- Timestamp:
- 07/11/15 13:37:32 (9 years ago)
- Location:
- stable
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12077,12112,12116-12117,12131,12173,12458,12599,12613,12631,12672,12684,12690,12692
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs
r12009 r12725 122 122 if (InvokeRequired) 123 123 Invoke(new EventHandler(Content_Reset), sender, e); 124 else {124 else if (!suppressUpdates) { 125 125 UpdateDataPoints(); 126 126 UpdateAxisLabels(); … … 376 376 Axis yAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisY; 377 377 int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count(); 378 //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 379 379 var xSAxisSelectedIndex = xAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(xAxisValue); 380 380 var ySAxisSelectedIndex = yAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(yAxisValue); -
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs
r12009 r12725 262 262 263 263 private void Content_Reset(object sender, EventArgs e) { 264 if (suppressUpdates) return; 264 265 if (InvokeRequired) 265 266 Invoke(new EventHandler(Content_Reset), sender, e); -
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs
r12009 r12725 24 24 using System.ComponentModel; 25 25 using System.Linq; 26 using System.Windows.Forms;27 26 using HeuristicLab.Analysis; 28 27 using HeuristicLab.Collections; … … 41 40 } 42 41 43 private int rowNumber = 0;42 private int rowNumber; 44 43 private bool suppressUpdates; 45 44 private readonly Dictionary<IRun, IEnumerable<DataRow>> runMapping; … … 60 59 protected override void RegisterContentEvents() { 61 60 base.RegisterContentEvents(); 62 Content.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);63 Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);64 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);65 Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);66 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; 67 66 } 68 67 protected override void DeregisterContentEvents() { 69 Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);70 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);71 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);72 Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);73 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; 74 73 base.DeregisterContentEvents(); 75 74 } 76 75 77 76 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 77 if (suppressUpdates) return; 78 78 if (InvokeRequired) { 79 79 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); 80 80 return; 81 81 } 82 UpdateDataTableComboBox(); 83 UpdateDataRowComboBox(); 82 84 AddRuns(e.Items); 83 85 } 84 86 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 87 if (suppressUpdates) return; 85 88 if (InvokeRequired) { 86 89 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e); 87 90 return; 88 91 } 92 UpdateDataTableComboBox(); 93 UpdateDataRowComboBox(); 89 94 RemoveRuns(e.Items); 90 95 } 91 96 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 97 if (suppressUpdates) return; 92 98 if (InvokeRequired) { 93 99 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e); 94 100 return; 95 101 } 102 UpdateDataTableComboBox(); 103 UpdateDataRowComboBox(); 96 104 RemoveRuns(e.OldItems); 97 105 AddRuns(e.Items); … … 108 116 } 109 117 suppressUpdates = Content.UpdateOfRunsInProgress; 110 if (!suppressUpdates) UpdateRuns(Content); 118 if (!suppressUpdates) { 119 UpdateDataTableComboBox(); 120 UpdateDataRowComboBox(); 121 UpdateRuns(Content); 122 } 111 123 } 112 124 … … 124 136 var run = (IRun)sender; 125 137 if (e.PropertyName == "Color" || e.PropertyName == "Visible") 126 UpdateRuns(new IRun[] { run });138 UpdateRuns(new[] { run }); 127 139 } 128 140 } … … 168 180 169 181 private void UpdateRuns(IEnumerable<IRun> runs) { 170 if (suppressUpdates) return;171 182 foreach (var run in runs) { 172 183 //update color 173 foreach (var dataRow in runMapping[run]) { 174 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 } 175 191 } 176 //update visibility - remove and add all rows to keep the same order as before177 combinedDataTable.Rows.Clear();178 combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value));179 }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)); 180 196 } 181 197 182 198 private IEnumerable<DataRow> ExtractDataRowsFromRun(IRun run) { 183 199 var resultName = (string)dataTableComboBox.SelectedItem; 200 if (string.IsNullOrEmpty(resultName)) yield break; 201 184 202 var rowName = (string)dataRowComboBox.SelectedItem; 185 203 if (!run.Results.ContainsKey(resultName)) yield break; … … 199 217 200 218 private void UpdateDataTableComboBox() { 219 string selectedItem = (string)dataTableComboBox.SelectedItem; 220 201 221 dataTableComboBox.Items.Clear(); 202 222 var dataTables = (from run in Content … … 206 226 207 227 dataTableComboBox.Items.AddRange(dataTables); 208 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 } 209 233 } 210 234 … … 214 238 215 239 private void UpdateDataRowComboBox() { 240 string selectedItem = (string)dataRowComboBox.SelectedItem; 241 216 242 dataRowComboBox.Items.Clear(); 217 243 var resultName = (string)dataTableComboBox.SelectedItem; 244 if (resultName == null) return; 245 218 246 var dataTables = from run in Content 219 247 where run.Results.ContainsKey(resultName) … … 225 253 dataRowComboBox.Items.AddRange(rowNames); 226 254 dataRowComboBox.Items.Add(AllDataRows); 227 if (dataRowComboBox.Items.Count > 0) dataRowComboBox.SelectedItem = dataRowComboBox.Items[0]; 228 } 229 230 private void dataTableComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 231 UpdateDataRowComboBox(); 232 } 233 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; 234 267 RebuildCombinedDataTable(); 235 268 } -
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs
r12009 r12725 53 53 base.OnContentChanged(); 54 54 if (Content != null) { 55 runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();56 55 UpdateRowAttributes(); 57 56 } … … 117 116 } 118 117 118 protected override void UpdateData() { 119 if (suppressUpdates) return; 120 base.UpdateData(); 121 } 122 119 123 protected override void UpdateColumnHeaders() { 120 124 HashSet<string> visibleColumnNames = new HashSet<string>(dataGridView.Columns.OfType<DataGridViewColumn>() … … 145 149 else { 146 150 suppressUpdates = Content.UpdateOfRunsInProgress; 147 if (!suppressUpdates) UpdateRowAttributes(); 151 if (!suppressUpdates) { 152 UpdateData(); 153 UpdateRowAttributes(); 154 } 148 155 } 149 156 } … … 171 178 protected override void ClearSorting() { 172 179 base.ClearSorting(); 173 runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();174 180 UpdateRowAttributes(); 175 181 } … … 190 196 i++; 191 197 } 192 UpdateRowAttributes( );198 UpdateRowAttributes(rebuild: false); 193 199 return newSortedIndex; 194 200 } 195 201 196 private void UpdateRowAttributes() { 202 private void UpdateRowAttributes(bool rebuild = true) { 203 if (rebuild) runToRowMapping = Enumerable.Range(0, Content.Count).ToArray(); 197 204 int runIndex = 0; 198 205 foreach (IRun run in Content) { -
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs
r12009 r12725 41 41 private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping; 42 42 private bool validDragOperation; 43 private bool suppressUpdates; 43 44 44 45 public new IItemCollection<IRun> Content { … … 66 67 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 67 68 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 69 if (RunCollection != null) 70 RunCollection.UpdateOfRunsInProgressChanged -= new EventHandler(RunCollection_UpdateOfRunsInProgressChanged); 68 71 foreach (IRun run in itemListViewItemMapping.Keys) { 69 72 DeregisterItemEvents(run); … … 76 79 Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 77 80 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 81 if (RunCollection != null) 82 RunCollection.UpdateOfRunsInProgressChanged += new EventHandler(RunCollection_UpdateOfRunsInProgressChanged); 78 83 } 79 84 private void DeregisterItemEvents(IRun item) { … … 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); … … 463 494 } 464 495 private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e) { 496 if (suppressUpdates) return; 465 497 if (InvokeRequired) 466 this.Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e);498 Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e); 467 499 else { 468 500 IRun run = (IRun)sender;
Note: See TracChangeset
for help on using the changeset viewer.