Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/11/13 16:47:11 (11 years ago)
Author:
sforsten
Message:

#2018:

  • renamed the structs and methods in IStringConvertibleMatrix
  • added MatrixValuesChangedEventArgs in IStringConvertibleMatrix
  • added methods SetValues(MatrixValues<T>) in ValueTypeMatrix
  • fixed bugs in StringConvertibleMatrixView: DataGridView has now at least one column and dataGridView_CellValidating does not set e.Cancel to true anymore.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/BoolMatrix.cs

    r9286 r9306  
    7474      }
    7575    }
    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.");
    7978      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);
    8586        }
    8687      }
    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));
    9388      return true;
    9489    }
Note: See TracChangeset for help on using the changeset viewer.