- Timestamp:
- 11/21/10 18:19:39 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionTabularView.cs
r4819 r4883 24 24 using System.Linq; 25 25 using System.Windows.Forms; 26 using HeuristicLab.Co re;26 using HeuristicLab.Common; 27 27 using HeuristicLab.Data.Views; 28 28 using HeuristicLab.MainForm; 29 using HeuristicLab.Core; 29 30 30 31 namespace HeuristicLab.Optimization.Views { … … 33 34 public sealed partial class RunCollectionTabularView : StringConvertibleMatrixView { 34 35 private int[] runToRowMapping; 36 private bool suppressUpdates = false; 35 37 public RunCollectionTabularView() { 36 38 InitializeComponent(); … … 62 64 Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 63 65 Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 66 Content.UpdateOfRunsInProgress += new EventHandler<EventArgs<bool>>(Content_UpdateOfRunsInProgress); 64 67 RegisterRunEvents(Content); 65 68 } … … 73 76 Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 74 77 Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 78 Content.UpdateOfRunsInProgress -= new EventHandler<EventArgs<bool>>(Content_UpdateOfRunsInProgress); 75 79 DeregisterRunEvents(Content); 76 80 } … … 113 117 114 118 private void UpdateRun(IRun run) { 115 int runIndex = GetIndexOfRun(run); 116 int rowIndex = runToRowMapping[runIndex]; 117 this.dataGridView.Rows[rowIndex].Visible = run.Visible; 118 this.dataGridView.Rows[rowIndex].DefaultCellStyle.ForeColor = run.Color; 119 foreach (int runIndex in GetIndexOfRun(run)) { 120 int rowIndex = runToRowMapping[runIndex]; 121 this.dataGridView.Rows[rowIndex].Visible = run.Visible; 122 this.dataGridView.Rows[rowIndex].DefaultCellStyle.ForeColor = run.Color; 123 } 119 124 this.UpdateRowHeaders(); 120 125 } 121 126 122 private int GetIndexOfRun(IRun run) { 127 128 private void Content_UpdateOfRunsInProgress(object sender, Common.EventArgs<bool> e) { 129 if (InvokeRequired) 130 Invoke(new EventHandler<EventArgs<bool>>(Content_UpdateOfRunsInProgress), sender, e); 131 else { 132 suppressUpdates = e.Value; 133 if (!suppressUpdates) UpdateRowAttributes(); 134 } 135 } 136 137 private IEnumerable<int> GetIndexOfRun(IRun run) { 123 138 int i = 0; 124 139 foreach (IRun actualRun in Content) { 125 140 if (actualRun == run) 126 return i;141 yield return i; 127 142 i++; 128 143 } 129 throw new ArgumentException("Run " + run.Name + "could not be found in the RunCollection.");130 144 } 131 145 … … 143 157 protected override void ClearSorting() { 144 158 base.ClearSorting(); 145 runToRowMapping = new int[Content.Count]; 146 for (int i = 0; i < runToRowMapping.Length; i++) 147 runToRowMapping[i] = i; 159 runToRowMapping = Enumerable.Range(0, Content.Count).ToArray(); 148 160 UpdateRowAttributes(); 149 161 } … … 176 188 runIndex++; 177 189 } 190 UpdateRowHeaders(); 178 191 } 179 192
Note: See TracChangeset
for help on using the changeset viewer.