- Timestamp:
- 10/26/15 18:31:28 (9 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13036,13054
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Optimization.Views merged: 13036,13054
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs
r12725 r13063 25 25 using System.Linq; 26 26 using System.Windows.Forms; 27 using HeuristicLab.Collections; 27 28 using HeuristicLab.Core; 28 29 using HeuristicLab.Data.Views; … … 122 123 123 124 protected override void UpdateColumnHeaders() { 124 HashSet<string> visibleColumnNames = new HashSet<string>(dataGridView.Columns.OfType<DataGridViewColumn>() 125 .Where(c => c.Visible && !string.IsNullOrEmpty(c.HeaderText)).Select(c => c.HeaderText)); 126 125 string[] colNames = base.Content.ColumnNames.ToArray(); 126 int colCount = colNames.Length; 127 127 for (int i = 0; i < dataGridView.ColumnCount; i++) { 128 if (i < base.Content.ColumnNames.Count())129 dataGridView.Columns[i].HeaderText = base.Content.ColumnNames.ElementAt(i);128 if (i < colCount) 129 dataGridView.Columns[i].HeaderText = colNames[i]; 130 130 else 131 131 dataGridView.Columns[i].HeaderText = "Column " + (i + 1); 132 } 133 134 HashSet<string> visibleColumnNames = new HashSet<string>( 135 dataGridView.Columns.OfType<DataGridViewColumn>() 136 .Where(c => c.Visible) 137 .Where(c => !string.IsNullOrEmpty(c.HeaderText)) 138 .Where(c => !IsConstant(c.HeaderText)) 139 .Select(c => c.HeaderText)); 140 141 for (int i = 0; i < dataGridView.ColumnCount; i++) { 132 142 dataGridView.Columns[i].Visible = visibleColumnNames.Count == 0 || visibleColumnNames.Contains(dataGridView.Columns[i].HeaderText); 133 143 } 144 } 145 146 // returns true when all values in the column are the same (missing values are included in the count) 147 private bool IsConstant(string columnName) { 148 Func<IRun, string, string> GetStringValue = (IRun r, string colName) => { 149 // also include missing values in the count 150 IItem v = null; 151 if (r.Parameters.TryGetValue(colName, out v)) return v.ToString(); 152 if (r.Results.TryGetValue(colName, out v)) return v.ToString(); 153 return string.Empty; 154 }; 155 156 var firstRun = Content.First(); 157 string firstValue = GetStringValue(firstRun, columnName); 158 return Content.Skip(1).All(run => firstValue == GetStringValue(run, columnName)); 134 159 } 135 160
Note: See TracChangeset
for help on using the changeset viewer.