Changeset 4200 for trunk/sources/HeuristicLab.Optimization.Views/3.3
- Timestamp:
- 08/11/10 17:40:00 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization.Views/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionTabularView.Designer.cs
r3742 r4200 46 46 private void InitializeComponent() { 47 47 this.components = new System.ComponentModel.Container(); 48 this.dataGridView.RowHeaderMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(dataGridView_RowHeaderMouseDoubleClick); 48 49 } 49 50 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionTabularView.cs
r4068 r4200 31 31 [View("RunCollection Tabular View")] 32 32 [Content(typeof(RunCollection), false)] 33 public partial class RunCollectionTabularView : StringConvertibleMatrixView { 33 public sealed partial class RunCollectionTabularView : StringConvertibleMatrixView { 34 private int[] runToRowMapping; 34 35 public RunCollectionTabularView() { 35 36 InitializeComponent(); 36 this.dataGridView.RowHeaderMouseDoubleClick += new DataGridViewCellMouseEventHandler(dataGridView_RowHeaderMouseDoubleClick);37 37 base.ReadOnly = true; 38 38 } … … 51 51 base.OnContentChanged(); 52 52 if (Content != null) { 53 foreach (IRun run in Content) 54 UpdateRun(run); 55 } 56 } 57 53 runToRowMapping = Enumerable.Range(0, Content.Count).ToArray(); 54 UpdateRowAttributes(); 55 } 56 } 57 58 #region events 58 59 protected override void RegisterContentEvents() { 59 60 base.RegisterContentEvents(); … … 63 64 RegisterRunEvents(Content); 64 65 } 65 pr otected virtualvoid RegisterRunEvents(IEnumerable<IRun> runs) {66 private void RegisterRunEvents(IEnumerable<IRun> runs) { 66 67 foreach (IRun run in runs) 67 68 run.Changed += new EventHandler(run_Changed); … … 74 75 DeregisterRunEvents(Content); 75 76 } 76 pr otected virtualvoid DeregisterRunEvents(IEnumerable<IRun> runs) {77 private void DeregisterRunEvents(IEnumerable<IRun> runs) { 77 78 foreach (IRun run in runs) 78 79 run.Changed -= new EventHandler(run_Changed); … … 81 82 DeregisterRunEvents(e.OldItems); 82 83 RegisterRunEvents(e.Items); 84 OnContentChanged(); 83 85 } 84 86 private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { … … 96 98 } 97 99 } 100 #endregion 98 101 99 102 private void UpdateRun(IRun run) { 100 int r owIndex = Content.ToList().IndexOf(run);101 rowIndex = virtualRowIndizes[rowIndex];103 int runIndex = GetIndexOfRun(run); 104 int rowIndex = runToRowMapping[runIndex]; 102 105 this.dataGridView.Rows[rowIndex].Visible = run.Visible; 103 106 this.dataGridView.Rows[rowIndex].DefaultCellStyle.ForeColor = run.Color; 104 this.rowsTextBox.Text = this.Content.Count(r => r.Visible).ToString(); 107 this.UpdateRowHeaders(); 108 } 109 110 private int GetIndexOfRun(IRun run) { 111 int i = 0; 112 foreach (IRun actualRun in Content) { 113 if (actualRun == run) 114 return i; 115 i++; 116 } 117 throw new ArgumentException("Run " + run.Name + "could not be found in the RunCollection."); 105 118 } 106 119 107 120 private void dataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { 108 121 if (e.RowIndex >= 0) { 109 IRun run = Content.ElementAt( virtualRowIndizes[e.RowIndex]);122 IRun run = Content.ElementAt(runToRowMapping.ToList().IndexOf(e.RowIndex)); 110 123 IContentView view = MainFormManager.MainForm.ShowContent(run); 111 124 if (view != null) { … … 124 137 Array.Sort(newSortedIndex, rowComparer); 125 138 } 139 140 runToRowMapping = new int[newSortedIndex.Length]; 141 int i = 0; 142 foreach (int runIndex in newSortedIndex) { 143 runToRowMapping[runIndex] = i; 144 i++; 145 } 146 UpdateRowAttributes(); 126 147 return newSortedIndex; 148 } 149 150 private void UpdateRowAttributes() { 151 int runIndex = 0; 152 foreach (IRun run in Content) { 153 int rowIndex = this.runToRowMapping[runIndex]; 154 this.dataGridView.Rows[rowIndex].Visible = run.Visible; 155 this.dataGridView.Rows[rowIndex].DefaultCellStyle.ForeColor = run.Color; 156 runIndex++; 157 } 127 158 } 128 159 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r4163 r4200 111 111 ListViewItem listViewItem = CreateListViewItem(item); 112 112 AddListViewItem(listViewItem); 113 UpdateRun(item);114 113 if ((selectedName != null) && item.Name.Equals(selectedName)) 115 114 listViewItem.Selected = true; 116 115 } 116 AdjustListViewColumnSizes(); 117 117 } else { 118 118 runCollectionConstraintCollectionView.Content = null; … … 150 150 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 151 151 listViewItem.Tag = item; 152 153 if (item.Visible) { 154 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 155 listViewItem.ForeColor = item.Color; 156 } else { 157 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic); 158 listViewItem.ForeColor = Color.LightGray; 159 } 152 160 return listViewItem; 153 161 } … … 156 164 ((IRun)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 157 165 ((IRun)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 158 AdjustListViewColumnSizes();159 166 } 160 167 protected virtual void RemoveListViewItem(ListViewItem listViewItem) { … … 294 301 else { 295 302 RegisterRunEvents(e.Items); 296 foreach (IRun item in e.Items) {303 foreach (IRun item in e.Items) 297 304 AddListViewItem(CreateListViewItem(item)); 298 UpdateRun(item); 299 }305 306 AdjustListViewColumnSizes(); 300 307 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 301 308 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; … … 331 338 } 332 339 RegisterRunEvents(e.Items); 333 foreach (IRun item in e.Items) {340 foreach (IRun item in e.Items) 334 341 AddListViewItem(CreateListViewItem(item)); 335 UpdateRun(item); 336 }342 343 AdjustListViewColumnSizes(); 337 344 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 338 345 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
Note: See TracChangeset
for help on using the changeset viewer.