Changeset 12694 for branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews
- Timestamp:
- 07/09/15 13:07:30 (9 years ago)
- Location:
- branches/HeuristicLab.Problems.Orienteering
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/HLScript/HeuristicLab.Optimization.Views merged eligible /stable/HeuristicLab.Optimization.Views merged eligible /trunk/sources/HeuristicLab.Optimization.Views merged eligible /branches/1721-RandomForestPersistence/HeuristicLab.Optimization.Views 10321-10322 /branches/Algorithms.GradientDescent/HeuristicLab.Optimization.Views 5516-5520 /branches/Benchmarking/sources/HeuristicLab.Optimization.Views 6917-7005 /branches/CloningRefactoring/HeuristicLab.Optimization.Views 4656-4721 /branches/CodeEditor/HeuristicLab.Optimization.Views 11700-11806 /branches/DataAnalysis Refactoring/HeuristicLab.Optimization.Views 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Optimization.Views 5815-6180 /branches/DataAnalysis/HeuristicLab.Optimization.Views 4458-4459,4462,4464 /branches/DataPreprocessing/HeuristicLab.Optimization.Views 10085-11101 /branches/GP.Grammar.Editor/HeuristicLab.Optimization.Views 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Optimization.Views 5060 /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Optimization.Views 11570-12508 /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Optimization.Views 6123-9799 /branches/LogResidualEvaluator/HeuristicLab.Optimization.Views 10202-10483 /branches/NET40/sources/HeuristicLab.Optimization.Views 5138-5162 /branches/NSGA-II Changes/HeuristicLab.Optimization.Views 12033-12122 /branches/ParallelEngine/HeuristicLab.Optimization.Views 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Optimization.Views 7568-7810 /branches/QAPAlgorithms/HeuristicLab.Optimization.Views 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Optimization.Views 6828 /branches/RuntimeOptimizer/HeuristicLab.Optimization.Views 8943-9078 /branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization.Views 7787-8333 /branches/SlaveShutdown/HeuristicLab.Optimization.Views 8944-8956 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Optimization.Views 10204-10479 /branches/SuccessProgressAnalysis/HeuristicLab.Optimization.Views 5370-5682 /branches/TimeLimitRunOptimizer/HeuristicLab.Optimization.Views 9438-12626 /branches/Trunk/HeuristicLab.Optimization.Views 6829-6865 /branches/UnloadJobs/HeuristicLab.Optimization.Views 9168-9215 /branches/VNS/HeuristicLab.Optimization.Views 5594-5752 /branches/histogram/HeuristicLab.Optimization.Views 5959-6341
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.Designer.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel; 24 25 using System.Linq; 25 26 using System.Windows.Forms; … … 92 93 protected virtual void RegisterRunEvents(IEnumerable<IRun> runs) { 93 94 foreach (IRun run in runs) 94 run. Changed += new EventHandler(run_Changed);95 run.PropertyChanged += run_PropertyChanged; 95 96 } 96 97 protected virtual void DeregisterRunEvents(IEnumerable<IRun> runs) { 97 98 foreach (IRun run in runs) 98 run. Changed -= new EventHandler(run_Changed);99 run.PropertyChanged -= run_PropertyChanged; 99 100 } 100 101 … … 121 122 if (InvokeRequired) 122 123 Invoke(new EventHandler(Content_Reset), sender, e); 123 else {124 else if (!suppressUpdates) { 124 125 UpdateDataPoints(); 125 126 UpdateAxisLabels(); … … 133 134 } 134 135 } 135 private void run_ Changed(object sender,EventArgs e) {136 private void run_PropertyChanged(object sender, PropertyChangedEventArgs e) { 136 137 if (InvokeRequired) 137 this.Invoke( new EventHandler(run_Changed), sender, e);138 this.Invoke((Action<object, PropertyChangedEventArgs>)run_PropertyChanged, sender, e); 138 139 else if (!suppressUpdates) { 139 UpdateDataPoints(); 140 if (e.PropertyName == "Visible") 141 UpdateDataPoints(); 140 142 } 141 143 } … … 374 376 Axis yAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisY; 375 377 int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count(); 376 //mkommend: combobox.SelectedIndex could not be used as this changes during ho overing over possible values378 //mkommend: combobox.SelectedIndex could not be used as this changes during hovering over possible values 377 379 var xSAxisSelectedIndex = xAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(xAxisValue); 378 380 var ySAxisSelectedIndex = yAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(yAxisValue); … … 451 453 } 452 454 455 public void SetXAxis(string axisName) { 456 xAxisComboBox.SelectedItem = axisName; 457 } 458 459 public void SetYAxis(string axisName) { 460 yAxisComboBox.SelectedItem = axisName; 461 } 453 462 } 454 463 } -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.Designer.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel; 24 25 using System.Drawing; 25 26 using System.Linq; … … 116 117 protected virtual void RegisterRunEvents(IEnumerable<IRun> runs) { 117 118 foreach (IRun run in runs) 118 run. Changed += new EventHandler(run_Changed);119 run.PropertyChanged += run_PropertyChanged; 119 120 } 120 121 protected virtual void DeregisterRunEvents(IEnumerable<IRun> runs) { 121 122 foreach (IRun run in runs) 122 run. Changed -= new EventHandler(run_Changed);123 run.PropertyChanged -= run_PropertyChanged; 123 124 } 124 125 … … 133 134 RegisterRunEvents(e.Items); 134 135 } 135 private void run_ Changed(object sender,EventArgs e) {136 private void run_PropertyChanged(object sender, PropertyChangedEventArgs e) { 136 137 if (suppressUpdates) return; 137 138 if (InvokeRequired) 138 this.Invoke( new EventHandler(run_Changed), sender, e);139 this.Invoke((Action<object, PropertyChangedEventArgs>)run_PropertyChanged, sender, e); 139 140 else { 140 IRun run = (IRun)sender; 141 UpdateRun(run); 142 UpdateCursorInterval(); 143 chart.ChartAreas[0].RecalculateAxesScale(); 144 UpdateAxisLabels(); 141 if (e.PropertyName == "Color" || e.PropertyName == "Visible") { 142 IRun run = (IRun)sender; 143 UpdateRun(run); 144 UpdateCursorInterval(); 145 chart.ChartAreas[0].RecalculateAxesScale(); 146 UpdateAxisLabels(); 147 } 145 148 } 146 149 } … … 259 262 260 263 private void Content_Reset(object sender, EventArgs e) { 264 if (suppressUpdates) return; 261 265 if (InvokeRequired) 262 266 Invoke(new EventHandler(Content_Reset), sender, e); … … 670 674 if (xAxisValue != null) 671 675 xAxis.Title = xAxisValue; 672 if (yAxisValue != null)673 yAxis.Title = yAxisValue;676 if (yAxisValue != null) 677 yAxis.Title = yAxisValue; 674 678 } 675 679 -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.Designer.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel; 24 25 using System.Linq; 25 using System.Windows.Forms;26 26 using HeuristicLab.Analysis; 27 27 using HeuristicLab.Collections; … … 40 40 } 41 41 42 private int rowNumber = 0;42 private int rowNumber; 43 43 private bool suppressUpdates; 44 44 private readonly Dictionary<IRun, IEnumerable<DataRow>> runMapping; … … 59 59 protected override void RegisterContentEvents() { 60 60 base.RegisterContentEvents(); 61 Content.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);62 Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);63 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);64 Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);65 Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged);61 Content.ItemsAdded += Content_ItemsAdded; 62 Content.ItemsRemoved += Content_ItemsRemoved; 63 Content.CollectionReset += Content_CollectionReset; 64 Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged; 65 Content.OptimizerNameChanged += Content_AlgorithmNameChanged; 66 66 } 67 67 protected override void DeregisterContentEvents() { 68 Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);69 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);70 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);71 Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);72 Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged);68 Content.ItemsAdded -= Content_ItemsAdded; 69 Content.ItemsRemoved -= Content_ItemsRemoved; 70 Content.CollectionReset -= Content_CollectionReset; 71 Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged; 72 Content.OptimizerNameChanged -= Content_AlgorithmNameChanged; 73 73 base.DeregisterContentEvents(); 74 74 } 75 75 76 76 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 77 if (suppressUpdates) return; 77 78 if (InvokeRequired) { 78 79 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); 79 80 return; 80 81 } 82 UpdateDataTableComboBox(); 83 UpdateDataRowComboBox(); 81 84 AddRuns(e.Items); 82 85 } 83 86 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 87 if (suppressUpdates) return; 84 88 if (InvokeRequired) { 85 89 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e); 86 90 return; 87 91 } 92 UpdateDataTableComboBox(); 93 UpdateDataRowComboBox(); 88 94 RemoveRuns(e.Items); 89 95 } 90 96 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 97 if (suppressUpdates) return; 91 98 if (InvokeRequired) { 92 99 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e); 93 100 return; 94 101 } 102 UpdateDataTableComboBox(); 103 UpdateDataRowComboBox(); 95 104 RemoveRuns(e.OldItems); 96 105 AddRuns(e.Items); … … 107 116 } 108 117 suppressUpdates = Content.UpdateOfRunsInProgress; 109 if (!suppressUpdates) UpdateRuns(Content); 118 if (!suppressUpdates) { 119 UpdateDataTableComboBox(); 120 UpdateDataRowComboBox(); 121 UpdateRuns(Content); 122 } 110 123 } 111 124 112 125 private void RegisterRunEvents(IRun run) { 113 run. Changed += new System.EventHandler(run_Changed);126 run.PropertyChanged += run_PropertyChanged; 114 127 } 115 128 private void DeregisterRunEvents(IRun run) { 116 run.Changed -= new System.EventHandler(run_Changed); 117 } 118 private void run_Changed(object sender, EventArgs e) { 119 if (suppressUpdates) return; 120 var run = (IRun)sender; 121 UpdateRuns(new IRun[] { run }); 129 run.PropertyChanged -= run_PropertyChanged; 130 } 131 private void run_PropertyChanged(object sender, PropertyChangedEventArgs e) { 132 if (suppressUpdates) return; 133 if (InvokeRequired) { 134 Invoke((Action<object, PropertyChangedEventArgs>)run_PropertyChanged, sender, e); 135 } else { 136 var run = (IRun)sender; 137 if (e.PropertyName == "Color" || e.PropertyName == "Visible") 138 UpdateRuns(new[] { run }); 139 } 122 140 } 123 141 #endregion … … 162 180 163 181 private void UpdateRuns(IEnumerable<IRun> runs) { 164 if (suppressUpdates) return;165 182 foreach (var run in runs) { 166 183 //update color 167 foreach (var dataRow in runMapping[run]) { 168 dataRow.VisualProperties.Color = run.Color; 184 if (!runMapping.ContainsKey(run)) { 185 runMapping[run] = ExtractDataRowsFromRun(run).ToList(); 186 RegisterRunEvents(run); 187 } else { 188 foreach (var dataRow in runMapping[run]) { 189 dataRow.VisualProperties.Color = run.Color; 190 } 169 191 } 170 //update visibility - remove and add all rows to keep the same order as before171 combinedDataTable.Rows.Clear();172 combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value));173 }192 } 193 //update visibility - remove and add all rows to keep the same order as before 194 combinedDataTable.Rows.Clear(); 195 combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value)); 174 196 } 175 197 176 198 private IEnumerable<DataRow> ExtractDataRowsFromRun(IRun run) { 177 199 var resultName = (string)dataTableComboBox.SelectedItem; 200 if (string.IsNullOrEmpty(resultName)) yield break; 201 178 202 var rowName = (string)dataRowComboBox.SelectedItem; 179 203 if (!run.Results.ContainsKey(resultName)) yield break; … … 193 217 194 218 private void UpdateDataTableComboBox() { 219 string selectedItem = (string)dataTableComboBox.SelectedItem; 220 195 221 dataTableComboBox.Items.Clear(); 196 222 var dataTables = (from run in Content … … 200 226 201 227 dataTableComboBox.Items.AddRange(dataTables); 202 if (dataTableComboBox.Items.Count > 0) dataTableComboBox.SelectedItem = dataTableComboBox.Items[0]; 228 if (selectedItem != null && dataTableComboBox.Items.Contains(selectedItem)) { 229 dataTableComboBox.SelectedItem = selectedItem; 230 } else if (dataTableComboBox.Items.Count > 0) { 231 dataTableComboBox.SelectedItem = dataTableComboBox.Items[0]; 232 } 203 233 } 204 234 … … 208 238 209 239 private void UpdateDataRowComboBox() { 240 string selectedItem = (string)dataRowComboBox.SelectedItem; 241 210 242 dataRowComboBox.Items.Clear(); 211 243 var resultName = (string)dataTableComboBox.SelectedItem; 244 if (resultName == null) return; 245 212 246 var dataTables = from run in Content 213 247 where run.Results.ContainsKey(resultName) … … 219 253 dataRowComboBox.Items.AddRange(rowNames); 220 254 dataRowComboBox.Items.Add(AllDataRows); 221 if (dataRowComboBox.Items.Count > 0) dataRowComboBox.SelectedItem = dataRowComboBox.Items[0]; 222 } 223 224 private void dataTableComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 225 UpdateDataRowComboBox(); 226 } 227 private void dataRowComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 255 if (selectedItem != null && dataRowComboBox.Items.Contains(selectedItem)) { 256 dataRowComboBox.SelectedItem = selectedItem; 257 } else if (dataRowComboBox.Items.Count > 0) { 258 dataRowComboBox.SelectedItem = dataRowComboBox.Items[0]; 259 } 260 } 261 262 private void dataTableComboBox_SelectedIndexChanged(object sender, EventArgs e) { 263 UpdateDataRowComboBox(); 264 } 265 private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) { 266 if (suppressUpdates) return; 228 267 RebuildCombinedDataTable(); 229 268 } -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.Designer.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel; 24 25 using System.Linq; 25 26 using System.Windows.Forms; … … 52 53 base.OnContentChanged(); 53 54 if (Content != null) { 54 runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();55 55 UpdateRowAttributes(); 56 56 } … … 70 70 private void RegisterRunEvents(IEnumerable<IRun> runs) { 71 71 foreach (IRun run in runs) 72 run. Changed += new EventHandler(run_Changed);72 run.PropertyChanged += run_PropertyChanged; 73 73 } 74 74 protected override void DeregisterContentEvents() { … … 83 83 private void DeregisterRunEvents(IEnumerable<IRun> runs) { 84 84 foreach (IRun run in runs) 85 run. Changed -= new EventHandler(run_Changed);85 run.PropertyChanged -= run_PropertyChanged; 86 86 } 87 87 private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { … … 100 100 else UpdateCaption(); 101 101 } 102 private void run_ Changed(object sender,EventArgs e) {102 private void run_PropertyChanged(object sender, PropertyChangedEventArgs e) { 103 103 if (suppressUpdates) return; 104 104 if (InvokeRequired) 105 this.Invoke( new EventHandler(run_Changed), sender, e);105 this.Invoke((Action<object, PropertyChangedEventArgs>)run_PropertyChanged, sender, e); 106 106 else { 107 107 IRun run = (IRun)sender; 108 UpdateRun(run); 108 if (e.PropertyName == "Color" || e.PropertyName == "Visible") 109 UpdateRun(run); 109 110 } 110 111 } … … 113 114 private void UpdateCaption() { 114 115 Caption = Content != null ? Content.OptimizerName + " Table" : ViewAttribute.GetViewName(GetType()); 116 } 117 118 protected override void UpdateData() { 119 if (suppressUpdates) return; 120 base.UpdateData(); 115 121 } 116 122 … … 143 149 else { 144 150 suppressUpdates = Content.UpdateOfRunsInProgress; 145 if (!suppressUpdates) UpdateRowAttributes(); 151 if (!suppressUpdates) { 152 UpdateData(); 153 UpdateRowAttributes(); 154 } 146 155 } 147 156 } … … 169 178 protected override void ClearSorting() { 170 179 base.ClearSorting(); 171 runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();172 180 UpdateRowAttributes(); 173 181 } … … 188 196 i++; 189 197 } 190 UpdateRowAttributes( );198 UpdateRowAttributes(rebuild: false); 191 199 return newSortedIndex; 192 200 } 193 201 194 private void UpdateRowAttributes() { 202 private void UpdateRowAttributes(bool rebuild = true) { 203 if (rebuild) runToRowMapping = Enumerable.Range(0, Content.Count).ToArray(); 195 204 int runIndex = 0; 196 205 foreach (IRun run in Content) { -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.Designer.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.ComponentModel; 25 26 using System.Drawing; 26 27 using System.Linq; … … 40 41 private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping; 41 42 private bool validDragOperation; 43 private bool suppressUpdates; 42 44 43 45 public new IItemCollection<IRun> Content { … … 65 67 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 66 68 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 69 if (RunCollection != null) 70 RunCollection.UpdateOfRunsInProgressChanged -= new EventHandler(RunCollection_UpdateOfRunsInProgressChanged); 67 71 foreach (IRun run in itemListViewItemMapping.Keys) { 68 72 DeregisterItemEvents(run); … … 75 79 Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 76 80 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 81 if (RunCollection != null) 82 RunCollection.UpdateOfRunsInProgressChanged += new EventHandler(RunCollection_UpdateOfRunsInProgressChanged); 77 83 } 78 84 private void DeregisterItemEvents(IRun item) { 79 85 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 80 86 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 81 item. Changed -= new EventHandler(Item_Changed);87 item.PropertyChanged -= Item_PropertyChanged; 82 88 } 83 89 private void RegisterItemEvents(IRun item) { 84 90 item.ItemImageChanged += new EventHandler(Item_ItemImageChanged); 85 91 item.ToStringChanged += new EventHandler(Item_ToStringChanged); 86 item. Changed += new EventHandler(Item_Changed);92 item.PropertyChanged += Item_PropertyChanged; 87 93 } 88 94 … … 385 391 try { 386 392 RunCollection.Modify(); 387 } 388 finally { 393 } finally { 389 394 ReadOnly = false; 390 395 } … … 394 399 #region Content Events 395 400 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 401 if (suppressUpdates) return; 396 402 if (InvokeRequired) 397 403 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); … … 407 413 } 408 414 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 415 if (suppressUpdates) return; 409 416 if (InvokeRequired) 410 417 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e); … … 422 429 } 423 430 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 431 if (suppressUpdates) return; 424 432 if (InvokeRequired) 425 433 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e); … … 440 448 } 441 449 } 450 private void RunCollection_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 451 if (InvokeRequired) Invoke((Action<object, EventArgs>)RunCollection_UpdateOfRunsInProgressChanged, sender, e); 452 else { 453 suppressUpdates = RunCollection.UpdateOfRunsInProgress; 454 if (!suppressUpdates) { 455 foreach (IRun item in Content) { 456 //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection 457 ListViewItem listViewItem = GetListViewItemsForItem(item).FirstOrDefault(); 458 if (listViewItem != null) RemoveListViewItem(listViewItem); 459 } 460 RebuildImageList(); 461 foreach (IRun item in Content) 462 AddListViewItem(CreateListViewItem(item)); 463 464 AdjustListViewColumnSizes(); 465 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 466 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 467 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 468 } 469 } 470 } 442 471 #endregion 443 472 444 473 #region Item Events 445 474 private void Item_ItemImageChanged(object sender, EventArgs e) { 475 if (suppressUpdates) return; 446 476 if (InvokeRequired) 447 477 Invoke(new EventHandler(Item_ItemImageChanged), sender, e); … … 453 483 } 454 484 private void Item_ToStringChanged(object sender, EventArgs e) { 485 if (suppressUpdates) return; 455 486 if (InvokeRequired) 456 487 Invoke(new EventHandler(Item_ToStringChanged), sender, e); … … 462 493 } 463 494 } 464 private void Item_Changed(object sender, EventArgs e) { 495 private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e) { 496 if (suppressUpdates) return; 465 497 if (InvokeRequired) 466 this.Invoke(new EventHandler(Item_Changed), sender, e);498 Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e); 467 499 else { 468 500 IRun run = (IRun)sender; 469 UpdateRun(run); 501 if (e.PropertyName == "Color" || e.PropertyName == "Visible") 502 UpdateRun(run); 470 503 } 471 504 }
Note: See TracChangeset
for help on using the changeset viewer.