Changeset 8535 for branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations
- Timestamp:
- 08/29/12 09:22:21 (12 years ago)
- Location:
- branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/CheckedValueConfigurationCollection.cs
r8517 r8535 28 28 29 29 namespace HeuristicLab.Encodings.ParameterConfigurationEncoding { 30 // todo: check that at least 1 elementsneeds to be selected31 // todo: control creatable item types30 // TODO: check that at least 1 element needs to be selected 31 // TODO: control creatable item types 32 32 [StorableClass] 33 33 public class CheckedValueConfigurationList : CheckedItemList<IValueConfiguration>, ICheckedValueConfigurationList { … … 44 44 } 45 45 46 public CheckedValueConfigurationList(IItemSet<IItem> validValues) { 47 this.validValues = validValues; 48 RegisterEvents(); 49 } 50 public CheckedValueConfigurationList(IEnumerable<IValueConfiguration> collection) 51 : base(collection) { 52 validValues = null; 53 // event wiring not needed 54 } 55 public CheckedValueConfigurationList() { 56 RegisterEvents(); 57 } 46 #region Constructors and Cloning 58 47 [StorableConstructor] 59 48 protected CheckedValueConfigurationList(bool deserializing) … … 67 56 RegisterEvents(); 68 57 } 69 58 public CheckedValueConfigurationList(IItemSet<IItem> validValues) 59 : base() { 60 this.validValues = validValues; 61 RegisterEvents(); 62 } 63 public CheckedValueConfigurationList(IEnumerable<IValueConfiguration> collection) 64 : base(collection) { 65 validValues = null; 66 // event wiring not needed 67 } 68 public CheckedValueConfigurationList() 69 : base() { 70 RegisterEvents(); 71 } 70 72 public override IDeepCloneable Clone(Cloner cloner) { 71 73 return new CheckedValueConfigurationList(this, cloner); … … 75 77 RegisterEvents(); 76 78 } 79 #endregion 77 80 78 81 private void RegisterEvents() { 79 82 this.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsAdded); 80 this.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved);81 83 } 82 84 83 85 private void DeregisterEvents() { 84 this.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved);85 86 this.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsAdded); 86 87 } … … 95 96 } 96 97 } 97 98 private void CheckedValueConfigurationList_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {99 // auch collectionreset gehört berücksichtigt100 // funktioniert so nicht ganz, weil die view das hinzufügen nicht mitkriegt101 //if (this.Count < minItemCount) {102 // foreach (var item in e.Items) {103 // if (this.Count >= minItemCount)104 // break;105 // this.Add(item);106 // }107 //}108 }109 110 98 } 111 99 } -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/NullValueConfiguration.cs
r8517 r8535 28 28 [StorableClass] 29 29 public class NullValueConfiguration : ValueConfiguration { 30 31 public NullValueConfiguration() { 32 this.ActualValue = new ConstrainedValue(null, null, null, true); 33 this.IsOptimizable = false; 34 } 30 #region Constructors and Cloning 35 31 [StorableConstructor] 36 32 protected NullValueConfiguration(bool deserializing) : base(deserializing) { } … … 38 34 : base(original, cloner) { 39 35 } 36 public NullValueConfiguration() 37 : base() { 38 this.ActualValue = new ConstrainedValue(null, null, null, true); 39 this.IsOptimizable = false; 40 } 40 41 public override IDeepCloneable Clone(Cloner cloner) { 41 42 return new NullValueConfiguration(this, cloner); 42 43 } 44 #endregion 43 45 44 46 public override string ToString() { -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/ParameterizedValueConfiguration.cs
r8517 r8535 83 83 [StorableConstructor] 84 84 protected ParameterizedValueConfiguration(bool deserializing) : base(deserializing) { } 85 public ParameterizedValueConfiguration() { 85 protected ParameterizedValueConfiguration(ParameterizedValueConfiguration original, Cloner cloner) 86 : base(original, cloner) { 87 this.discoverValidValues = original.discoverValidValues; 88 this.ParameterConfigurations = cloner.Clone(original.parameterConfigurations); 89 } 90 public ParameterizedValueConfiguration() 91 : base() { 86 92 this.ParameterConfigurations = new ItemList<IParameterConfiguration>(); 87 93 } … … 89 95 : base(value, valueDataType) { 90 96 this.discoverValidValues = discoverValidValues; 91 }92 protected ParameterizedValueConfiguration(ParameterizedValueConfiguration original, Cloner cloner)93 : base(original, cloner) {94 this.discoverValidValues = original.discoverValidValues;95 this.ParameterConfigurations = cloner.Clone(original.parameterConfigurations);96 97 } 97 98 public override IDeepCloneable Clone(Cloner cloner) { … … 107 108 if (valueParameter != null) { 108 109 var pc = new ParameterConfiguration(valueParameter.Name, valueParameter, discoverValidValues); 110 pc.CombinationsCountChanged += (sender, args) => OnCombinationsCountChanged(); 109 111 this.parameterConfigurations.Add(pc); 110 112 } -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/RangeValueConfiguration.cs
r8517 r8535 46 46 [StorableConstructor] 47 47 protected RangeValueConfiguration(bool deserializing) : base(deserializing) { } 48 public RangeValueConfiguration() {49 50 }51 48 protected RangeValueConfiguration(RangeValueConfiguration original, Cloner cloner) 52 49 : base(original, cloner) { … … 54 51 RegisterRangeConstraintEvents(); 55 52 } 53 public RangeValueConfiguration() : base() { } 56 54 public RangeValueConfiguration(IItem value, Type valueDataType) 57 55 : base(value, valueDataType) { … … 68 66 } 69 67 } 70 public override IDeepCloneable Clone(Cloner cloner) {71 return new RangeValueConfiguration(this, cloner);72 }73 68 [StorableHook(HookType.AfterDeserialization)] 74 69 private void AfterDeserialization() { 75 70 RegisterRangeConstraintEvents(); 76 71 } 72 public override IDeepCloneable Clone(Cloner cloner) { 73 return new RangeValueConfiguration(this, cloner); 74 } 77 75 #endregion 78 76 79 77 private void RegisterRangeConstraintEvents() { 80 if (this.RangeConstraint != null) this.RangeConstraint.ToStringChanged += new EventHandler(RangeConstraint_ToStringChanged); 78 if (this.RangeConstraint != null) { 79 this.RangeConstraint.ToStringChanged += new EventHandler(RangeConstraint_ToStringChanged); 80 this.RangeConstraint.LowerBoundChanged += new EventHandler(RangeConstraintParametersChanged); 81 this.RangeConstraint.UpperBoundChanged += new EventHandler(RangeConstraintParametersChanged); 82 this.RangeConstraint.StepSizeChanged += new EventHandler(RangeConstraintParametersChanged); 83 } 81 84 } 85 82 86 private void DeregisterRangeConstraintEvents() { 83 if (this.RangeConstraint != null) this.RangeConstraint.ToStringChanged -= new EventHandler(RangeConstraint_ToStringChanged); 87 if (this.RangeConstraint != null) { 88 this.RangeConstraint.ToStringChanged -= new EventHandler(RangeConstraint_ToStringChanged); 89 this.RangeConstraint.LowerBoundChanged -= new EventHandler(RangeConstraintParametersChanged); 90 this.RangeConstraint.UpperBoundChanged -= new EventHandler(RangeConstraintParametersChanged); 91 this.RangeConstraint.StepSizeChanged -= new EventHandler(RangeConstraintParametersChanged); 92 } 84 93 } 85 94 … … 119 128 OnToStringChanged(); 120 129 } 130 private void RangeConstraintParametersChanged(object sender, EventArgs e) { 131 OnCombinationsCountChanged(); 132 } 121 133 #endregion 122 134 } -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/ValueConfiguration.cs
r8524 r8535 61 61 optimize = value; 62 62 OnOptimizeChanged(); 63 OnCombinationsCountChanged(); 63 64 OnToStringChanged(); 64 65 } … … 117 118 } 118 119 protected ValueConfiguration() : base() { } 119 protected ValueConfiguration(IItem value, Type valueDataType) { 120 protected ValueConfiguration(IItem value, Type valueDataType) 121 : base() { 120 122 this.ActualValue = new ConstrainedValue(value, valueDataType, new ItemSet<IItem> { value }, false); 121 123 this.IsOptimizable = true; … … 168 170 if (handler != null) handler(this, EventArgs.Empty); 169 171 } 172 173 public event EventHandler CombinationsCountChanged; 174 protected void OnCombinationsCountChanged() { 175 var handler = CombinationsCountChanged; 176 if (handler != null) handler(this, EventArgs.Empty); 177 } 170 178 #endregion 171 179
Note: See TracChangeset
for help on using the changeset viewer.