Changeset 3341 for trunk/sources/HeuristicLab.Parameters
- Timestamp:
- 04/14/10 05:09:59 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Parameters/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Parameters/3.3/ConstrainedValueParameter.cs
r3017 r3341 49 49 public ConstrainedValueParameter(string name, string description, ItemSet<T> validValues, T value) : base(name, description, validValues, value) { } 50 50 51 protected override void validValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) {51 protected override void ValidValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) { 52 52 if (Value == null) Value = ValidValues.First(); 53 53 } -
trunk/sources/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs
r3317 r3341 21 21 22 22 using System; 23 using System.Drawing; 23 24 using HeuristicLab.Collections; 24 25 using HeuristicLab.Common; … … 33 34 [StorableClass] 34 35 public class OptionalConstrainedValueParameter<T> : Parameter, IValueParameter<T> where T : class, IItem { 36 public override Image ItemImage { 37 get { 38 if (value != null) return value.ItemImage; 39 else return base.ItemImage; 40 } 41 } 42 35 43 [Storable] 36 44 private ItemSet<T> validValues; … … 46 54 if (value != this.value) { 47 55 if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value."); 48 if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);56 DeregisterValueEvents(); 49 57 this.value = value; 50 if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);58 RegisterValueEvents(); 51 59 OnValueChanged(); 52 60 } … … 110 118 private void Initialize() { 111 119 RegisterValidValuesEvents(); 112 if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);120 RegisterValueEvents(); 113 121 } 114 122 … … 136 144 if (ValueChanged != null) 137 145 ValueChanged(this, EventArgs.Empty); 146 OnItemImageChanged(); 138 147 OnToStringChanged(); 139 148 } … … 141 150 private void RegisterValidValuesEvents() { 142 151 if (validValues != null) { 143 validValues.ItemsAdded += new CollectionItemsChangedEventHandler<T>( validValues_ItemsAdded);152 validValues.ItemsAdded += new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded); 144 153 validValues.ItemsRemoved += new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved); 145 154 validValues.CollectionReset += new CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset); 146 155 } 147 156 } 148 149 157 private void DeregisterValidValuesEvents() { 150 158 if (validValues != null) { 151 validValues.ItemsAdded -= new CollectionItemsChangedEventHandler<T>( validValues_ItemsAdded);159 validValues.ItemsAdded -= new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded); 152 160 validValues.ItemsRemoved -= new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved); 153 161 validValues.CollectionReset -= new CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset); 154 162 } 155 163 } 156 157 protected virtual void validValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) { } 164 protected virtual void ValidValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) { } 158 165 protected virtual void ValidValues_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<T> e) { 159 166 if ((Value != null) && !validValues.Contains(Value)) Value = null; … … 162 169 if ((Value != null) && !validValues.Contains(Value)) Value = null; 163 170 } 164 protected virtual void Value_ToStringChanged(object sender, EventArgs e) { 171 172 private void RegisterValueEvents() { 173 if (value != null) { 174 value.ItemImageChanged += new EventHandler(Value_ItemImageChanged); 175 value.ToStringChanged += new EventHandler(Value_ToStringChanged); 176 } 177 } 178 private void DeregisterValueEvents() { 179 if (value != null) { 180 value.ItemImageChanged -= new EventHandler(Value_ItemImageChanged); 181 value.ToStringChanged -= new EventHandler(Value_ToStringChanged); 182 } 183 } 184 private void Value_ItemImageChanged(object sender, EventArgs e) { 185 OnItemImageChanged(); 186 } 187 private void Value_ToStringChanged(object sender, EventArgs e) { 165 188 OnToStringChanged(); 166 189 } -
trunk/sources/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs
r3317 r3341 21 21 22 22 using System; 23 using System.Drawing; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 32 33 [StorableClass] 33 34 public class OptionalValueParameter<T> : Parameter, IValueParameter<T> where T : class, IItem { 35 public override Image ItemImage { 36 get { 37 if (value != null) return value.ItemImage; 38 else return base.ItemImage; 39 } 40 } 41 34 42 [Storable] 35 43 private T value; … … 38 46 set { 39 47 if (value != this.value) { 40 if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);48 DeregisterValueEvents(); 41 49 this.value = value; 42 if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);50 RegisterValueEvents(); 43 51 OnValueChanged(); 44 52 } … … 82 90 [StorableHook(HookType.AfterDeserialization)] 83 91 private void Initialize() { 84 if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);92 RegisterValueEvents(); 85 93 } 86 94 … … 107 115 if (ValueChanged != null) 108 116 ValueChanged(this, EventArgs.Empty); 117 OnItemImageChanged(); 109 118 OnToStringChanged(); 119 } 120 121 private void RegisterValueEvents() { 122 if (value != null) { 123 value.ItemImageChanged += new EventHandler(Value_ItemImageChanged); 124 value.ToStringChanged += new EventHandler(Value_ToStringChanged); 125 } 126 } 127 private void DeregisterValueEvents() { 128 if (value != null) { 129 value.ItemImageChanged -= new EventHandler(Value_ItemImageChanged); 130 value.ToStringChanged -= new EventHandler(Value_ToStringChanged); 131 } 132 } 133 private void Value_ItemImageChanged(object sender, EventArgs e) { 134 OnItemImageChanged(); 110 135 } 111 136 private void Value_ToStringChanged(object sender, EventArgs e) { -
trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs
r3317 r3341 21 21 22 22 using System; 23 using System.Drawing; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 32 33 [StorableClass] 33 34 public class ValueLookupParameter<T> : LookupParameter<T>, IValueLookupParameter<T> where T : class, IItem { 35 public override Image ItemImage { 36 get { 37 if (value != null) return value.ItemImage; 38 else return base.ItemImage; 39 } 40 } 41 34 42 [Storable] 35 43 private T value; … … 38 46 set { 39 47 if (value != this.value) { 40 if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);48 DeregisterValueEvents(); 41 49 this.value = value; 42 if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);50 RegisterValueEvents(); 43 51 OnValueChanged(); 44 52 } … … 85 93 [StorableHook(HookType.AfterDeserialization)] 86 94 private void Initialize() { 87 if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);95 RegisterValueEvents(); 88 96 } 89 97 … … 103 111 if (ValueChanged != null) 104 112 ValueChanged(this, EventArgs.Empty); 113 OnItemImageChanged(); 105 114 OnToStringChanged(); 115 } 116 117 private void RegisterValueEvents() { 118 if (value != null) { 119 value.ItemImageChanged += new EventHandler(Value_ItemImageChanged); 120 value.ToStringChanged += new EventHandler(Value_ToStringChanged); 121 } 122 } 123 private void DeregisterValueEvents() { 124 if (value != null) { 125 value.ItemImageChanged -= new EventHandler(Value_ItemImageChanged); 126 value.ToStringChanged -= new EventHandler(Value_ToStringChanged); 127 } 128 } 129 private void Value_ItemImageChanged(object sender, EventArgs e) { 130 OnItemImageChanged(); 106 131 } 107 132 private void Value_ToStringChanged(object sender, EventArgs e) {
Note: See TracChangeset
for help on using the changeset viewer.