Changeset 3321
- Timestamp:
- 04/13/10 10:37:47 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Dataset.cs
r3311 r3321 46 46 } 47 47 Data = data; 48 this.variableNames = variableNames.ToArray(); 48 this.VariableNames = variableNames; 49 this.sortableView = false; 49 50 } 50 51 … … 53 54 public IEnumerable<string> VariableNames { 54 55 get { return variableNames; } 56 protected set { 57 if (variableNames != value) { 58 variableNames = value.ToArray(); 59 OnColumnNamesChanged(); 60 } 61 } 55 62 } 56 63 … … 75 82 data[rowIndex, columnIndex] = value; 76 83 OnDataChanged(new EventArgs<int, int>(rowIndex, columnIndex)); 84 OnItemChanged(rowIndex, columnIndex); 77 85 } 78 86 } … … 116 124 if (variableIndex < 0 || variableIndex >= variableNames.Length) throw new ArgumentException(" Cannot set name of not existent variable at index " + variableIndex + "."); 117 125 variableNames[variableIndex] = name; 126 OnColumnNamesChanged(); 118 127 } 119 128 … … 220 229 var listeners = Reset; 221 230 if (listeners != null) listeners(this, e); 222 }223 224 private void data_ItemChanged(object sender, EventArgs<int, int> e) {225 OnDataChanged(e);226 }227 228 private void data_Reset(object sender, EventArgs e) {229 OnReset(e);230 231 } 231 232 #endregion … … 271 272 newVariableNames[column] = "Var" + column.ToString(formatString); 272 273 } 273 variableNames = newVariableNames;274 VariableNames = newVariableNames; 274 275 Data = newValues; 276 } 277 } 278 } 279 280 [Storable] 281 private bool sortableView; 282 public bool SortableView { 283 get { return sortableView; } 284 set { 285 if (value != sortableView) { 286 sortableView = value; 287 OnSortableViewChanged(); 275 288 } 276 289 } … … 285 298 i++; 286 299 } 300 OnColumnNamesChanged(); 287 301 } 288 302 } … … 294 308 295 309 public bool Validate(string value, out string errorMessage) { 310 double val; 311 bool valid = double.TryParse(value, out val); 296 312 errorMessage = string.Empty; 297 return true; 313 if (!valid) { 314 StringBuilder sb = new StringBuilder(); 315 sb.Append("Invalid Value (Valid Value Format: \""); 316 sb.Append(FormatPatterns.GetDoubleFormatPattern()); 317 sb.Append("\")"); 318 errorMessage = sb.ToString(); 319 } 320 return valid; 298 321 } 299 322 … … 306 329 if (double.TryParse(value, out v)) { 307 330 data[rowIndex, columnIndex] = v; 331 OnDataChanged(new EventArgs<int, int>(rowIndex, columnIndex)); 332 OnItemChanged(rowIndex, columnIndex); 308 333 return true; 309 334 } else return false; 310 335 } 311 336 337 public event EventHandler ColumnNamesChanged; 338 private void OnColumnNamesChanged() { 339 EventHandler handler = ColumnNamesChanged; 340 if (handler != null) 341 handler(this, EventArgs.Empty); 342 } 343 public event EventHandler RowNamesChanged; 344 private void OnRowNamesChanged() { 345 EventHandler handler = RowNamesChanged; 346 if (handler != null) 347 handler(this, EventArgs.Empty); 348 } 349 public event EventHandler SortableViewChanged; 350 private void OnSortableViewChanged() { 351 EventHandler handler = SortableViewChanged; 352 if (handler != null) 353 handler(this, EventArgs.Empty); 354 } 312 355 public event EventHandler<EventArgs<int, int>> ItemChanged; 356 private void OnItemChanged(int rowIndex, int columnIndex) { 357 if (ItemChanged != null) 358 ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex)); 359 OnToStringChanged(); 360 } 313 361 #endregion 314 362 }
Note: See TracChangeset
for help on using the changeset viewer.