Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13036


Ignore:
Timestamp:
10/19/15 17:24:53 (9 years ago)
Author:
gkronber
Message:

#2473: hiding of columns that have only one single value for all runs in the RunCollectionTableView

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs

    r12692 r13036  
    2525using System.Linq;
    2626using System.Windows.Forms;
     27using HeuristicLab.Collections;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Data.Views;
     
    122123
    123124    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 
    127125      for (int i = 0; i < dataGridView.ColumnCount; i++) {
    128126        if (i < base.Content.ColumnNames.Count())
     
    130128        else
    131129          dataGridView.Columns[i].HeaderText = "Column " + (i + 1);
     130      }
     131
     132      HashSet<string> visibleColumnNames = new HashSet<string>(dataGridView.Columns.OfType<DataGridViewColumn>()
     133       .Where(c => c.Visible && !string.IsNullOrEmpty(c.HeaderText) && GetNumberOfDistinctValues(c.HeaderText) > 1).Select(c => c.HeaderText));
     134
     135      for (int i = 0; i < dataGridView.ColumnCount; i++) {
    132136        dataGridView.Columns[i].Visible = visibleColumnNames.Count == 0 || visibleColumnNames.Contains(dataGridView.Columns[i].HeaderText);
    133137      }
     138    }
     139
     140    // returns the number of different values for the parameter or result in the RunCollection
     141    private int GetNumberOfDistinctValues(string columnName) {
     142      Func<IRun, string, string> GetStringValue = (IRun r, string colName) => {
     143        // also include missing values in the count
     144        if (r.Parameters.ContainsKey(colName)) return r.Parameters[colName].ToString();
     145        if (r.Results.ContainsKey(colName)) return r.Results[colName].ToString();
     146        return string.Empty;
     147      };
     148      return Content.Select(r => GetStringValue(r, columnName)).Distinct().Count();
    134149    }
    135150
Note: See TracChangeset for help on using the changeset viewer.