Changeset 6018 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs
- Timestamp:
- 04/17/11 18:22:28 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs
r6017 r6018 92 92 if (this.valueConfigurations != null) DeregisterValueConfigurationEvents(); 93 93 this.valueConfigurations = value; 94 KeepActualValueConfigurationIndexConsistent(); 94 95 if (this.valueConfigurations != null) RegisterValueConfigurationEvents(); 95 96 } … … 144 145 set { autoPopulateValueConfigurations = value; } 145 146 } 146 147 147 148 148 149 #region Constructors and Cloning … … 258 259 } else { 259 260 IItem val; 260 if (ActualValue.Value != null && ActualValue.Value DataType== t) {261 if (ActualValue.Value != null && ActualValue.Value.GetType() == t) { 261 262 val = (IItem)ActualValue.Value.Clone(); // use existing value for that type (if available) 262 263 } else { … … 363 364 void ValueConfigurations_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 364 365 OnToStringChanged(); 365 } 366 KeepActualValueConfigurationIndexConsistent(); 367 } 368 366 369 void ValueConfigurations_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 367 370 OnToStringChanged(); 371 KeepActualValueConfigurationIndexConsistent(); 368 372 } 369 373 void ValueConfigurations_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 370 374 OnToStringChanged(); 375 KeepActualValueConfigurationIndexConsistent(); 371 376 } 372 377 … … 440 445 } 441 446 442 public string ParameterInfoString {447 public virtual string ParameterInfoString { 443 448 get { 444 449 StringBuilder sb = new StringBuilder(); … … 455 460 } 456 461 457 if (this. ActualValue.Value is IParameterizedItem) {462 if (this.ValueConfigurations[actualValueConfigurationIndex] is ParameterizedValueConfiguration) { 458 463 string subParams = this.ValueConfigurations[actualValueConfigurationIndex].ParameterInfoString; 459 464 if (!string.IsNullOrEmpty(subParams)) { … … 583 588 } 584 589 } 590 591 /// <summary> 592 /// Ensures that the ActualValueConfigurationIndex has a valid value 593 /// Only indices of items which are checked are allowed 594 /// </summary> 595 private void KeepActualValueConfigurationIndexConsistent() { 596 if (this.valueConfigurations != null && this.valueConfigurations.CheckedItems.Count() > 0) { 597 if(this.valueConfigurations.Count <= this.actualValueConfigurationIndex && 598 this.valueConfigurations.CheckedItems.Count(x => x.Index == this.actualValueConfigurationIndex) == 1) { 599 // everything is ok; do nothing 600 } else { 601 // current index is invalid, set new one 602 this.ActualValueConfigurationIndex = this.valueConfigurations.CheckedItems.First().Index; 603 } 604 } else { 605 // no checked valueConfiguration is available; cannot be used 606 this.ActualValueConfigurationIndex = -1; 607 } 608 } 585 609 } 586 610 }
Note: See TracChangeset
for help on using the changeset viewer.