- Timestamp:
- 04/29/19 15:00:56 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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() {
Note: See TracChangeset
for help on using the changeset viewer.