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