Changeset 17034 for branches/2435-alglib_3_15/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs
- Timestamp:
- 06/25/19 23:14:06 (5 years ago)
- Location:
- branches/2435-alglib_3_15
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2435-alglib_3_15
- Property svn:mergeinfo changed
-
branches/2435-alglib_3_15/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs
r16565 r17034 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>(); 107 this.getsCollected = true; 108 Initialize(); 109 } 110 public OptionalConstrainedValueParameter(string name, bool getsCollected) 111 : base(name, typeof(T)) { 112 this.validValues = new ItemSet<T>(); 113 this.getsCollected = getsCollected; 121 this.readOnly = false; 122 this.getsCollected = true; 114 123 Initialize(); 115 124 } … … 117 126 : base(name, typeof(T)) { 118 127 this.validValues = validValues; 119 this.getsCollected = true; 120 Initialize(); 121 } 122 public OptionalConstrainedValueParameter(string name, ItemSet<T> validValues, bool getsCollected) 123 : base(name, typeof(T)) { 124 this.validValues = validValues; 125 this.getsCollected = getsCollected; 128 this.readOnly = false; 129 this.getsCollected = true; 126 130 Initialize(); 127 131 } … … 130 134 this.validValues = validValues; 131 135 this.value = value; 132 this.getsCollected = true; 133 Initialize(); 134 } 135 public OptionalConstrainedValueParameter(string name, ItemSet<T> validValues, T value, bool getsCollected) 136 : base(name, typeof(T)) { 137 this.validValues = validValues; 138 this.value = value; 139 this.getsCollected = getsCollected; 136 this.readOnly = false; 137 this.getsCollected = true; 140 138 Initialize(); 141 139 } … … 143 141 : base(name, description, typeof(T)) { 144 142 this.validValues = new ItemSet<T>(); 145 this.getsCollected = true; 146 Initialize(); 147 } 148 public OptionalConstrainedValueParameter(string name, string description, bool getsCollected) 149 : base(name, description, typeof(T)) { 150 this.validValues = new ItemSet<T>(); 151 this.getsCollected = getsCollected; 143 this.readOnly = false; 144 this.getsCollected = true; 152 145 Initialize(); 153 146 } … … 155 148 : base(name, description, typeof(T)) { 156 149 this.validValues = validValues; 157 this.getsCollected = true; 158 Initialize(); 159 } 160 public OptionalConstrainedValueParameter(string name, string description, ItemSet<T> validValues, bool getsCollected) 161 : base(name, description, typeof(T)) { 162 this.validValues = validValues; 163 this.getsCollected = getsCollected; 150 this.readOnly = false; 151 this.getsCollected = true; 164 152 Initialize(); 165 153 } … … 168 156 this.validValues = validValues; 169 157 this.value = value; 170 this.getsCollected = true; 171 Initialize(); 172 } 173 public OptionalConstrainedValueParameter(string name, string description, ItemSet<T> validValues, T value, bool getsCollected) 174 : base(name, description, typeof(T)) { 175 this.validValues = validValues; 176 this.value = value; 177 this.getsCollected = getsCollected; 158 this.readOnly = false; 159 this.getsCollected = true; 178 160 Initialize(); 179 161 } … … 212 194 OnToStringChanged(); 213 195 } 196 public event EventHandler ReadOnlyChanged; 197 protected virtual void OnReadOnlyChanged() { 198 EventHandler handler = ReadOnlyChanged; 199 if (handler != null) handler(this, EventArgs.Empty); 200 } 214 201 public event EventHandler GetsCollectedChanged; 215 202 protected virtual void OnGetsCollectedChanged() {
Note: See TracChangeset
for help on using the changeset viewer.