- Timestamp:
- 03/11/13 16:47:11 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/DoubleMatrix.cs
r9286 r9306 74 74 } 75 75 } 76 protected override bool SetValue (IEnumerable<RowColumnValue> rowColumnValues) {77 if (ReadOnly) throw new NotSupportedException("Item cannot be set. StringMatrix is read-only.");78 List<Tuple<Position, double>> newValues = new List<Tuple<Position, double>>(); 76 protected override bool SetValues(IEnumerable<MatrixValue<string>> matrixValues) { 77 if (ReadOnly) throw new NotSupportedException("Item cannot be set. DoubleMatrix is read-only."); 78 79 79 double parsed; 80 foreach (var curValue in rowColumnValues) { 81 if (double.TryParse(curValue.Value, out parsed)) { 82 newValues.Add(new Tuple<Position, double>(curValue.Position, parsed)); 83 } else { 84 return false; 80 if (!matrixValues.All(v => double.TryParse(v.Value, out parsed))) return false; 81 List<MatrixPosition> positions = new List<MatrixPosition>(); 82 foreach (var v in matrixValues) { 83 parsed = double.Parse(v.Value); 84 if (matrix[v.Position.Row, v.Position.Column] != parsed) { 85 matrix[v.Position.Row, v.Position.Column] = parsed; 86 positions.Add(v.Position); 85 87 } 86 88 } 87 Position pos;88 foreach (var curValue in newValues) {89 pos = curValue.Item1;90 matrix[pos.Row, pos.Column] = curValue.Item2;91 }92 OnItemsChanged(rowColumnValues.Select(x => x.Position));93 89 return true; 94 90 }
Note: See TracChangeset
for help on using the changeset viewer.