Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/22/15 17:08:16 (9 years ago)
Author:
bburlacu
Message:

#2276: Made events in Dataset.cs virtual and overrode them in the ModifiableDataset class. Added event handlers for dataset changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs

    r12190 r12489  
    5656        variableValues[variableNames[i]][row] = list[i];
    5757      }
     58      OnRowsChanged();
     59      OnReset();
    5860    }
    5961
     
    7375      }
    7476      rows++;
     77      OnRowsChanged();
     78      OnReset();
    7579    }
    7680
     
    8488      variableValues[variableName] = new List<T>(values);
    8589      variableNames.Add(variableName);
     90      OnColumnsChanged();
     91      OnColumnNamesChanged();
     92      OnReset();
    8693    }
    8794
     
    9198      variableValues.Remove(variableName);
    9299      variableNames.Remove(variableName);
     100      OnColumnsChanged();
     101      OnColumnNamesChanged();
     102      OnReset();
    93103    }
    94104
     
    98108        list.RemoveAt(row);
    99109      rows--;
     110      OnRowsChanged();
     111      OnReset();
    100112    }
    101113
     
    158170      return false;
    159171    }
     172
     173    #region event handlers
     174    public override event EventHandler RowsChanged;
     175    private void OnRowsChanged() {
     176      var changed = RowsChanged;
     177      if (changed != null)
     178        changed(this, EventArgs.Empty);
     179    }
     180
     181    public override event EventHandler ColumnsChanged;
     182    private void OnColumnsChanged() {
     183      var changed = ColumnsChanged;
     184      if (changed != null)
     185        changed(this, EventArgs.Empty);
     186    }
     187
     188    public override event EventHandler RowNamesChanged;
     189    private void OnRowNamesChanged() {
     190      var changed = RowNamesChanged;
     191      if (changed != null)
     192        changed(this, EventArgs.Empty);
     193    }
     194
     195    public override event EventHandler ColumnNamesChanged;
     196    private void OnColumnNamesChanged() {
     197      var changed = ColumnNamesChanged;
     198      if (changed != null)
     199        changed(this, EventArgs.Empty);
     200    }
     201
     202    public override event EventHandler Reset;
     203    private void OnReset() {
     204      var reset = Reset;
     205      if (reset != null)
     206        reset(this, EventArgs.Empty);
     207    }
     208
     209    // not sure if this is really applicable in the ModifiableDataset
     210    // since this is not a matrix and values are changed based on row + variableName
     211    public override event EventHandler<EventArgs<int, int>> ItemChanged;
     212    private void OnItemChanged(int rowIndex, int columnIndex) {
     213      var changed = ItemChanged;
     214      if (changed != null) {
     215        changed(this, new EventArgs<int, int>(rowIndex, columnIndex));
     216      }
     217    }
     218    #endregion
    160219  }
    161220}
Note: See TracChangeset for help on using the changeset viewer.