Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10544


Ignore:
Timestamp:
03/05/14 15:43:46 (11 years ago)
Author:
sbreuer
Message:
  • created changed event in preprocessing data
  • register to event in line chart
Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/HeuristicLab.DataPreprocessing-3.3.csproj

    r10383 r10544  
    7878  <ItemGroup>
    7979    <Compile Include="Implementations\DataGridLogic.cs" />
     80    <Compile Include="Implementations\DataPreprocessingChangedEvent.cs" />
    8081    <Compile Include="Implementations\ManipulationLogic.cs" />
    8182    <Compile Include="Interfaces\IDataGridLogic.cs" />
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/LineChartLogic.cs

    r10539 r10544  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using HeuristicLab.Analysis;
     
    3233      dataTable = new DataTable("LineChart");
    3334      FillDataTable();
     35      preprocessingData.Changed += PreprocessingData_Changed;
    3436    }
    3537
     
    7779    }
    7880
     81    void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) {
     82      var variableName = preprocessingData.GetVariableName(e.Column);
     83      switch (e.Type) {
     84        case DataPreprocessingChangedEventType.DeleteColumn:
     85          dataTable.Rows.Remove(variableName);
     86          break;
     87        case DataPreprocessingChangedEventType.AddColumn:
     88          dataTable.Rows.Add(new DataRow(variableName, String.Empty, preprocessingData.GetValues<double>(e.Column)));
     89          break;
     90        case DataPreprocessingChangedEventType.ChangeColumn:
     91        case DataPreprocessingChangedEventType.ChangeItem:
     92          dataTable.Rows.Remove(variableName);
     93          dataTable.Rows.Add(new DataRow(variableName, String.Empty, preprocessingData.GetValues<double>(e.Column)));
     94          break;
     95        case DataPreprocessingChangedEventType.DeleteRow:
     96        case DataPreprocessingChangedEventType.AddRow:
     97          dataTable.Rows.Clear();
     98          FillDataTable();
     99          break;
     100      }
     101    }
    79102  }
    80103}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingData.cs

    r10367 r10544  
    103103    public void SetCell<T>(int columnIndex, int rowIndex, T value) {
    104104      variableValues[columnIndex][rowIndex] = value;
     105      OnChanged(DataPreprocessingChangedEventType.ChangeItem, columnIndex, rowIndex);
    105106    }
    106107
     
    112113    public string GetCellAsString(int columnIndex, int rowIndex) {
    113114      return variableValues[columnIndex][rowIndex].ToString();
    114 
    115115    }
    116116
     
    127127    public void SetValues<T>(string variableName, IList<T> values) {
    128128      SetValues<T>(GetColumnIndex(variableName), values);
    129 
    130     }
     129    }
     130
    131131    public void SetValues<T>(int columnIndex, IList<T> values) {
    132132      if (IsType<T>(columnIndex)) {
     
    135135        throw new ArgumentException("The datatype of column " + columnIndex + " must be of type " + variableValues[columnIndex].GetType().Name + " but was " + typeof(T).Name);
    136136      }
     137      OnChanged(DataPreprocessingChangedEventType.ChangeColumn, columnIndex, -1);
    137138    }
    138139
     
    140141      foreach (IList column in variableValues.Values) {
    141142        Type type = column.GetType().GetGenericArguments()[0];
    142 
    143143        column.Insert(rowIndex, type.IsValueType ? Activator.CreateInstance(type) : null);
    144144      }
     145      OnChanged(DataPreprocessingChangedEventType.AddRow, -1, rowIndex);
    145146    }
    146147
     
    149150        column.RemoveAt(rowIndex);
    150151      }
     152      OnChanged(DataPreprocessingChangedEventType.DeleteRow, -1, rowIndex);
    151153    }
    152154
    153155    public void InsertColumn<T>(string variableName, int columnIndex) {
    154156      variableValues.Add(columnIndex, new List<T>(Rows));
    155       variableNames.Insert(columnIndex, variableName);
     157      variableNames.Insert(columnIndex, variableName);
     158      OnChanged(DataPreprocessingChangedEventType.AddColumn, columnIndex , -1);
    156159    }
    157160
     
    159162      variableValues.Remove(columnIndex);
    160163      variableNames.RemoveAt(columnIndex);
     164      OnChanged(DataPreprocessingChangedEventType.DeleteColumn, columnIndex, -1);
    161165    }
    162166
     
    212216      var dataset = new Dataset(variableNames, values);
    213217      return dataset;
     218    }
     219
     220    public event DataPreprocessingChangedEventHandler Changed;
     221    protected virtual void OnChanged(DataPreprocessingChangedEventType type, int column, int row) {
     222      var listeners = Changed;
     223      if (listeners != null) listeners(this, new DataPreprocessingChangedEventArgs(type, column, row));
    214224    }
    215225
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IPreprocessingData.cs

    r10367 r10544  
    7474
    7575    Dataset ExportToDataset();
     76
     77    event DataPreprocessingChangedEventHandler Changed;
    7678  }
    7779}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/LineChartView.cs

    r10539 r10544  
    3535    }
    3636
    37     private void InitDataTable() {
     37    private void InitDataTable() { 
    3838      ILineChartLogic logic = Content.LineChartLogic;
    3939      viewHost.Content = logic.GetDataTable();
Note: See TracChangeset for help on using the changeset viewer.