Changeset 9432
- Timestamp:
- 05/03/13 11:30:34 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Data/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data/3.3/ValueTypeArray.cs
r8587 r9432 34 34 [StorableClass] 35 35 public abstract class ValueTypeArray<T> : Item, IEnumerable<T> where T : struct { 36 private const int maximumToStringLength = 100; 37 36 38 public static new Image StaticItemImage { 37 39 get { return HeuristicLab.Common.Resources.VSImageLibrary.Class; } … … 99 101 100 102 public override string ToString() { 103 if (array.Length == 0) return "[]"; 104 101 105 StringBuilder sb = new StringBuilder(); 102 106 sb.Append("["); 103 if (array.Length > 0) { 104 sb.Append(array[0].ToString()); 105 for (int i = 1; i < array.Length; i++) 106 sb.Append(";").Append(array[i].ToString()); 107 sb.Append(array[0].ToString()); 108 for (int i = 1; i < array.Length; i++) { 109 sb.Append(";").Append(array[i].ToString()); 110 if (sb.Length > maximumToStringLength) { 111 sb.Append("..."); 112 break; 113 } 107 114 } 108 115 sb.Append("]"); … … 122 129 if (ItemChanged != null) 123 130 ItemChanged(this, new EventArgs<int>(index)); 124 OnToStringChanged(); 131 if (index < maximumToStringLength) 132 OnToStringChanged(); 125 133 } 126 134 public event EventHandler Reset; -
trunk/sources/HeuristicLab.Data/3.3/ValueTypeMatrix.cs
r7259 r9432 34 34 [StorableClass] 35 35 public abstract class ValueTypeMatrix<T> : Item, IEnumerable<T> where T : struct { 36 private const int maximumToStringLength = 100; 37 36 38 public static new Image StaticItemImage { 37 39 get { return HeuristicLab.Common.Resources.VSImageLibrary.Class; } … … 194 196 195 197 public override string ToString() { 198 if (matrix.Length == 0) return "[]"; 199 196 200 StringBuilder sb = new StringBuilder(); 197 201 sb.Append("["); 198 if (matrix.Length > 0) { 199 for (int i = 0; i < Rows; i++) { 200 sb.Append("[").Append(matrix[i, 0].ToString()); 201 for (int j = 1; j < Columns; j++) 202 sb.Append(";").Append(matrix[i, j].ToString()); 203 sb.Append("]"); 202 for (int i = 0; i < Rows; i++) { 203 sb.Append("[").Append(matrix[i, 0].ToString()); 204 for (int j = 1; j < Columns; j++) 205 sb.Append(";").Append(matrix[i, j].ToString()); 206 sb.Append("]"); 207 208 if (sb.Length > maximumToStringLength) { 209 sb.Append("[...]"); 210 break; 204 211 } 205 212 } 206 213 sb.Append("]"); 214 207 215 return sb.ToString(); 208 216 } … … 251 259 if (ItemChanged != null) 252 260 ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex)); 253 OnToStringChanged(); 261 262 //approximation to avoid firing of unnecessary ToStringChangedEvents 263 //columnIndex is not used, because always full rows are returned in the ToString method 264 if (rowIndex * Columns < maximumToStringLength) 265 OnToStringChanged(); 254 266 } 255 267 public event EventHandler Reset;
Note: See TracChangeset
for help on using the changeset viewer.