Changeset 1984
- Timestamp:
- 05/31/09 21:47:55 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.Test/3.2/LineChartTests.cs
r1983 r1984 302 302 303 303 row.ModifyValues(new double[] {5, 5}, 1); 304 305 model.AddDataRow(row); 306 307 f.ShowDialog(); 308 } 309 310 [Test] 311 public void TestRemoveValueFromDataRow() { 312 LineChartTestForm f = new LineChartTestForm(model); 313 314 IDataRow row = new DataRow(); 315 row.AddValue(0); 316 row.AddValue(20); 317 row.AddValue(100); 318 row.AddValue(50); 319 320 row.RemoveValue(2); 321 322 model.AddDataRow(row); 323 324 f.ShowDialog(); 325 } 326 327 [Test] 328 public void TestRemoveValuesFromDataRow() { 329 LineChartTestForm f = new LineChartTestForm(model); 330 331 IDataRow row = new DataRow(); 332 row.AddValue(0); 333 row.AddValue(20); 334 row.AddValue(100); 335 row.AddValue(50); 336 337 row.RemoveValues(1, 2); 304 338 305 339 model.AddDataRow(row); -
trunk/sources/HeuristicLab.Visualization/3.2/DataRow.cs
r1983 r1984 113 113 114 114 public override void RemoveValue(int index) { 115 double remVal = dataRow[index];116 //check if index is valid117 115 if (index >= 0 && index < dataRow.Count) { 116 UpdateMinMaxValueForRemovedValue(index); // bad runtime but works 117 double removedValue = dataRow[index]; 118 118 dataRow.RemoveAt(index); 119 OnValueChanged(rem Val, index, Action.Deleted);119 OnValueChanged(removedValue, index, Action.Deleted); 120 120 } else { 121 121 throw new IndexOutOfRangeException(); … … 124 124 125 125 public override void RemoveValues(int index, int count) { 126 double[] remValues = new double[count]; //removed values127 int j = 0;128 129 //check if count is valid130 126 if (count > 0) { 131 //check if index is valid132 127 if ((index >= 0) && (index + count <= dataRow.Count)) { 133 for (int i = index; i < (index + count); i++) { 134 remValues.SetValue(i, j); 135 dataRow.RemoveAt(i); 136 j++; 128 double[] removedValues = new double[count]; 129 for (int i = 0; i < count; i++) { 130 removedValues[i] = dataRow[index + i]; 131 UpdateMinMaxValueForRemovedValue(index); // bad runtime but works 132 dataRow.RemoveAt(index); 137 133 } 138 OnValuesChanged(rem Values, index, Action.Deleted);134 OnValuesChanged(removedValues, index, Action.Deleted); 139 135 } else { 140 136 throw new IndexOutOfRangeException(); … … 165 161 } 166 162 163 private void UpdateMinMaxValueForRemovedValue(int removedValueIndex) { 164 if (minValue == dataRow[removedValueIndex] || maxValue == dataRow[removedValueIndex]) { 165 minValue = double.MaxValue; 166 maxValue = double.MinValue; 167 168 for (int i = 0; i < dataRow.Count; i++) { 169 if (i != removedValueIndex) { 170 UpdateMinMaxValue(dataRow[i]); 171 } 172 } 173 } 174 } 175 167 176 private void UpdateMinMaxValue(double newValue, int oldValueIndex) { 168 177 if (minValue != dataRow[oldValueIndex] && maxValue != dataRow[oldValueIndex])
Note: See TracChangeset
for help on using the changeset viewer.