Changeset 9312


Ignore:
Timestamp:
03/12/13 16:11:37 (7 years ago)
Author:
mkommend
Message:

#2016: Changes in the bubblechart:

  • Added possibility to select runs.
  • Added option to hide all selected runs.
  • Performance improvements regarding coloring, filtering and selection.
  • Corrected minor bug regarding categorial values in the bubblechart and boxplot view.
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  
    328328      if (!this.categoricalMapping.ContainsKey(dimension)) {
    329329        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())
    331331                                .Distinct()
    332332                                .OrderBy(x => x, new NaturalStringComparer());
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.Designer.cs

    r9277 r9312  
    6565      this.selectButton = new System.Windows.Forms.RadioButton();
    6666      this.radioButtonGroup = new System.Windows.Forms.GroupBox();
    67       this.colorButton = new System.Windows.Forms.Button();
     67      this.colorDialogButton = new System.Windows.Forms.Button();
    6868      this.colorDialog = new System.Windows.Forms.ColorDialog();
    6969      this.tooltip = new System.Windows.Forms.ToolTip(this.components);
     
    7575      this.transparencyTrackBar = new System.Windows.Forms.TrackBar();
    7676      this.transparencyLabel = new System.Windows.Forms.Label();
     77      this.colorRunsButton = new System.Windows.Forms.Button();
     78      this.hideRunsButton = new System.Windows.Forms.Button();
    7779      ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).BeginInit();
    7880      ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).BeginInit();
     
    257259      this.radioButtonGroup.Controls.Add(this.zoomButton);
    258260      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);
    260262      this.radioButtonGroup.Name = "radioButtonGroup";
    261       this.radioButtonGroup.Size = new System.Drawing.Size(135, 32);
     263      this.radioButtonGroup.Size = new System.Drawing.Size(122, 32);
    262264      this.radioButtonGroup.TabIndex = 19;
    263265      this.radioButtonGroup.TabStop = false;
    264266      //
    265       // colorButton
    266       //
    267       this.colorButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    268       this.colorButton.Enabled = false;
    269       this.colorButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
    270       this.colorButton.Location = new System.Drawing.Point(144, 469);
    271       this.colorButton.Name = "colorButton";
    272       this.colorButton.Size = new System.Drawing.Size(64, 21);
    273       this.colorButton.TabIndex = 20;
    274       this.colorButton.Text = "Color";
    275       this.colorButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
    276       this.colorButton.UseVisualStyleBackColor = true;
    277       this.colorButton.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);
    278280      //
    279281      // colorDialog
     
    341343      this.transparencyTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    342344      this.transparencyTrackBar.LargeChange = 16;
    343       this.transparencyTrackBar.Location = new System.Drawing.Point(295, 469);
     345      this.transparencyTrackBar.Location = new System.Drawing.Point(359, 470);
    344346      this.transparencyTrackBar.Maximum = 254;
    345347      this.transparencyTrackBar.Name = "transparencyTrackBar";
     
    347349      this.transparencyTrackBar.TabIndex = 24;
    348350      this.transparencyTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
     351      this.tooltip.SetToolTip(this.transparencyTrackBar, "Sets the transparency of the colors");
    349352      this.transparencyTrackBar.ValueChanged += new System.EventHandler(this.transparencyTrackBar_ValueChanged);
    350353      //
     
    353356      this.transparencyLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    354357      this.transparencyLabel.AutoSize = true;
    355       this.transparencyLabel.Location = new System.Drawing.Point(214, 474);
     358      this.transparencyLabel.Location = new System.Drawing.Point(278, 475);
    356359      this.transparencyLabel.Name = "transparencyLabel";
    357360      this.transparencyLabel.Size = new System.Drawing.Size(75, 13);
     
    359362      this.transparencyLabel.Text = "Transparency:";
    360363      //
     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      //
    361394      // RunCollectionBubbleChartView
    362395      //
     
    364397      this.BackColor = System.Drawing.SystemColors.Window;
    365398      this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     399      this.Controls.Add(this.hideRunsButton);
     400      this.Controls.Add(this.colorRunsButton);
    366401      this.Controls.Add(this.transparencyTrackBar);
    367402      this.Controls.Add(this.sizeTrackBar);
     
    369404      this.Controls.Add(this.colorXAxisButton);
    370405      this.Controls.Add(this.noRunsLabel);
    371       this.Controls.Add(this.colorButton);
     406      this.Controls.Add(this.colorDialogButton);
    372407      this.Controls.Add(this.radioButtonGroup);
    373408      this.Controls.Add(this.chart);
     
    412447    private System.Windows.Forms.RadioButton selectButton;
    413448    private System.Windows.Forms.GroupBox radioButtonGroup;
    414     private System.Windows.Forms.Button colorButton;
     449    private System.Windows.Forms.Button colorDialogButton;
    415450    private System.Windows.Forms.ColorDialog colorDialog;
    416451    private System.Windows.Forms.ToolTip tooltip;
     
    424459    private System.Windows.Forms.TrackBar transparencyTrackBar;
    425460    private System.Windows.Forms.Label transparencyLabel;
     461    private System.Windows.Forms.Button colorRunsButton;
     462    private System.Windows.Forms.Button hideRunsButton;
    426463  }
    427464}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r9276 r9312  
    4343    private string sizeAxisValue;
    4444
    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();
    5053    private double xJitterFactor = 0.0;
    5154    private double yJitterFactor = 0.0;
    52     private Random random;
    5355    private bool isSelecting = false;
    5456    private bool suppressUpdates = false;
    55 
    5657
    5758
     
    6465      chart.ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening);
    6566
    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 
    7267      colorDialog.Color = Color.Black;
    73       colorButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
     68      colorDialogButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
    7469      isSelecting = false;
    7570
     
    8782    public IStringConvertibleMatrix Matrix {
    8883      get { return this.Content; }
     84    }
     85    public IEnumerable<IRun> SelectedRuns {
     86      get { return selectedRuns; }
    8987    }
    9088
     
    9694      Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    9795      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     96      Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged);
    9897      Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
    99       Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged);
    10098      RegisterRunEvents(Content);
    10199    }
     
    107105      Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    108106      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     107      Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged);
    109108      Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
    110       Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged);
    111109      DeregisterRunEvents(Content);
    112110    }
     
    131129    }
    132130    private void run_Changed(object sender, EventArgs e) {
     131      if (suppressUpdates) return;
    133132      if (InvokeRequired)
    134133        this.Invoke(new EventHandler(run_Changed), sender, e);
     
    136135        IRun run = (IRun)sender;
    137136        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();
    138155      }
    139156    }
    140157
    141158    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;
    151164          }
    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;
    164183    }
    165184
     
    175194    private void RebuildInverseIndex() {
    176195      if (Content != null) {
    177         runToIndexMapping = new Dictionary<IRun, int>(Content.Count);
     196        runToIndexMapping.Clear();
    178197        int i = 0;
    179198        foreach (var run in Content) {
     
    233252    }
    234253
    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 
    245254    private void Content_AlgorithmNameChanged(object sender, EventArgs e) {
    246255      if (InvokeRequired)
     
    264273      series.Points.Clear();
    265274      runToDataPointMapping.Clear();
     275      selectedRuns.Clear();
    266276
    267277      chart.ChartAreas[0].AxisX.IsMarginVisible = xAxisValue != AxisDimension.Index.ToString();
     
    313323        double sizeChange = Math.Abs(sizeTrackBar.Value) * relativeSize;
    314324        point.MarkerSize = (int)Math.Round(sizeChange + smallestBubbleSize);
    315         point.Color = Color.FromArgb(255 - transparencyTrackBar.Value, ((IRun)point.Tag).Color);
    316325      }
    317326    }
     
    373382      if (xValue.HasValue && yValue.HasValue && sizeValue.HasValue) {
    374383        xValue = xValue.Value;
    375 
    376384        yValue = yValue.Value;
    377385
     
    379387          DataPoint point = new DataPoint(xValue.Value, new double[] { yValue.Value, sizeValue.Value });
    380388          point.Tag = run;
    381           point.Color = run.Color;
    382389          series.Points.Add(point);
    383390          if (!runToDataPointMapping.ContainsKey(run)) runToDataPointMapping.Add(run, new List<DataPoint>());
    384391          runToDataPointMapping[run].Add(point);
     392          UpdateRun(run);
    385393        }
    386394      }
     
    422430      if (!this.categoricalMapping.ContainsKey(dimension)) {
    423431        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())
    425433                                    .Distinct()
    426434                                    .OrderBy(x => x, new NaturalStringComparer());
     
    461469    }
    462470    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
    477489      if (xRange.IsAlmost(0.0)) xRange = 1.0;
    478490      if (yRange.IsAlmost(0.0)) yRange = 1.0;
     
    512524
    513525    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;
    547560    }
    548561
    549562    private void chart_MouseMove(object sender, MouseEventArgs e) {
     563      if (Control.MouseButtons != MouseButtons.None) return;
    550564      HitTestResult h = this.chart.HitTest(e.X, e.Y);
    551565      string newTooltipText = string.Empty;
     
    671685    private void zoomButton_CheckedChanged(object sender, EventArgs e) {
    672686      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;
    674690      this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = !isSelecting;
    675691      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();
    690693    }
    691694
     
    706709    }
    707710    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);
    709712      if (constraint == null) {
    710713        constraint = new RunCollectionContentConstraint();
     
    713716      }
    714717      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();
    715736    }
    716737
     
    761782
    762783    private void transparencyTrackBar_ValueChanged(object sender, EventArgs e) {
    763       UpdateMarkerSizes();
     784      foreach (var run in Content)
     785        UpdateRun(run);
    764786    }
    765787    #endregion
    766788
    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
    768815    private void colorXAxisButton_Click(object sender, EventArgs e) {
    769816      ColorRuns(xAxisValue);
    770817    }
    771 
    772818    private void colorYAxisButton_Click(object sender, EventArgs e) {
    773819      ColorRuns(yAxisValue);
    774820    }
    775 
    776821    private void ColorRuns(string axisValue) {
    777822      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.