Changeset 15973 for branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews
- Timestamp:
- 06/28/18 11:13:37 (6 years ago)
- Location:
- branches/2522_RefactorPluginInfrastructure
- Files:
-
- 12 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2522_RefactorPluginInfrastructure
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views
- Property svn:mergeinfo changed
-
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 54 54 this.yAxisComboBox = new System.Windows.Forms.ComboBox(); 55 55 this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart(); 56 this.openBubbleChartViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 56 57 this.noRunsLabel = new System.Windows.Forms.Label(); 57 58 this.splitContainer = new System.Windows.Forms.SplitContainer(); … … 132 133 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 133 134 // 135 // openBubbleChartViewToolStripMenuItem 136 // 137 this.openBubbleChartViewToolStripMenuItem.Name = "openBubbleChartViewToolStripMenuItem"; 138 this.openBubbleChartViewToolStripMenuItem.Size = new System.Drawing.Size(256, 22); 139 this.openBubbleChartViewToolStripMenuItem.Text = "Open BubbleChart View"; 140 this.openBubbleChartViewToolStripMenuItem.Click += new System.EventHandler(this.openBubbleChartViewToolStripMenuItem_Click); 141 // 134 142 // noRunsLabel 135 143 // … … 239 247 private System.Windows.Forms.ToolTip tooltip; 240 248 protected System.Windows.Forms.CheckBox showStatisticsCheckBox; 249 private System.Windows.Forms.ToolStripMenuItem openBubbleChartViewToolStripMenuItem; 241 250 } 242 251 } -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs
r13051 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 48 48 public RunCollectionBoxPlotView() { 49 49 InitializeComponent(); 50 chart.ContextMenuStrip.Items.Insert(0, openBubbleChartViewToolStripMenuItem); 51 50 52 categoricalMapping = new Dictionary<int, Dictionary<object, double>>(); 51 53 seriesCache = new SortedDictionary<double, Series>(); … … 211 213 212 214 private void UpdateStatistics() { 213 DoubleMatrix matrix = new DoubleMatrix( 9, seriesCache.Count);215 DoubleMatrix matrix = new DoubleMatrix(10, seriesCache.Count); 214 216 matrix.SortableView = false; 215 217 List<string> columnNames = new List<string>(); … … 224 226 AxisDimension axisDimension = (AxisDimension)Enum.Parse(typeof(AxisDimension), selectedAxis); 225 227 switch (axisDimension) { 226 case AxisDimension.Color: value = new StringValue(run.Color.ToString()); 228 case AxisDimension.Color: 229 value = new StringValue(run.Color.ToString()); 227 230 break; 228 231 } … … 236 239 } 237 240 matrix.ColumnNames = columnNames; 238 matrix.RowNames = new string[] { "Count", "Minimum", "Maximum", "Median", "Average", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile" };241 matrix.RowNames = new string[] { "Count", "Minimum", "Maximum", "Median", "Average", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Interquartile Range" }; 239 242 240 243 for (int i = 0; i < seriesCache.Count; i++) { … … 250 253 matrix[7, i] = seriesValues.Quantile(0.25); 251 254 matrix[8, i] = seriesValues.Quantile(0.75); 255 matrix[9, i] = matrix[8, i] - matrix[7, i]; 252 256 } 253 257 statisticsMatrixView.Content = matrix; … … 276 280 double? yValue; 277 281 278 if (!xAxisComboBox.DroppedDown) 279 this.xAxisValue = (string)xAxisComboBox.SelectedItem; 280 if (!yAxisComboBox.DroppedDown) 281 this.yAxisValue = (string)yAxisComboBox.SelectedItem; 282 this.xAxisValue = (string)xAxisComboBox.SelectedItem; 283 this.yAxisValue = (string)yAxisComboBox.SelectedItem; 282 284 283 285 xValue = GetValue(run, this.xAxisValue); … … 382 384 UpdateDataPoints(); 383 385 } 386 384 387 private void UpdateAxisLabels() { 385 388 Axis xAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisX; 386 389 Axis yAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisY; 387 390 int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count(); 388 //mkommend: combobox.SelectedIndex could not be used as this changes during hovering over possible values 389 var xSAxisSelectedIndex = xAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(xAxisValue); 390 var ySAxisSelectedIndex = yAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(yAxisValue); 391 SetCustomAxisLabels(xAxis, xSAxisSelectedIndex - axisDimensionCount); 392 SetCustomAxisLabels(yAxis, ySAxisSelectedIndex - axisDimensionCount); 393 if (xAxisValue != null) 394 xAxis.Title = xAxisValue; 395 if (yAxisValue != null) 396 yAxis.Title = yAxisValue; 391 392 SetCustomAxisLabels(xAxis, xAxisComboBox.SelectedIndex - axisDimensionCount); 393 SetCustomAxisLabels(yAxis, yAxisComboBox.SelectedIndex - axisDimensionCount); 394 395 xAxis.Title = (string)xAxisComboBox.SelectedItem; 396 yAxis.Title = (string)yAxisComboBox.SelectedItem; 397 397 } 398 398 … … 402 402 403 403 private void SetCustomAxisLabels(Axis axis, int dimension) { 404 if (Content == null) { return; } 405 if (!Content.Any()) { return; } 406 404 407 axis.CustomLabels.Clear(); 405 408 if (categoricalMapping.ContainsKey(dimension)) { … … 445 448 } 446 449 450 private void openBubbleChartViewToolStripMenuItem_Click(object sender, EventArgs e) { 451 RunCollectionBubbleChartView bubbleChartView = new RunCollectionBubbleChartView(); 452 bubbleChartView.Content = this.Content; 453 bubbleChartView.xAxisComboBox.SelectedItem = xAxisComboBox.SelectedItem; 454 bubbleChartView.yAxisComboBox.SelectedItem = yAxisComboBox.SelectedItem; 455 bubbleChartView.Show(); 456 } 457 447 458 private void chart_MouseMove(object sender, MouseEventArgs e) { 448 459 string newTooltipText = string.Empty; … … 463 474 } 464 475 476 public bool StatisticsVisible { 477 get { return splitContainer.Panel2Collapsed; } 478 set { splitContainer.Panel2Collapsed = value; } 479 } 480 465 481 public void SetXAxis(string axisName) { 466 482 xAxisComboBox.SelectedItem = axisName; -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 139 139 this.xAxisComboBox.Size = new System.Drawing.Size(400, 21); 140 140 this.xAxisComboBox.TabIndex = 7; 141 this.xAxisComboBox.Sorted = false; 141 142 this.xAxisComboBox.SelectedValueChanged += new System.EventHandler(this.AxisComboBox_SelectedValueChanged); 142 143 // … … 160 161 this.yAxisComboBox.Size = new System.Drawing.Size(400, 21); 161 162 this.yAxisComboBox.TabIndex = 5; 163 this.yAxisComboBox.Sorted = false; 162 164 this.yAxisComboBox.SelectedValueChanged += new System.EventHandler(this.AxisComboBox_SelectedValueChanged); 163 165 // … … 183 185 this.sizeComboBox.Name = "sizeComboBox"; 184 186 this.sizeComboBox.Size = new System.Drawing.Size(300, 21); 187 this.sizeComboBox.Sorted = false; 185 188 this.sizeComboBox.TabIndex = 14; 186 189 this.sizeComboBox.SelectedValueChanged += new System.EventHandler(this.AxisComboBox_SelectedValueChanged); … … 198 201 // chart 199 202 // 200 this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 201 | System.Windows.Forms.AnchorStyles.Left) 203 this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 204 | System.Windows.Forms.AnchorStyles.Left) 202 205 | System.Windows.Forms.AnchorStyles.Right))); 203 206 chartArea1.Name = "ChartArea1"; … … 264 267 this.radioButtonGroup.Controls.Add(this.zoomButton); 265 268 this.radioButtonGroup.Controls.Add(this.selectButton); 266 this.radioButtonGroup.Location = new System.Drawing.Point( 3, 704);269 this.radioButtonGroup.Location = new System.Drawing.Point(6, 679); 267 270 this.radioButtonGroup.Name = "radioButtonGroup"; 268 271 this.radioButtonGroup.Size = new System.Drawing.Size(122, 32); … … 275 278 this.colorRunsButton.Enabled = false; 276 279 this.colorRunsButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 277 this.colorRunsButton.Location = new System.Drawing.Point( 131, 713);280 this.colorRunsButton.Location = new System.Drawing.Point(6, 715); 278 281 this.colorRunsButton.Name = "colorRunsButton"; 279 282 this.colorRunsButton.Size = new System.Drawing.Size(21, 21); … … 317 320 this.transparencyTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 318 321 this.transparencyTrackBar.LargeChange = 16; 319 this.transparencyTrackBar.Location = new System.Drawing.Point( 302, 715);322 this.transparencyTrackBar.Location = new System.Drawing.Point(177, 717); 320 323 this.transparencyTrackBar.Maximum = 254; 321 324 this.transparencyTrackBar.Name = "transparencyTrackBar"; … … 331 334 this.hideRunsButton.Enabled = false; 332 335 this.hideRunsButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 333 this.hideRunsButton.Location = new System.Drawing.Point( 172, 713);336 this.hideRunsButton.Location = new System.Drawing.Point(47, 715); 334 337 this.hideRunsButton.Name = "hideRunsButton"; 335 338 this.hideRunsButton.Size = new System.Drawing.Size(43, 21); … … 347 350 this.colorDialogButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 348 351 this.colorDialogButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 349 this.colorDialogButton.Location = new System.Drawing.Point( 152, 713);352 this.colorDialogButton.Location = new System.Drawing.Point(27, 715); 350 353 this.colorDialogButton.Name = "colorDialogButton"; 351 354 this.colorDialogButton.Size = new System.Drawing.Size(14, 21); … … 390 393 this.transparencyLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 391 394 this.transparencyLabel.AutoSize = true; 392 this.transparencyLabel.Location = new System.Drawing.Point( 233, 717);395 this.transparencyLabel.Location = new System.Drawing.Point(108, 719); 393 396 this.transparencyLabel.Name = "transparencyLabel"; 394 397 this.transparencyLabel.Size = new System.Drawing.Size(75, 13); … … 452 455 453 456 private System.Windows.Forms.Label xAxisLabel; 454 privateSystem.Windows.Forms.ComboBox xAxisComboBox;457 internal System.Windows.Forms.ComboBox xAxisComboBox; 455 458 private System.Windows.Forms.Label yAxisLabel; 456 privateSystem.Windows.Forms.ComboBox yAxisComboBox;459 internal System.Windows.Forms.ComboBox yAxisComboBox; 457 460 private System.Windows.Forms.TrackBar yTrackBar; 458 461 private System.Windows.Forms.TrackBar xTrackBar; -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs
r12077 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 93 93 } 94 94 95 public string SelectedXAxis { 96 get { return xAxisValue; } 97 set { 98 if (xAxisComboBox.Items.Contains(value)) { 99 xAxisComboBox.SelectedItem = value; 100 } 101 } 102 } 103 public string SelectedYAxis { 104 get { return yAxisValue; } 105 set { 106 if (yAxisComboBox.Items.Contains(value)) { 107 yAxisComboBox.SelectedItem = value; 108 } 109 } 110 } 111 95 112 protected override void RegisterContentEvents() { 96 113 base.RegisterContentEvents(); … … 227 244 string[] additionalAxisDimension = Enum.GetNames(typeof(AxisDimension)); 228 245 this.xAxisComboBox.Items.AddRange(additionalAxisDimension); 229 this.xAxisComboBox.Items.AddRange(Matrix.ColumnNames.ToArray()); 246 var comparer = new HeuristicLab.Common.NaturalStringComparer(); 247 var sortedColumnNames = Matrix.ColumnNames.ToArray(); 248 sortedColumnNames.StableSort(comparer); 249 this.xAxisComboBox.Items.AddRange(sortedColumnNames); 230 250 this.yAxisComboBox.Items.AddRange(additionalAxisDimension); 231 this.yAxisComboBox.Items.AddRange( Matrix.ColumnNames.ToArray());251 this.yAxisComboBox.Items.AddRange(sortedColumnNames); 232 252 string[] additionalSizeDimension = Enum.GetNames(typeof(SizeDimension)); 233 253 this.sizeComboBox.Items.AddRange(additionalSizeDimension); 234 this.sizeComboBox.Items.AddRange( Matrix.ColumnNames.ToArray());254 this.sizeComboBox.Items.AddRange(sortedColumnNames); 235 255 this.sizeComboBox.SelectedItem = SizeDimension.Constant.ToString(); 236 256 … … 415 435 return GetValue(run, sizeDimension); 416 436 } else { 417 int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName); 418 IItem value = Content.GetValue(run, column Index);437 438 IItem value = Content.GetValue(run, columnName); 419 439 if (value == null) 420 440 return null; … … 431 451 else if (timeSpanValue != null) { 432 452 ret = timeSpanValue.Value.TotalSeconds; 433 } else 453 } else { 454 int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName); 434 455 ret = GetCategoricalValue(columnIndex, value.ToString()); 456 } 435 457 436 458 return ret; … … 602 624 tooltip = run.Name + System.Environment.NewLine; 603 625 604 double? xValue = this.GetValue(run, (string)xAxisComboBox.SelectedItem); 605 double? yValue = this.GetValue(run, (string)yAxisComboBox.SelectedItem); 606 double? sizeValue = this.GetValue(run, (string)sizeComboBox.SelectedItem); 607 608 string xString = xValue == null ? string.Empty : xValue.Value.ToString(); 609 string yString = yValue == null ? string.Empty : yValue.Value.ToString(); 610 string sizeString = sizeValue == null ? string.Empty : sizeValue.Value.ToString(); 611 612 //code to handle TimeSpanValues correct 613 int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count(); 614 int columnIndex = xAxisComboBox.SelectedIndex - axisDimensionCount; 615 if (xValue.HasValue && columnIndex > 0 && Content.GetValue(0, columnIndex) is TimeSpanValue) { 616 TimeSpan time = TimeSpan.FromSeconds(xValue.Value); 617 xString = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.Seconds); 618 } 619 columnIndex = yAxisComboBox.SelectedIndex - axisDimensionCount; 620 if (yValue.HasValue && columnIndex > 0 && Content.GetValue(0, columnIndex) is TimeSpanValue) { 621 TimeSpan time = TimeSpan.FromSeconds(yValue.Value); 622 yString = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.Seconds); 623 } 626 string xString = GetTooltipValue(run, (string)xAxisComboBox.SelectedItem); 627 string yString = GetTooltipValue(run, (string)yAxisComboBox.SelectedItem); 628 string sizeString = GetTooltipValue(run, (string)sizeComboBox.SelectedItem); 624 629 625 630 tooltip += xAxisComboBox.SelectedItem + " : " + xString + Environment.NewLine; … … 628 633 629 634 return tooltip; 635 } 636 637 private string GetTooltipValue(IRun run, string columnName) { 638 if (columnName == SizeDimension.Constant.ToString()) 639 return string.Empty; 640 641 int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName); 642 643 //handle non-numeric values correctly 644 if (categoricalMapping.ContainsKey(columnIndex)) { 645 return Content.GetValue(run, columnName).ToString(); 646 } 647 648 double? value = GetValue(run, columnName); 649 if (!value.HasValue) return string.Empty; 650 651 string valueString = value.Value.ToString(); 652 653 //code to handle TimeSpanValues correctly 654 if (columnIndex > 0 && Content.GetValue(0, columnIndex) is TimeSpanValue) { 655 TimeSpan time = TimeSpan.FromSeconds(value.Value); 656 valueString = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.Seconds); 657 } 658 659 return valueString; 630 660 } 631 661 #endregion … … 726 756 } 727 757 private void hideRunsToolStripMenuItem_Click(object sender, EventArgs e) { 728 //ToList is necessary to prevent lazy evaluation 729 HideRuns(selectedRuns.ToList()); 758 HideRuns(selectedRuns); 730 759 //could not use ClearSelectedRuns as the runs are not visible anymore 731 760 selectedRuns.Clear(); 732 761 } 733 762 private void hideRunsButton_Click(object sender, EventArgs e) { 734 //ToList is necessary to prevent lazy evaluation 735 HideRuns(selectedRuns.ToList()); 763 HideRuns(selectedRuns); 736 764 //could not use ClearSelectedRuns as the runs are not visible anymore 737 765 selectedRuns.Clear(); … … 739 767 740 768 private void HideRuns(IEnumerable<IRun> runs) { 769 Content.UpdateOfRunsInProgress = true; 741 770 visibilityConstraint.Active = false; 742 771 if (!Content.Constraints.Contains(visibilityConstraint)) Content.Constraints.Add(visibilityConstraint); … … 745 774 } 746 775 visibilityConstraint.Active = true; 776 Content.UpdateOfRunsInProgress = false; 747 777 } 748 778 -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs
r13181 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs
r13054 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 25 25 using System.Linq; 26 26 using System.Windows.Forms; 27 using HeuristicLab.Collections;28 27 using HeuristicLab.Core; 29 28 using HeuristicLab.Data.Views; … … 122 121 } 123 122 124 p rotectedoverride void UpdateColumnHeaders() {123 public override void UpdateColumnHeaders() { 125 124 string[] colNames = base.Content.ColumnNames.ToArray(); 126 125 int colCount = colNames.Length; -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.Designer.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs
r13181 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 52 52 } 53 53 54 public ListView ItemsListView { 55 get { return itemsListView; } 56 } 54 private int EmptyImageIndex { get { return 0; } } 55 private int RunImageIndex { get { return 1; } } 57 56 58 57 public RunCollectionView() { 59 58 InitializeComponent(); 60 itemsGroupBox.Text = "Runs"; 59 UpdateGroupBoxText(); 60 61 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Nothing); 62 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Class); 63 61 64 itemListViewItemMapping = new Dictionary<IRun, List<ListViewItem>>(); 62 65 runCollectionModifiersListView.Evaluator = EvaluateModifications; … … 83 86 } 84 87 private void DeregisterItemEvents(IRun item) { 85 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged);86 88 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 87 89 item.PropertyChanged -= Item_PropertyChanged; 88 90 } 89 91 private void RegisterItemEvents(IRun item) { 90 item.ItemImageChanged += new EventHandler(Item_ItemImageChanged);91 92 item.ToStringChanged += new EventHandler(Item_ToStringChanged); 92 93 item.PropertyChanged += Item_PropertyChanged; … … 116 117 itemsListView.Items.Clear(); 117 118 itemListViewItemMapping.Clear(); 118 RebuildImageList();119 119 viewHost.Content = null; 120 121 UpdateGroupBoxText(); 120 122 121 123 if (Content != null) { … … 129 131 runCollectionModifiersListView.Content = RunCollection.Modifiers; 130 132 } 133 134 ListViewItem[] items = new ListViewItem[Content.Count]; 135 int count = 0; 131 136 foreach (IRun item in Content) { 132 137 ListViewItem listViewItem = CreateListViewItem(item); 133 AddListViewItem(listViewItem); 138 134 139 if ((selectedName != null) && item.Name.Equals(selectedName)) 135 140 listViewItem.Selected = true; 136 } 141 items[count] = listViewItem; 142 count++; 143 } 144 itemsListView.Items.AddRange(items); 137 145 AdjustListViewColumnSizes(); 138 146 } else { … … 166 174 } 167 175 168 private ListViewItem CreateListViewItem(IRun item) { 176 private static readonly string tooltipText = ItemAttribute.GetName(typeof(Run)) + ": " + 177 ItemAttribute.GetDescription(typeof(Run)); 178 private ListViewItem CreateListViewItem(IRun run) { 169 179 ListViewItem listViewItem = new ListViewItem(); 170 if ( item== null) {180 if (run == null) { 171 181 listViewItem.Text = "null"; 172 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Nothing); 173 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 182 listViewItem.ImageIndex = EmptyImageIndex; 183 return listViewItem; 184 } 185 186 listViewItem.Text = run.Name; 187 listViewItem.ToolTipText = tooltipText; 188 listViewItem.ImageIndex = RunImageIndex; 189 listViewItem.Tag = run; 190 191 if (run.Visible) { 192 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 193 listViewItem.ForeColor = run.Color; 174 194 } else { 175 listViewItem.Text = item.ToString(); 176 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 177 itemsListView.SmallImageList.Images.Add(item.ItemImage); 178 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 179 listViewItem.Tag = item; 180 181 if (item.Visible) { 182 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 183 listViewItem.ForeColor = item.Color; 184 } else { 185 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic); 186 listViewItem.ForeColor = Color.LightGray; 187 } 188 } 195 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic); 196 listViewItem.ForeColor = Color.LightGray; 197 } 198 199 if (!itemListViewItemMapping.ContainsKey(run)) { 200 itemListViewItemMapping.Add(run, new List<ListViewItem>()); 201 RegisterItemEvents(run); 202 } 203 itemListViewItemMapping[run].Add(listViewItem); 204 189 205 return listViewItem; 190 206 } 191 private void AddListViewItem(ListViewItem listViewItem) { 192 if (listViewItem == null) throw new ArgumentNullException(); 193 itemsListView.Items.Add(listViewItem); 194 IRun run = listViewItem.Tag as IRun; 195 if (run != null) { 196 if (!itemListViewItemMapping.ContainsKey(run)) { 197 itemListViewItemMapping.Add(run, new List<ListViewItem>()); 198 RegisterItemEvents(run); 199 } 200 itemListViewItemMapping[run].Add(listViewItem); 201 } 202 } 207 203 208 private void RemoveListViewItem(ListViewItem listViewItem) { 204 209 if (listViewItem == null) throw new ArgumentNullException(); … … 213 218 listViewItem.Remove(); 214 219 } 215 private void UpdateListViewItemImage(ListViewItem listViewItem) { 216 if (listViewItem == null) throw new ArgumentNullException(); 217 IRun item = listViewItem.Tag as IRun; 218 int i = listViewItem.ImageIndex; 219 itemsListView.SmallImageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage; 220 listViewItem.ImageIndex = -1; 221 listViewItem.ImageIndex = i; 222 } 220 223 221 private void UpdateListViewItemText(ListViewItem listViewItem) { 224 222 if (listViewItem == null) throw new ArgumentNullException(); … … 239 237 return listViewItems == null ? Enumerable.Empty<ListViewItem>() : listViewItems; 240 238 } 239 } 240 241 private void UpdateGroupBoxText() { 242 if (Content == null || Content.Count == 0) itemsGroupBox.Text = "Runs"; 243 else itemsGroupBox.Text = @"Runs (" + Content.Count + @")"; 241 244 } 242 245 … … 268 271 } 269 272 } 273 } else if (e.KeyData == (Keys.A | Keys.Control)) { 274 try { 275 itemsListView.BeginUpdate(); 276 foreach (ListViewItem item in itemsListView.Items) 277 item.Selected = true; 278 } finally { itemsListView.EndUpdate(); } 270 279 } 271 280 } … … 393 402 RunCollection.UpdateOfRunsInProgress = true; 394 403 RunCollection.Modify(); 395 } finally { 404 } 405 finally { 396 406 ReadOnly = false; 397 407 RunCollection.UpdateOfRunsInProgress = false; … … 406 416 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); 407 417 else { 408 foreach (IRun item in e.Items) 409 AddListViewItem(CreateListViewItem(item)); 410 418 var items = e.Items.Select(CreateListViewItem).ToArray(); 419 itemsListView.Items.AddRange(items); 411 420 AdjustListViewColumnSizes(); 412 421 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 413 422 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 414 423 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 424 UpdateGroupBoxText(); 415 425 } 416 426 } … … 425 435 if (listViewItem != null) RemoveListViewItem(listViewItem); 426 436 } 427 RebuildImageList();428 437 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 429 438 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 430 439 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 440 UpdateGroupBoxText(); 431 441 } 432 442 } … … 441 451 if (listViewItem != null) RemoveListViewItem(listViewItem); 442 452 } 443 RebuildImageList(); 444 foreach (IRun item in e.Items) 445 AddListViewItem(CreateListViewItem(item)); 453 var items = e.Items.Select(CreateListViewItem).ToArray(); 454 itemsListView.Items.AddRange(items); 446 455 447 456 AdjustListViewColumnSizes(); … … 449 458 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 450 459 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 460 UpdateGroupBoxText(); 451 461 } 452 462 } … … 456 466 suppressUpdates = RunCollection.UpdateOfRunsInProgress; 457 467 if (!suppressUpdates) { 458 foreach (IRun item in Content) { 459 //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection 460 ListViewItem listViewItem = GetListViewItemsForItem(item).FirstOrDefault(); 461 if (listViewItem != null) RemoveListViewItem(listViewItem); 468 foreach (IRun run in Content) { 469 DeregisterItemEvents(run); 462 470 } 463 RebuildImageList(); 464 foreach (IRun item in Content) 465 AddListViewItem(CreateListViewItem(item)); 471 itemsListView.Items.Clear(); 472 itemListViewItemMapping.Clear(); 473 var items = Content.Select(CreateListViewItem).ToArray(); 474 itemsListView.Items.AddRange(items); 466 475 467 476 AdjustListViewColumnSizes(); … … 469 478 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 470 479 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 480 UpdateGroupBoxText(); 471 481 } 472 482 } … … 475 485 476 486 #region Item Events 477 private void Item_ItemImageChanged(object sender, EventArgs e) {478 if (suppressUpdates) return;479 if (InvokeRequired)480 Invoke(new EventHandler(Item_ItemImageChanged), sender, e);481 else {482 IRun item = (IRun)sender;483 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item))484 UpdateListViewItemImage(listViewItem);485 }486 }487 487 private void Item_ToStringChanged(object sender, EventArgs e) { 488 488 if (suppressUpdates) return; … … 528 528 } 529 529 } 530 private void RebuildImageList() {531 itemsListView.SmallImageList.Images.Clear();532 foreach (ListViewItem listViewItem in itemsListView.Items) {533 IRun item = listViewItem.Tag as IRun;534 itemsListView.SmallImageList.Images.Add(item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage);535 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;536 }537 }538 530 #endregion 539 531 }
Note: See TracChangeset
for help on using the changeset viewer.