- Timestamp:
- 03/05/14 15:43:46 (11 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/LineChartLogic.cs
r10539 r10544 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using HeuristicLab.Analysis; … … 32 33 dataTable = new DataTable("LineChart"); 33 34 FillDataTable(); 35 preprocessingData.Changed += PreprocessingData_Changed; 34 36 } 35 37 … … 77 79 } 78 80 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 } 79 102 } 80 103 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingData.cs
r10367 r10544 103 103 public void SetCell<T>(int columnIndex, int rowIndex, T value) { 104 104 variableValues[columnIndex][rowIndex] = value; 105 OnChanged(DataPreprocessingChangedEventType.ChangeItem, columnIndex, rowIndex); 105 106 } 106 107 … … 112 113 public string GetCellAsString(int columnIndex, int rowIndex) { 113 114 return variableValues[columnIndex][rowIndex].ToString(); 114 115 115 } 116 116 … … 127 127 public void SetValues<T>(string variableName, IList<T> values) { 128 128 SetValues<T>(GetColumnIndex(variableName), values); 129 130 } 129 } 130 131 131 public void SetValues<T>(int columnIndex, IList<T> values) { 132 132 if (IsType<T>(columnIndex)) { … … 135 135 throw new ArgumentException("The datatype of column " + columnIndex + " must be of type " + variableValues[columnIndex].GetType().Name + " but was " + typeof(T).Name); 136 136 } 137 OnChanged(DataPreprocessingChangedEventType.ChangeColumn, columnIndex, -1); 137 138 } 138 139 … … 140 141 foreach (IList column in variableValues.Values) { 141 142 Type type = column.GetType().GetGenericArguments()[0]; 142 143 143 column.Insert(rowIndex, type.IsValueType ? Activator.CreateInstance(type) : null); 144 144 } 145 OnChanged(DataPreprocessingChangedEventType.AddRow, -1, rowIndex); 145 146 } 146 147 … … 149 150 column.RemoveAt(rowIndex); 150 151 } 152 OnChanged(DataPreprocessingChangedEventType.DeleteRow, -1, rowIndex); 151 153 } 152 154 153 155 public void InsertColumn<T>(string variableName, int columnIndex) { 154 156 variableValues.Add(columnIndex, new List<T>(Rows)); 155 variableNames.Insert(columnIndex, variableName); 157 variableNames.Insert(columnIndex, variableName); 158 OnChanged(DataPreprocessingChangedEventType.AddColumn, columnIndex , -1); 156 159 } 157 160 … … 159 162 variableValues.Remove(columnIndex); 160 163 variableNames.RemoveAt(columnIndex); 164 OnChanged(DataPreprocessingChangedEventType.DeleteColumn, columnIndex, -1); 161 165 } 162 166 … … 212 216 var dataset = new Dataset(variableNames, values); 213 217 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)); 214 224 } 215 225
Note: See TracChangeset
for help on using the changeset viewer.