Changeset 3459
- Timestamp:
- 04/21/10 13:47:06 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.Designer.cs
r3440 r3459 175 175 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 176 176 this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown); 177 this.chart.LostFocus += new System.EventHandler(this.chart_LostFocus);178 177 // 179 178 // zoomButton -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs
r3454 r3459 225 225 #region drag and drop 226 226 private IRun draggedRun; 227 private bool isDragOperationInProgress = false;228 229 227 private void chart_MouseDown(object sender, MouseEventArgs e) { 230 228 HitTestResult h = this.chart.HitTest(e.X, e.Y); 231 229 if (h.ChartElementType == ChartElementType.DataPoint) { 232 IRun run = (IRun)((DataPoint)h.Object).Tag;230 IRun run = (IRun)((DataPoint)h.Object).Tag; 233 231 if (e.Clicks >= 2) { 234 232 IContentView view = MainFormManager.CreateDefaultView(run); … … 238 236 } else { 239 237 this.draggedRun = run; 240 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = false; 241 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = false; 242 this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = false; 243 this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = false; 238 this.chart.ChartAreas[0].CursorX.SetSelectionPosition(double.NaN, double.NaN); 239 this.chart.ChartAreas[0].CursorY.SetSelectionPosition(double.NaN, double.NaN); 244 240 } 245 241 } … … 247 243 248 244 private void chart_MouseUp(object sender, MouseEventArgs e) { 249 if (isDragOperationInProgress) { 250 this.isDragOperationInProgress = false; 251 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = !isSelecting; 252 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = !isSelecting; 253 this.chart.ChartAreas[0].CursorX.SetSelectionPosition(0, 0); 254 this.chart.ChartAreas[0].CursorY.SetSelectionPosition(0, 0); 255 this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; 256 this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; 257 return; 258 } 259 if (!isSelecting) return; 260 System.Windows.Forms.DataVisualization.Charting.Cursor xCursor = chart.ChartAreas[0].CursorX; 261 System.Windows.Forms.DataVisualization.Charting.Cursor yCursor = chart.ChartAreas[0].CursorY; 262 263 double minX = Math.Min(xCursor.SelectionStart, xCursor.SelectionEnd); 264 double maxX = Math.Max(xCursor.SelectionStart, xCursor.SelectionEnd); 265 double minY = Math.Min(yCursor.SelectionStart, yCursor.SelectionEnd); 266 double maxY = Math.Max(yCursor.SelectionStart, yCursor.SelectionEnd); 267 268 //check for click to select model 269 if (minX == maxX && minY == maxY) { 270 HitTestResult hitTest = chart.HitTest(e.X, e.Y); 271 if (hitTest.ChartElementType == ChartElementType.DataPoint) { 272 int pointIndex = hitTest.PointIndex; 273 IRun run = (IRun)this.chart.Series[0].Points[pointIndex].Tag; 274 run.Color = colorDialog.Color; 275 } 276 } else { 277 List<DataPoint> selectedPoints = new List<DataPoint>(); 278 foreach (DataPoint p in this.chart.Series[0].Points) { 279 if (p.XValue >= minX && p.XValue < maxX && 280 p.YValues[0] >= minY && p.YValues[0] < maxY) { 281 selectedPoints.Add(p); 282 } 283 } 284 foreach (DataPoint p in selectedPoints) { 285 IRun run = (IRun)p.Tag; 286 run.Color = colorDialog.Color; 287 } 288 xCursor.SetSelectionPosition(0, 0); 289 yCursor.SetSelectionPosition(0, 0); 245 if (isSelecting) { 246 System.Windows.Forms.DataVisualization.Charting.Cursor xCursor = chart.ChartAreas[0].CursorX; 247 System.Windows.Forms.DataVisualization.Charting.Cursor yCursor = chart.ChartAreas[0].CursorY; 248 249 double minX = Math.Min(xCursor.SelectionStart, xCursor.SelectionEnd); 250 double maxX = Math.Max(xCursor.SelectionStart, xCursor.SelectionEnd); 251 double minY = Math.Min(yCursor.SelectionStart, yCursor.SelectionEnd); 252 double maxY = Math.Max(yCursor.SelectionStart, yCursor.SelectionEnd); 253 254 //check for click to select model 255 if (minX == maxX && minY == maxY) { 256 HitTestResult hitTest = chart.HitTest(e.X, e.Y); 257 if (hitTest.ChartElementType == ChartElementType.DataPoint) { 258 int pointIndex = hitTest.PointIndex; 259 IRun run = (IRun)this.chart.Series[0].Points[pointIndex].Tag; 260 run.Color = colorDialog.Color; 261 } 262 } else { 263 List<DataPoint> selectedPoints = new List<DataPoint>(); 264 foreach (DataPoint p in this.chart.Series[0].Points) { 265 if (p.XValue >= minX && p.XValue < maxX && 266 p.YValues[0] >= minY && p.YValues[0] < maxY) { 267 selectedPoints.Add(p); 268 } 269 } 270 foreach (DataPoint p in selectedPoints) { 271 IRun run = (IRun)p.Tag; 272 run.Color = colorDialog.Color; 273 } 274 } 275 this.chart.ChartAreas[0].CursorX.SetSelectionPosition(double.NaN, double.NaN); 276 this.chart.ChartAreas[0].CursorY.SetSelectionPosition(double.NaN, double.NaN); 290 277 } 291 278 } … … 295 282 HitTestResult h = this.chart.HitTest(e.X, e.Y); 296 283 if (this.draggedRun != null && h.ChartElementType != ChartElementType.DataPoint) { 297 this.isDragOperationInProgress = true;298 284 DataObject data = new DataObject(); 299 285 data.SetData("Type", draggedRun.GetType()); 300 286 data.SetData("Value", draggedRun); 301 if (ReadOnly) {287 if (ReadOnly) 302 288 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 303 }else {289 else { 304 290 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 305 291 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 306 292 Content.Remove(draggedRun); 307 293 } 294 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = !isSelecting; 295 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = !isSelecting; 308 296 this.draggedRun = null; 309 297 } 310 }311 }312 private void chart_LostFocus(object sender, EventArgs e) {313 if (this.isDragOperationInProgress) {314 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = !isSelecting;315 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = !isSelecting;316 this.chart.ChartAreas[0].CursorX.SetSelectionPosition(0, 0);317 this.chart.ChartAreas[0].CursorY.SetSelectionPosition(0, 0);318 this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;319 this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;320 this.isDragOperationInProgress = false;321 298 } 322 299 }
Note: See TracChangeset
for help on using the changeset viewer.