Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5150 for trunk


Ignore:
Timestamp:
12/21/10 16:08:55 (14 years ago)
Author:
mkommend
Message:

Added ColumnsChanged and RowsChanged event in IStringConvertibleMatrix and all implementing classes (ticket #1269).

Location:
trunk/sources
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis/3.3/DataVisualization/DataTable.cs

    r5097 r5150  
    128128      foreach (DataRow row in e.Items)
    129129        this.RegisterRowEvents(row);
     130
     131      this.OnColumnsChanged();
    130132      this.OnColumnNamesChanged();
    131133      this.OnReset();
     
    134136      foreach (DataRow row in e.Items)
    135137        this.DeregisterRowEvents(row);
     138
     139      this.OnColumnsChanged();
    136140      this.OnColumnNamesChanged();
    137141      this.OnReset();
     
    142146      foreach (DataRow row in e.Items)
    143147        this.RegisterRowEvents(row);
     148
     149      this.OnColumnsChanged();
    144150      this.OnColumnNamesChanged();
    145151      this.OnReset();
     
    150156      foreach (DataRow row in e.Items)
    151157        this.RegisterRowEvents(row);
     158
     159      if (e.OldItems.Count() != e.Items.Count())
     160        this.OnColumnsChanged();
    152161      this.OnColumnNamesChanged();
    153162      this.OnReset();
     
    239248      if (handler != null) handler(this, EventArgs.Empty);
    240249    }
     250    public event EventHandler ColumnsChanged;
     251    protected virtual void OnColumnsChanged() {
     252      var handler = ColumnsChanged;
     253      if (handler != null) handler(this, EventArgs.Empty);
     254    }
     255    public event EventHandler RowsChanged;
     256    protected virtual void OnRowsChanged() {
     257      var handler = RowsChanged;
     258      if (handler != null) handler(this, EventArgs.Empty);
     259    }
    241260    public event EventHandler ColumnNamesChanged;
    242261    protected virtual void OnColumnNamesChanged() {
  • trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleMatrix.cs

    r4477 r5150  
    3838    bool SetValue(string value, int rowIndex, int columnIndex);
    3939
     40    event EventHandler ColumnsChanged;
     41    event EventHandler RowsChanged;
    4042    event EventHandler ColumnNamesChanged;
    4143    event EventHandler RowNamesChanged;
     
    4345    event EventHandler<EventArgs<int, int>> ItemChanged;
    4446    event EventHandler Reset;
     47
    4548  }
    4649}
  • trunk/sources/HeuristicLab.Data/3.3/StringMatrix.cs

    r4722 r5150  
    5353        else
    5454          columnNames = new List<string>(value);
     55        OnColumnNamesChanged();
    5556      }
    5657    }
     
    6768        else
    6869          rowNames = new List<string>(value);
     70        OnRowNamesChanged();
    6971      }
    7072    }
     
    9496          while (rowNames.Count < value)
    9597            rowNames.Add("Row " + rowNames.Count);
     98          OnRowsChanged();
     99          OnRowNamesChanged();
    96100          OnReset();
    97101        }
     
    111115          while (columnNames.Count < value)
    112116            columnNames.Add("Column " + columnNames.Count);
     117          OnColumnsChanged();
     118          OnColumnNamesChanged();
    113119          OnReset();
    114120        }
     
    167173    }
    168174    protected StringMatrix(int rows, int columns, IEnumerable<string> columnNames, IEnumerable<string> rowNames)
    169       : this(rows, columns,columnNames) {
     175      : this(rows, columns, columnNames) {
    170176      RowNames = rowNames;
    171177    }
     
    186192      ColumnNames = columnNames;
    187193    }
    188     protected StringMatrix(string[,] elements, IEnumerable<string> columnNames,IEnumerable<string> rowNames)
    189       : this(elements,columnNames) {
     194    protected StringMatrix(string[,] elements, IEnumerable<string> columnNames, IEnumerable<string> rowNames)
     195      : this(elements, columnNames) {
    190196      RowNames = rowNames;
    191197    }
     
    245251    }
    246252
     253    #region events
     254    public event EventHandler ColumnsChanged;
     255    protected virtual void OnColumnsChanged() {
     256      EventHandler handler = ColumnsChanged;
     257      if (handler != null)
     258        handler(this, EventArgs.Empty);
     259    }
     260    public event EventHandler RowsChanged;
     261    protected virtual void OnRowsChanged() {
     262      EventHandler handler = RowsChanged;
     263      if (handler != null)
     264        handler(this, EventArgs.Empty);
     265    }
    247266    public event EventHandler ColumnNamesChanged;
    248267    protected virtual void OnColumnNamesChanged() {
     
    275294      OnToStringChanged();
    276295    }
     296    #endregion
    277297
    278298    #region IStringConvertibleMatrix Members
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeMatrix.cs

    r4722 r5150  
    5353        else
    5454          columnNames = new List<string>(value);
     55        OnColumnNamesChanged();
    5556      }
    5657    }
     
    6768        else
    6869          rowNames = new List<string>(value);
     70        OnRowNamesChanged();
    6971      }
    7072    }
     
    9496          while (rowNames.Count < value)
    9597            rowNames.Add("Row " + rowNames.Count);
     98          OnRowsChanged();
     99          OnRowNamesChanged();
    96100          OnReset();
    97101        }
     
    111115          while (columnNames.Count < value)
    112116            columnNames.Add("Column " + columnNames.Count);
     117          OnColumnsChanged();
     118          OnColumnNamesChanged();
    113119          OnReset();
    114120        }
     
    177183    }
    178184    protected ValueTypeMatrix(T[,] elements, IEnumerable<string> columnNames, IEnumerable<string> rowNames)
    179       : this(elements,columnNames) {
     185      : this(elements, columnNames) {
    180186      RowNames = rowNames;
    181187    }
     
    210216    }
    211217
     218    #region events
     219    public event EventHandler ColumnsChanged;
     220    protected virtual void OnColumnsChanged() {
     221      EventHandler handler = ColumnsChanged;
     222      if (handler != null)
     223        handler(this, EventArgs.Empty);
     224    }
     225    public event EventHandler RowsChanged;
     226    protected virtual void OnRowsChanged() {
     227      EventHandler handler = RowsChanged;
     228      if (handler != null)
     229        handler(this, EventArgs.Empty);
     230    }
    212231    public event EventHandler ColumnNamesChanged;
    213232    protected virtual void OnColumnNamesChanged() {
    214233      EventHandler handler = ColumnNamesChanged;
    215       if(handler!=null)
    216         handler(this,EventArgs.Empty);
     234      if (handler != null)
     235        handler(this, EventArgs.Empty);
    217236    }
    218237    public event EventHandler RowNamesChanged;
     
    240259      OnToStringChanged();
    241260    }
     261    #endregion
    242262  }
    243263}
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs

    r4888 r5150  
    123123      }
    124124      columnNameCache = null;
     125      OnColumnsChanged();
    125126      OnColumnNamesChanged();
    126127      rowNamesCache = null;
    127128      base.OnCollectionReset(items, oldItems);
     129      OnRowsChanged();
    128130      OnRowNamesChanged();
    129131      OnReset();
     
    131133    }
    132134    protected override void OnItemsAdded(IEnumerable<IRun> items) {
    133       bool columnNamesChanged = false;
     135      bool columnsChanged = false;
    134136      foreach (IRun run in items) {
    135137        foreach (KeyValuePair<string, IItem> parameter in run.Parameters)
    136           columnNamesChanged |= AddParameter(parameter.Key, parameter.Value);
     138          columnsChanged |= AddParameter(parameter.Key, parameter.Value);
    137139        foreach (KeyValuePair<string, IItem> result in run.Results)
    138           columnNamesChanged |= AddResult(result.Key, result.Value);
    139       }
    140       if (columnNamesChanged) columnNameCache = null;
     140          columnsChanged |= AddResult(result.Key, result.Value);
     141      }
     142      if (columnsChanged) columnNameCache = null;
    141143      rowNamesCache = null;
    142144      base.OnItemsAdded(items);
    143145      OnReset();
     146      OnRowsChanged();
    144147      OnRowNamesChanged();
    145       if (columnNamesChanged) OnColumnNamesChanged();
     148      if (columnsChanged) {
     149        OnColumnsChanged();
     150        OnColumnNamesChanged();
     151      }
    146152      UpdateFiltering(false);
    147153    }
    148154    protected override void OnItemsRemoved(IEnumerable<IRun> items) {
    149       bool columnNamesChanged = false;
     155      bool columnsChanged = false;
    150156      foreach (IRun run in items) {
    151157        foreach (string parameterName in run.Parameters.Keys)
    152           columnNamesChanged |= RemoveParameterName(parameterName);
     158          columnsChanged |= RemoveParameterName(parameterName);
    153159        foreach (string resultName in run.Results.Keys)
    154           columnNamesChanged |= RemoveResultName(resultName);
    155       }
    156       if (columnNamesChanged) columnNameCache = null;
     160          columnsChanged |= RemoveResultName(resultName);
     161      }
     162      if (columnsChanged) columnNameCache = null;
    157163      rowNamesCache = null;
    158164      base.OnItemsRemoved(items);
    159165      OnReset();
    160166      OnRowNamesChanged();
    161       if (columnNamesChanged) OnColumnNamesChanged();
     167      if (columnsChanged) {
     168        OnColumnsChanged();
     169        OnColumnNamesChanged();
     170      }
    162171    }
    163172
     
    287296      OnToStringChanged();
    288297    }
     298    public event EventHandler ColumnsChanged;
     299    protected virtual void OnColumnsChanged() {
     300      var handler = ColumnsChanged;
     301      if (handler != null) handler(this, EventArgs.Empty);
     302    }
     303    public event EventHandler RowsChanged;
     304    protected virtual void OnRowsChanged() {
     305      var handler = RowsChanged;
     306      if (handler != null) handler(this, EventArgs.Empty);
     307    }
    289308    public event EventHandler ColumnNamesChanged;
    290309    protected virtual void OnColumnNamesChanged() {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Dataset.cs

    r4722 r5150  
    187187    }
    188188
     189    public event EventHandler ColumnsChanged;
     190    private void OnColumnsChanged() {
     191      var handler = ColumnsChanged;
     192      if (handler != null) handler(this, EventArgs.Empty);
     193    }
     194    public event EventHandler RowsChanged;
     195    private void OnRowsChanged() {
     196      var handler = RowsChanged;
     197      if (handler != null) handler(this, EventArgs.Empty);
     198    }
    189199    public event EventHandler ColumnNamesChanged;
    190200    private void OnColumnNamesChanged() {
Note: See TracChangeset for help on using the changeset viewer.