Changeset 16872 for trunk/HeuristicLab.Parameters
- Timestamp:
- 04/29/19 15:00:56 (6 years ago)
- Location:
- trunk/HeuristicLab.Parameters/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs
r16565 r16872 22 22 using System; 23 23 using System.Drawing; 24 using HEAL.Attic; 24 25 using HeuristicLab.Collections; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 using HEAL.Attic;28 28 29 29 namespace HeuristicLab.Parameters { … … 40 40 } 41 41 } 42 42 43 43 [Storable] 44 44 private ItemSet<T> validValues; … … 52 52 get { return this.value; } 53 53 set { 54 if (ReadOnly) throw new InvalidOperationException("Cannot set the value of a readonly parameter."); 54 55 if (value != this.value) { 55 56 if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value."); … … 74 75 } 75 76 77 [Storable(DefaultValue = false)] 78 private bool readOnly; 79 public bool ReadOnly { 80 get { return readOnly; } 81 set { 82 if (value == readOnly) return; 83 readOnly = value; 84 OnReadOnlyChanged(); 85 } 86 } 87 76 88 [Storable(DefaultValue = true)] 77 89 private bool getsCollected; … … 93 105 validValues = cloner.Clone(original.validValues); 94 106 value = cloner.Clone(original.value); 107 readOnly = original.readOnly; 95 108 getsCollected = original.getsCollected; 96 109 Initialize(); … … 99 112 : base("Anonymous", typeof(T)) { 100 113 this.validValues = new ItemSet<T>(); 114 this.readOnly = false; 101 115 this.getsCollected = true; 102 116 Initialize(); … … 105 119 : base(name, typeof(T)) { 106 120 this.validValues = new ItemSet<T>(); 121 this.readOnly = false; 107 122 this.getsCollected = true; 108 123 Initialize(); … … 111 126 : base(name, typeof(T)) { 112 127 this.validValues = new ItemSet<T>(); 128 this.readOnly = false; 113 129 this.getsCollected = getsCollected; 114 130 Initialize(); … … 117 133 : base(name, typeof(T)) { 118 134 this.validValues = validValues; 135 this.readOnly = false; 119 136 this.getsCollected = true; 120 137 Initialize(); … … 123 140 : base(name, typeof(T)) { 124 141 this.validValues = validValues; 142 this.readOnly = false; 125 143 this.getsCollected = getsCollected; 126 144 Initialize(); … … 130 148 this.validValues = validValues; 131 149 this.value = value; 150 this.readOnly = false; 132 151 this.getsCollected = true; 133 152 Initialize(); … … 137 156 this.validValues = validValues; 138 157 this.value = value; 158 this.readOnly = false; 139 159 this.getsCollected = getsCollected; 140 160 Initialize(); … … 143 163 : base(name, description, typeof(T)) { 144 164 this.validValues = new ItemSet<T>(); 165 this.readOnly = false; 145 166 this.getsCollected = true; 146 167 Initialize(); … … 149 170 : base(name, description, typeof(T)) { 150 171 this.validValues = new ItemSet<T>(); 172 this.readOnly = false; 151 173 this.getsCollected = getsCollected; 152 174 Initialize(); … … 155 177 : base(name, description, typeof(T)) { 156 178 this.validValues = validValues; 179 this.readOnly = false; 157 180 this.getsCollected = true; 158 181 Initialize(); … … 161 184 : base(name, description, typeof(T)) { 162 185 this.validValues = validValues; 186 this.readOnly = false; 163 187 this.getsCollected = getsCollected; 164 188 Initialize(); … … 168 192 this.validValues = validValues; 169 193 this.value = value; 194 this.readOnly = false; 170 195 this.getsCollected = true; 171 196 Initialize(); … … 175 200 this.validValues = validValues; 176 201 this.value = value; 202 this.readOnly = false; 177 203 this.getsCollected = getsCollected; 178 204 Initialize(); … … 212 238 OnToStringChanged(); 213 239 } 240 public event EventHandler ReadOnlyChanged; 241 protected virtual void OnReadOnlyChanged() { 242 EventHandler handler = ReadOnlyChanged; 243 if (handler != null) handler(this, EventArgs.Empty); 244 } 214 245 public event EventHandler GetsCollectedChanged; 215 246 protected virtual void OnGetsCollectedChanged() { -
trunk/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs
r16565 r16872 22 22 using System; 23 23 using System.Drawing; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 using HEAL.Attic;27 27 28 28 namespace HeuristicLab.Parameters { … … 45 45 get { return this.value; } 46 46 set { 47 if (ReadOnly) throw new InvalidOperationException("Cannot set the value of a readonly parameter."); 47 48 if (value != this.value) { 48 49 DeregisterValueEvents(); … … 63 64 ); 64 65 Value = val; 66 } 67 } 68 69 [Storable(DefaultValue = false)] 70 private bool readOnly; 71 public bool ReadOnly { 72 get { return readOnly; } 73 set { 74 if (value == readOnly) return; 75 readOnly = value; 76 OnReadOnlyChanged(); 65 77 } 66 78 } … … 108 120 : base(original, cloner) { 109 121 value = cloner.Clone(original.value); 122 readOnly = original.readOnly; 110 123 getsCollected = original.getsCollected; 111 124 reactOnValueToStringChangedAndValueItemImageChanged = original.reactOnValueToStringChangedAndValueItemImageChanged; … … 114 127 public OptionalValueParameter() 115 128 : base("Anonymous", typeof(T)) { 129 this.readOnly = false; 116 130 this.getsCollected = true; 117 131 this.reactOnValueToStringChangedAndValueItemImageChanged = true; … … 119 133 public OptionalValueParameter(string name) 120 134 : base(name, typeof(T)) { 135 this.readOnly = false; 121 136 this.getsCollected = true; 122 137 this.reactOnValueToStringChangedAndValueItemImageChanged = true; … … 124 139 public OptionalValueParameter(string name, bool getsCollected) 125 140 : base(name, typeof(T)) { 141 this.readOnly = false; 126 142 this.getsCollected = getsCollected; 127 143 this.reactOnValueToStringChangedAndValueItemImageChanged = true; … … 130 146 : base(name, typeof(T)) { 131 147 this.value = value; 148 this.readOnly = false; 132 149 this.getsCollected = true; 133 150 this.reactOnValueToStringChangedAndValueItemImageChanged = true; … … 137 154 : base(name, typeof(T)) { 138 155 this.value = value; 156 this.readOnly = false; 139 157 this.getsCollected = getsCollected; 140 158 this.reactOnValueToStringChangedAndValueItemImageChanged = true; … … 143 161 public OptionalValueParameter(string name, string description) 144 162 : base(name, description, typeof(T)) { 163 this.readOnly = false; 145 164 this.getsCollected = true; 146 165 this.reactOnValueToStringChangedAndValueItemImageChanged = true; … … 148 167 public OptionalValueParameter(string name, string description, bool getsCollected) 149 168 : base(name, description, typeof(T)) { 169 this.readOnly = false; 150 170 this.getsCollected = getsCollected; 151 171 this.reactOnValueToStringChangedAndValueItemImageChanged = true; … … 154 174 : base(name, description, typeof(T)) { 155 175 this.value = value; 176 this.readOnly = false; 156 177 this.getsCollected = true; 157 178 this.reactOnValueToStringChangedAndValueItemImageChanged = true; … … 161 182 : base(name, description, typeof(T)) { 162 183 this.value = value; 184 this.readOnly = false; 163 185 this.getsCollected = getsCollected; 164 186 this.reactOnValueToStringChangedAndValueItemImageChanged = true; … … 197 219 OnToStringChanged(); 198 220 } 221 222 public event EventHandler ReadOnlyChanged; 223 protected virtual void OnReadOnlyChanged() { 224 EventHandler handler = ReadOnlyChanged; 225 if (handler != null) handler(this, EventArgs.Empty); 226 } 199 227 public event EventHandler GetsCollectedChanged; 200 228 protected virtual void OnGetsCollectedChanged() { -
trunk/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs
r16565 r16872 22 22 using System; 23 23 using System.Drawing; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 using HEAL.Attic;27 27 28 28 namespace HeuristicLab.Parameters { … … 45 45 get { return this.value; } 46 46 set { 47 if (ReadOnly) throw new InvalidOperationException("Cannot set the value of a readonly parameter."); 47 48 if (value != this.value) { 48 49 DeregisterValueEvents(); … … 66 67 } 67 68 69 [Storable(DefaultValue = false)] 70 private bool readOnly; 71 public bool ReadOnly { 72 get { return readOnly; } 73 set { 74 if (value == readOnly) return; 75 readOnly = value; 76 OnReadOnlyChanged(); 77 } 78 } 79 68 80 [Storable(DefaultValue = true)] 69 81 private bool getsCollected; … … 84 96 : base(original, cloner) { 85 97 value = cloner.Clone(original.value); 98 readOnly = original.readOnly; 86 99 getsCollected = original.getsCollected; 87 100 RegisterValueEvents(); … … 89 102 public ValueLookupParameter() 90 103 : base() { 104 this.readOnly = false; 91 105 this.Hidden = false; 92 106 this.getsCollected = true; … … 94 108 public ValueLookupParameter(string name) 95 109 : base(name) { 110 this.readOnly = false; 96 111 this.Hidden = false; 97 112 this.getsCollected = true; … … 99 114 public ValueLookupParameter(string name, bool getsCollected) 100 115 : base(name) { 116 this.readOnly = false; 101 117 this.Hidden = false; 102 118 this.getsCollected = getsCollected; … … 105 121 : base(name) { 106 122 this.value = value; 123 this.readOnly = false; 107 124 this.Hidden = false; 108 125 this.getsCollected = true; … … 112 129 : base(name) { 113 130 this.value = value; 131 this.readOnly = false; 114 132 this.Hidden = false; 115 133 this.getsCollected = getsCollected; … … 118 136 public ValueLookupParameter(string name, string description) 119 137 : base(name, description) { 138 this.readOnly = false; 120 139 this.Hidden = false; 121 140 this.getsCollected = true; … … 123 142 public ValueLookupParameter(string name, string description, bool getsCollected) 124 143 : base(name, description) { 144 this.readOnly = false; 125 145 this.Hidden = false; 126 146 this.getsCollected = getsCollected; … … 129 149 : base(name, description) { 130 150 this.value = value; 151 this.readOnly = false; 131 152 this.Hidden = false; 132 153 this.getsCollected = true; … … 136 157 : base(name, description) { 137 158 this.value = value; 159 this.readOnly = false; 138 160 this.Hidden = false; 139 161 this.getsCollected = getsCollected; … … 142 164 public ValueLookupParameter(string name, string description, string actualName) 143 165 : base(name, description, actualName) { 166 this.readOnly = false; 144 167 this.Hidden = false; 145 168 this.getsCollected = true; … … 147 170 public ValueLookupParameter(string name, string description, string actualName, bool getsCollected) 148 171 : base(name, description, actualName) { 172 this.readOnly = false; 149 173 this.Hidden = false; 150 174 this.getsCollected = getsCollected; … … 177 201 OnToStringChanged(); 178 202 } 203 public event EventHandler ReadOnlyChanged; 204 protected virtual void OnReadOnlyChanged() { 205 EventHandler handler = ReadOnlyChanged; 206 if (handler != null) handler(this, EventArgs.Empty); 207 } 179 208 public event EventHandler GetsCollectedChanged; 180 209 protected virtual void OnGetsCollectedChanged() {
Note: See TracChangeset
for help on using the changeset viewer.