Changeset 9312
- Timestamp:
- 03/12/13 16:11:37 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs
r9236 r9312 328 328 if (!this.categoricalMapping.ContainsKey(dimension)) { 329 329 this.categoricalMapping[dimension] = new Dictionary<object, double>(); 330 var orderedCategories = Content. Select(r => Content.GetValue(r, dimension).ToString())330 var orderedCategories = Content.Where(r=> r.Visible).Select(r => Content.GetValue(r, dimension).ToString()) 331 331 .Distinct() 332 332 .OrderBy(x => x, new NaturalStringComparer()); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.Designer.cs
r9277 r9312 65 65 this.selectButton = new System.Windows.Forms.RadioButton(); 66 66 this.radioButtonGroup = new System.Windows.Forms.GroupBox(); 67 this.color Button = new System.Windows.Forms.Button();67 this.colorDialogButton = new System.Windows.Forms.Button(); 68 68 this.colorDialog = new System.Windows.Forms.ColorDialog(); 69 69 this.tooltip = new System.Windows.Forms.ToolTip(this.components); … … 75 75 this.transparencyTrackBar = new System.Windows.Forms.TrackBar(); 76 76 this.transparencyLabel = new System.Windows.Forms.Label(); 77 this.colorRunsButton = new System.Windows.Forms.Button(); 78 this.hideRunsButton = new System.Windows.Forms.Button(); 77 79 ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).BeginInit(); 78 80 ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).BeginInit(); … … 257 259 this.radioButtonGroup.Controls.Add(this.zoomButton); 258 260 this.radioButtonGroup.Controls.Add(this.selectButton); 259 this.radioButtonGroup.Location = new System.Drawing.Point( 3, 461);261 this.radioButtonGroup.Location = new System.Drawing.Point(2, 461); 260 262 this.radioButtonGroup.Name = "radioButtonGroup"; 261 this.radioButtonGroup.Size = new System.Drawing.Size(1 35, 32);263 this.radioButtonGroup.Size = new System.Drawing.Size(122, 32); 262 264 this.radioButtonGroup.TabIndex = 19; 263 265 this.radioButtonGroup.TabStop = false; 264 266 // 265 // color Button266 // 267 this.color Button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));268 this.color Button.Enabled = false;269 this.color Button.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;270 this.color Button.Location = new System.Drawing.Point(144, 469);271 this.color Button.Name = "colorButton";272 this.color Button.Size = new System.Drawing.Size(64, 21);273 this.color Button.TabIndex = 20;274 this.color Button.Text = "Color";275 this. colorButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;276 this.color Button.UseVisualStyleBackColor = true;277 this.color Button.Click += new System.EventHandler(this.colorButton_Click);267 // colorDialogButton 268 // 269 this.colorDialogButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 270 this.colorDialogButton.Enabled = false; 271 this.colorDialogButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 272 this.colorDialogButton.Location = new System.Drawing.Point(130, 469); 273 this.colorDialogButton.Name = "colorDialogButton"; 274 this.colorDialogButton.Size = new System.Drawing.Size(21, 21); 275 this.colorDialogButton.TabIndex = 20; 276 this.colorDialogButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight; 277 this.tooltip.SetToolTip(this.colorDialogButton, "Choose color"); 278 this.colorDialogButton.UseVisualStyleBackColor = true; 279 this.colorDialogButton.Click += new System.EventHandler(this.colorDialogButton_Click); 278 280 // 279 281 // colorDialog … … 341 343 this.transparencyTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 342 344 this.transparencyTrackBar.LargeChange = 16; 343 this.transparencyTrackBar.Location = new System.Drawing.Point( 295, 469);345 this.transparencyTrackBar.Location = new System.Drawing.Point(359, 470); 344 346 this.transparencyTrackBar.Maximum = 254; 345 347 this.transparencyTrackBar.Name = "transparencyTrackBar"; … … 347 349 this.transparencyTrackBar.TabIndex = 24; 348 350 this.transparencyTrackBar.TickStyle = System.Windows.Forms.TickStyle.None; 351 this.tooltip.SetToolTip(this.transparencyTrackBar, "Sets the transparency of the colors"); 349 352 this.transparencyTrackBar.ValueChanged += new System.EventHandler(this.transparencyTrackBar_ValueChanged); 350 353 // … … 353 356 this.transparencyLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 354 357 this.transparencyLabel.AutoSize = true; 355 this.transparencyLabel.Location = new System.Drawing.Point(2 14, 474);358 this.transparencyLabel.Location = new System.Drawing.Point(278, 475); 356 359 this.transparencyLabel.Name = "transparencyLabel"; 357 360 this.transparencyLabel.Size = new System.Drawing.Size(75, 13); … … 359 362 this.transparencyLabel.Text = "Transparency:"; 360 363 // 364 // colorRunsButton 365 // 366 this.colorRunsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 367 this.colorRunsButton.Enabled = false; 368 this.colorRunsButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 369 this.colorRunsButton.Location = new System.Drawing.Point(151, 469); 370 this.colorRunsButton.Name = "colorRunsButton"; 371 this.colorRunsButton.Size = new System.Drawing.Size(43, 21); 372 this.colorRunsButton.TabIndex = 25; 373 this.colorRunsButton.Text = "Color"; 374 this.colorRunsButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight; 375 this.tooltip.SetToolTip(this.colorRunsButton, "Color all selected runs"); 376 this.colorRunsButton.UseVisualStyleBackColor = true; 377 this.colorRunsButton.Click += new System.EventHandler(this.colorRunsButton_Click); 378 // 379 // hideRunsButton 380 // 381 this.hideRunsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 382 this.hideRunsButton.Enabled = false; 383 this.hideRunsButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 384 this.hideRunsButton.Location = new System.Drawing.Point(194, 469); 385 this.hideRunsButton.Name = "hideRunsButton"; 386 this.hideRunsButton.Size = new System.Drawing.Size(43, 21); 387 this.hideRunsButton.TabIndex = 26; 388 this.hideRunsButton.Text = "Hide"; 389 this.hideRunsButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight; 390 this.tooltip.SetToolTip(this.hideRunsButton, "Hides all selected runs"); 391 this.hideRunsButton.UseVisualStyleBackColor = true; 392 this.hideRunsButton.Click += new System.EventHandler(this.hideRunsButton_Click); 393 // 361 394 // RunCollectionBubbleChartView 362 395 // … … 364 397 this.BackColor = System.Drawing.SystemColors.Window; 365 398 this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 399 this.Controls.Add(this.hideRunsButton); 400 this.Controls.Add(this.colorRunsButton); 366 401 this.Controls.Add(this.transparencyTrackBar); 367 402 this.Controls.Add(this.sizeTrackBar); … … 369 404 this.Controls.Add(this.colorXAxisButton); 370 405 this.Controls.Add(this.noRunsLabel); 371 this.Controls.Add(this.color Button);406 this.Controls.Add(this.colorDialogButton); 372 407 this.Controls.Add(this.radioButtonGroup); 373 408 this.Controls.Add(this.chart); … … 412 447 private System.Windows.Forms.RadioButton selectButton; 413 448 private System.Windows.Forms.GroupBox radioButtonGroup; 414 private System.Windows.Forms.Button color Button;449 private System.Windows.Forms.Button colorDialogButton; 415 450 private System.Windows.Forms.ColorDialog colorDialog; 416 451 private System.Windows.Forms.ToolTip tooltip; … … 424 459 private System.Windows.Forms.TrackBar transparencyTrackBar; 425 460 private System.Windows.Forms.Label transparencyLabel; 461 private System.Windows.Forms.Button colorRunsButton; 462 private System.Windows.Forms.Button hideRunsButton; 426 463 } 427 464 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs
r9276 r9312 43 43 private string sizeAxisValue; 44 44 45 private Dictionary<IRun, List<DataPoint>> runToDataPointMapping; 46 private Dictionary<IRun, int> runToIndexMapping; 47 private Dictionary<int, Dictionary<object, double>> categoricalMapping; 48 private Dictionary<IRun, double> xJitter; 49 private Dictionary<IRun, double> yJitter; 45 private readonly Dictionary<IRun, List<DataPoint>> runToDataPointMapping = new Dictionary<IRun, List<DataPoint>>(); 46 private readonly Dictionary<IRun, int> runToIndexMapping = new Dictionary<IRun, int>(); 47 private readonly Dictionary<int, Dictionary<object, double>> categoricalMapping = new Dictionary<int, Dictionary<object, double>>(); 48 private readonly Dictionary<IRun, double> xJitter = new Dictionary<IRun, double>(); 49 private readonly Dictionary<IRun, double> yJitter = new Dictionary<IRun, double>(); 50 51 private readonly HashSet<IRun> selectedRuns = new HashSet<IRun>(); 52 private readonly Random random = new Random(); 50 53 private double xJitterFactor = 0.0; 51 54 private double yJitterFactor = 0.0; 52 private Random random;53 55 private bool isSelecting = false; 54 56 private bool suppressUpdates = false; 55 56 57 57 58 … … 64 65 chart.ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening); 65 66 66 runToDataPointMapping = new Dictionary<IRun, List<DataPoint>>();67 categoricalMapping = new Dictionary<int, Dictionary<object, double>>();68 xJitter = new Dictionary<IRun, double>();69 yJitter = new Dictionary<IRun, double>();70 random = new Random();71 72 67 colorDialog.Color = Color.Black; 73 color Button.Image = this.GenerateImage(16, 16, this.colorDialog.Color);68 colorDialogButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color); 74 69 isSelecting = false; 75 70 … … 87 82 public IStringConvertibleMatrix Matrix { 88 83 get { return this.Content; } 84 } 85 public IEnumerable<IRun> SelectedRuns { 86 get { return selectedRuns; } 89 87 } 90 88 … … 96 94 Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 97 95 Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 96 Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged); 98 97 Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged); 99 Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged);100 98 RegisterRunEvents(Content); 101 99 } … … 107 105 Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 108 106 Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 107 Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged); 109 108 Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged); 110 Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged);111 109 DeregisterRunEvents(Content); 112 110 } … … 131 129 } 132 130 private void run_Changed(object sender, EventArgs e) { 131 if (suppressUpdates) return; 133 132 if (InvokeRequired) 134 133 this.Invoke(new EventHandler(run_Changed), sender, e); … … 136 135 IRun run = (IRun)sender; 137 136 UpdateRun(run); 137 UpdateCursorInterval(); 138 chart.ChartAreas[0].RecalculateAxesScale(); 139 UpdateAxisLabels(); 140 } 141 } 142 143 private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 144 if (InvokeRequired) 145 this.Invoke(new EventHandler(Content_UpdateOfRunsInProgressChanged), sender, e); 146 else { 147 suppressUpdates = Content.UpdateOfRunsInProgress; 148 if (suppressUpdates) return; 149 150 foreach (var run in Content) UpdateRun(run); 151 UpdateMarkerSizes(); 152 UpdateCursorInterval(); 153 chart.ChartAreas[0].RecalculateAxesScale(); 154 UpdateAxisLabels(); 138 155 } 139 156 } 140 157 141 158 private void UpdateRun(IRun run) { 142 if (!suppressUpdates) { 143 if (runToDataPointMapping.ContainsKey(run)) { 144 foreach (DataPoint point in runToDataPointMapping[run]) { 145 point.Color = run.Color; 146 if (!run.Visible) { 147 this.chart.Series[0].Points.Remove(point); 148 UpdateCursorInterval(); 149 chart.ChartAreas[0].RecalculateAxesScale(); 150 } 159 if (runToDataPointMapping.ContainsKey(run)) { 160 foreach (DataPoint point in runToDataPointMapping[run]) { 161 if (!run.Visible) { 162 this.chart.Series[0].Points.Remove(point); 163 continue; 151 164 } 152 if (!run.Visible) runToDataPointMapping.Remove(run); 153 } else { 154 AddDataPoint(run); 155 UpdateCursorInterval(); 156 chart.ChartAreas[0].RecalculateAxesScale(); 157 } 158 159 if (this.chart.Series[0].Points.Count == 0) 160 noRunsLabel.Visible = true; 161 else 162 noRunsLabel.Visible = false; 163 } 165 if (selectedRuns.Contains(run)) { 166 point.Color = Color.Red; 167 point.MarkerStyle = MarkerStyle.Cross; 168 } else { 169 point.Color = Color.FromArgb(255 - transparencyTrackBar.Value, ((IRun)point.Tag).Color); 170 point.MarkerStyle = MarkerStyle.Circle; 171 } 172 173 } 174 if (!run.Visible) runToDataPointMapping.Remove(run); 175 } else { 176 AddDataPoint(run); 177 } 178 179 if (this.chart.Series[0].Points.Count == 0) 180 noRunsLabel.Visible = true; 181 else 182 noRunsLabel.Visible = false; 164 183 } 165 184 … … 175 194 private void RebuildInverseIndex() { 176 195 if (Content != null) { 177 runToIndexMapping = new Dictionary<IRun, int>(Content.Count);196 runToIndexMapping.Clear(); 178 197 int i = 0; 179 198 foreach (var run in Content) { … … 233 252 } 234 253 235 236 private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {237 if (InvokeRequired)238 Invoke(new EventHandler(Content_UpdateOfRunsInProgressChanged), sender, e);239 else {240 suppressUpdates = Content.UpdateOfRunsInProgress;241 if (!suppressUpdates) UpdateDataPoints();242 }243 }244 245 254 private void Content_AlgorithmNameChanged(object sender, EventArgs e) { 246 255 if (InvokeRequired) … … 264 273 series.Points.Clear(); 265 274 runToDataPointMapping.Clear(); 275 selectedRuns.Clear(); 266 276 267 277 chart.ChartAreas[0].AxisX.IsMarginVisible = xAxisValue != AxisDimension.Index.ToString(); … … 313 323 double sizeChange = Math.Abs(sizeTrackBar.Value) * relativeSize; 314 324 point.MarkerSize = (int)Math.Round(sizeChange + smallestBubbleSize); 315 point.Color = Color.FromArgb(255 - transparencyTrackBar.Value, ((IRun)point.Tag).Color);316 325 } 317 326 } … … 373 382 if (xValue.HasValue && yValue.HasValue && sizeValue.HasValue) { 374 383 xValue = xValue.Value; 375 376 384 yValue = yValue.Value; 377 385 … … 379 387 DataPoint point = new DataPoint(xValue.Value, new double[] { yValue.Value, sizeValue.Value }); 380 388 point.Tag = run; 381 point.Color = run.Color;382 389 series.Points.Add(point); 383 390 if (!runToDataPointMapping.ContainsKey(run)) runToDataPointMapping.Add(run, new List<DataPoint>()); 384 391 runToDataPointMapping[run].Add(point); 392 UpdateRun(run); 385 393 } 386 394 } … … 422 430 if (!this.categoricalMapping.ContainsKey(dimension)) { 423 431 this.categoricalMapping[dimension] = new Dictionary<object, double>(); 424 var orderedCategories = Content. Select(r => Content.GetValue(r, dimension).ToString())432 var orderedCategories = Content.Where(r => r.Visible).Select(r => Content.GetValue(r, dimension).ToString()) 425 433 .Distinct() 426 434 .OrderBy(x => x, new NaturalStringComparer()); … … 461 469 } 462 470 private void UpdateCursorInterval() { 463 Series series = chart.Series[0]; 464 double[] xValues = (from point in series.Points 465 where !point.IsEmpty 466 select point.XValue) 467 .DefaultIfEmpty(1.0) 468 .ToArray(); 469 double[] yValues = (from point in series.Points 470 where !point.IsEmpty 471 select point.YValues[0]) 472 .DefaultIfEmpty(1.0) 473 .ToArray(); 474 475 double xRange = xValues.Max() - xValues.Min(); 476 double yRange = yValues.Max() - yValues.Min(); 471 double xMin = double.MaxValue; 472 double xMax = double.MinValue; 473 double yMin = double.MaxValue; 474 double yMax = double.MinValue; 475 476 foreach (var point in chart.Series[0].Points) { 477 if (point.IsEmpty) continue; 478 if (point.XValue < xMin) xMin = point.XValue; 479 if (point.XValue > xMax) xMax = point.XValue; 480 if (point.YValues[0] < yMin) yMin = point.YValues[0]; 481 if (point.YValues[0] > yMax) yMax = point.YValues[0]; 482 } 483 484 double xRange = 0.0; 485 double yRange = 0.0; 486 if (xMin != double.MaxValue && xMax != double.MinValue) xRange = xMax - xMin; 487 if (yMin != double.MaxValue && yMax != double.MinValue) yRange = yMax - yMin; 488 477 489 if (xRange.IsAlmost(0.0)) xRange = 1.0; 478 490 if (yRange.IsAlmost(0.0)) yRange = 1.0; … … 512 524 513 525 private void chart_MouseUp(object sender, MouseEventArgs e) { 514 if (isSelecting) { 515 System.Windows.Forms.DataVisualization.Charting.Cursor xCursor = chart.ChartAreas[0].CursorX; 516 System.Windows.Forms.DataVisualization.Charting.Cursor yCursor = chart.ChartAreas[0].CursorY; 517 518 double minX = Math.Min(xCursor.SelectionStart, xCursor.SelectionEnd); 519 double maxX = Math.Max(xCursor.SelectionStart, xCursor.SelectionEnd); 520 double minY = Math.Min(yCursor.SelectionStart, yCursor.SelectionEnd); 521 double maxY = Math.Max(yCursor.SelectionStart, yCursor.SelectionEnd); 522 523 //check for click to select model 524 if (minX == maxX && minY == maxY) { 525 HitTestResult hitTest = chart.HitTest(e.X, e.Y); 526 if (hitTest.ChartElementType == ChartElementType.DataPoint) { 527 int pointIndex = hitTest.PointIndex; 528 IRun run = (IRun)this.chart.Series[0].Points[pointIndex].Tag; 529 run.Color = colorDialog.Color; 530 } 531 } else { 532 List<DataPoint> selectedPoints = new List<DataPoint>(); 533 foreach (DataPoint p in this.chart.Series[0].Points) { 534 if (p.XValue >= minX && p.XValue < maxX && 535 p.YValues[0] >= minY && p.YValues[0] < maxY) { 536 selectedPoints.Add(p); 537 } 538 } 539 foreach (DataPoint p in selectedPoints) { 540 IRun run = (IRun)p.Tag; 541 run.Color = colorDialog.Color; 542 } 543 } 544 this.chart.ChartAreas[0].CursorX.SelectionStart = this.chart.ChartAreas[0].CursorX.SelectionEnd; 545 this.chart.ChartAreas[0].CursorY.SelectionStart = this.chart.ChartAreas[0].CursorY.SelectionEnd; 546 } 526 if (!isSelecting) return; 527 528 System.Windows.Forms.DataVisualization.Charting.Cursor xCursor = chart.ChartAreas[0].CursorX; 529 System.Windows.Forms.DataVisualization.Charting.Cursor yCursor = chart.ChartAreas[0].CursorY; 530 531 double minX = Math.Min(xCursor.SelectionStart, xCursor.SelectionEnd); 532 double maxX = Math.Max(xCursor.SelectionStart, xCursor.SelectionEnd); 533 double minY = Math.Min(yCursor.SelectionStart, yCursor.SelectionEnd); 534 double maxY = Math.Max(yCursor.SelectionStart, yCursor.SelectionEnd); 535 536 //check for click to select a single model 537 if (minX == maxX && minY == maxY) { 538 HitTestResult hitTest = chart.HitTest(e.X, e.Y); 539 if (hitTest.ChartElementType == ChartElementType.DataPoint) { 540 int pointIndex = hitTest.PointIndex; 541 var point = chart.Series[0].Points[pointIndex]; 542 IRun run = (IRun)point.Tag; 543 point.Color = Color.Red; 544 point.MarkerStyle = MarkerStyle.Cross; 545 selectedRuns.Add(run); 546 547 } else ClearSelectedRuns(); 548 } else { 549 foreach (DataPoint point in this.chart.Series[0].Points) { 550 if (point.XValue < minX || point.XValue >= maxX) continue; 551 if (point.YValues[0] < minY || point.YValues[0] >= maxY) continue; 552 point.MarkerStyle = MarkerStyle.Cross; 553 point.Color = Color.Red; 554 IRun run = (IRun)point.Tag; 555 selectedRuns.Add(run); 556 } 557 } 558 this.chart.ChartAreas[0].CursorX.SelectionStart = this.chart.ChartAreas[0].CursorX.SelectionEnd; 559 this.chart.ChartAreas[0].CursorY.SelectionStart = this.chart.ChartAreas[0].CursorY.SelectionEnd; 547 560 } 548 561 549 562 private void chart_MouseMove(object sender, MouseEventArgs e) { 563 if (Control.MouseButtons != MouseButtons.None) return; 550 564 HitTestResult h = this.chart.HitTest(e.X, e.Y); 551 565 string newTooltipText = string.Empty; … … 671 685 private void zoomButton_CheckedChanged(object sender, EventArgs e) { 672 686 this.isSelecting = selectButton.Checked; 673 this.colorButton.Enabled = this.isSelecting; 687 this.colorDialogButton.Enabled = this.isSelecting; 688 this.colorRunsButton.Enabled = this.isSelecting; 689 this.hideRunsButton.Enabled = this.isSelecting; 674 690 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = !isSelecting; 675 691 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = !isSelecting; 676 } 677 private void colorButton_Click(object sender, EventArgs e) { 678 if (colorDialog.ShowDialog(this) == DialogResult.OK) { 679 this.colorButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color); 680 } 681 } 682 private Image GenerateImage(int width, int height, Color fillColor) { 683 Image colorImage = new Bitmap(width, height); 684 using (Graphics gfx = Graphics.FromImage(colorImage)) { 685 using (SolidBrush brush = new SolidBrush(fillColor)) { 686 gfx.FillRectangle(brush, 0, 0, width, height); 687 } 688 } 689 return colorImage; 692 ClearSelectedRuns(); 690 693 } 691 694 … … 706 709 } 707 710 private void hideRunToolStripMenuItem_Click(object sender, EventArgs e) { 708 var constraint = Content.Constraints.OfType<RunCollectionContentConstraint>(). Where(c => c.Active).FirstOrDefault();711 var constraint = Content.Constraints.OfType<RunCollectionContentConstraint>().FirstOrDefault(c => c.Active); 709 712 if (constraint == null) { 710 713 constraint = new RunCollectionContentConstraint(); … … 713 716 } 714 717 constraint.ConstraintData.Add(runToHide); 718 } 719 private void hideRunsButton_Click(object sender, EventArgs e) { 720 if (!selectedRuns.Any()) return; 721 var constraint = new RunCollectionContentConstraint(); 722 constraint.ConstraintData = new ItemSet<IRun>(selectedRuns); 723 Content.Constraints.Add(constraint); 724 ClearSelectedRuns(); 725 constraint.Active = true; 726 } 727 728 private void ClearSelectedRuns() { 729 foreach (var run in selectedRuns) { 730 foreach (var point in runToDataPointMapping[run]) { 731 point.MarkerStyle = MarkerStyle.Circle; 732 point.Color = Color.FromArgb(255 - transparencyTrackBar.Value, run.Color); 733 } 734 } 735 selectedRuns.Clear(); 715 736 } 716 737 … … 761 782 762 783 private void transparencyTrackBar_ValueChanged(object sender, EventArgs e) { 763 UpdateMarkerSizes(); 784 foreach (var run in Content) 785 UpdateRun(run); 764 786 } 765 787 #endregion 766 788 767 #region Automatic coloring 789 #region coloring 790 private void colorDialogButton_Click(object sender, EventArgs e) { 791 if (colorDialog.ShowDialog(this) == DialogResult.OK) { 792 this.colorDialogButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color); 793 } 794 } 795 private Image GenerateImage(int width, int height, Color fillColor) { 796 Image colorImage = new Bitmap(width, height); 797 using (Graphics gfx = Graphics.FromImage(colorImage)) { 798 using (SolidBrush brush = new SolidBrush(fillColor)) { 799 gfx.FillRectangle(brush, 0, 0, width, height); 800 } 801 } 802 return colorImage; 803 } 804 805 private void colorRunsButton_Click(object sender, EventArgs e) { 806 if (!selectedRuns.Any()) return; 807 Content.UpdateOfRunsInProgress = true; 808 foreach (var run in selectedRuns) 809 run.Color = colorDialog.Color; 810 811 ClearSelectedRuns(); 812 Content.UpdateOfRunsInProgress = false; 813 } 814 768 815 private void colorXAxisButton_Click(object sender, EventArgs e) { 769 816 ColorRuns(xAxisValue); 770 817 } 771 772 818 private void colorYAxisButton_Click(object sender, EventArgs e) { 773 819 ColorRuns(yAxisValue); 774 820 } 775 776 821 private void ColorRuns(string axisValue) { 777 822 var runs = Content.Where(r => r.Visible).Select(r => new { Run = r, Value = GetValue(r, axisValue) }).Where(r => r.Value.HasValue).ToList();
Note: See TracChangeset
for help on using the changeset viewer.