Changeset 16872
- Timestamp:
- 04/29/19 15:00:56 (6 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Core/3.3/Interfaces/IValueParameter.cs
r16565 r16872 27 27 public interface IValueParameter : IParameter { 28 28 IItem Value { get; set; } 29 bool ReadOnly { get; set; } 29 30 bool GetsCollected { get; set; } 30 31 event EventHandler ValueChanged; 32 event EventHandler ReadOnlyChanged; 31 33 event EventHandler GetsCollectedChanged; 32 34 } -
trunk/HeuristicLab.Parameters.Views/3.3/ConstrainedValueParameterView.cs
r16565 r16872 62 62 protected override void DeregisterContentEvents() { 63 63 Content.GetsCollectedChanged -= new EventHandler(Content_GetsCollectedChanged); 64 Content.ReadOnlyChanged -= new EventHandler(Content_ReadOnlyChanged); 64 65 Content.ValidValues.ItemsAdded -= new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded); 65 66 Content.ValidValues.ItemsRemoved -= new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved); … … 76 77 base.RegisterContentEvents(); 77 78 Content.GetsCollectedChanged += new EventHandler(Content_GetsCollectedChanged); 79 Content.ReadOnlyChanged += new EventHandler(Content_ReadOnlyChanged); 78 80 Content.ValidValues.ItemsAdded += new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded); 79 81 Content.ValidValues.ItemsRemoved += new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved); … … 100 102 base.SetEnabledStateOfControls(); 101 103 valueGroupBox.Enabled = Content != null; 102 valueComboBox.Enabled = (valueComboBox.Items.Count > 0) && ! ReadOnly;104 valueComboBox.Enabled = (valueComboBox.Items.Count > 0) && !Content.ReadOnly && !ReadOnly; 103 105 showInRunCheckBox.Enabled = Content != null && !ReadOnly; 104 106 } … … 153 155 FillValueComboBox(); 154 156 } 157 protected virtual void Content_ReadOnlyChanged(object sender, EventArgs e) { 158 if (InvokeRequired) 159 Invoke(new EventHandler(Content_ReadOnlyChanged), sender, e); 160 else { 161 SetEnabledStateOfControls(); 162 } 163 } 155 164 protected virtual void Content_GetsCollectedChanged(object sender, EventArgs e) { 156 165 if (InvokeRequired) -
trunk/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.cs
r16565 r16872 74 74 Content.ActualNameChanged -= new EventHandler(Content_ActualNameChanged); 75 75 Content.GetsCollectedChanged -= new EventHandler(Content_GetsCollectedChanged); 76 Content.ReadOnlyChanged -= new EventHandler(Content_ReadOnlyChanged); 76 77 Content.ValueChanged -= new EventHandler(Content_ValueChanged); 77 78 base.DeregisterContentEvents(); … … 86 87 Content.ActualNameChanged += new EventHandler(Content_ActualNameChanged); 87 88 Content.GetsCollectedChanged += new EventHandler(Content_GetsCollectedChanged); 89 Content.ReadOnlyChanged += new EventHandler(Content_ReadOnlyChanged); 88 90 Content.ValueChanged += new EventHandler(Content_ValueChanged); 89 91 } … … 108 110 actualNameTextBox.Enabled = Content != null; 109 111 actualNameTextBox.ReadOnly = ReadOnly; 110 setValueButton.Enabled = Content != null && ! ReadOnly;111 clearValueButton.Enabled = Content != null && Content.Value != null && !ReadOnly;112 setValueButton.Enabled = Content != null && !Content.ReadOnly && !ReadOnly; 113 clearValueButton.Enabled = Content != null && !Content.ReadOnly && Content.Value != null && !ReadOnly; 112 114 showInRunCheckBox.Enabled = Content != null && !ReadOnly; 113 115 } … … 124 126 else { 125 127 SetDataTypeTextBoxText(); 126 clearValueButton.Enabled = Content != null && Content.Value != null && !ReadOnly;128 clearValueButton.Enabled = Content != null && !Content.ReadOnly && Content.Value != null && !ReadOnly; 127 129 valueViewHost.ViewType = null; 128 130 valueViewHost.Content = Content != null ? Content.Value : null; 131 } 132 } 133 protected virtual void Content_ReadOnlyChanged(object sender, EventArgs e) { 134 if (InvokeRequired) 135 Invoke(new EventHandler(Content_ReadOnlyChanged), sender, e); 136 else { 137 SetEnabledStateOfControls(); 129 138 } 130 139 } -
trunk/HeuristicLab.Parameters.Views/3.3/ValueParameterView.cs
r16565 r16872 74 74 protected override void DeregisterContentEvents() { 75 75 Content.GetsCollectedChanged -= new EventHandler(Content_GetsCollectedChanged); 76 Content.ReadOnlyChanged -= new EventHandler(Content_ReadOnlyChanged); 76 77 Content.ValueChanged -= new EventHandler(Content_ValueChanged); 77 78 base.DeregisterContentEvents(); … … 85 86 base.RegisterContentEvents(); 86 87 Content.GetsCollectedChanged += new EventHandler(Content_GetsCollectedChanged); 88 Content.ReadOnlyChanged += new EventHandler(Content_ReadOnlyChanged); 87 89 Content.ValueChanged += new EventHandler(Content_ValueChanged); 88 90 } … … 103 105 protected override void SetEnabledStateOfControls() { 104 106 base.SetEnabledStateOfControls(); 105 setValueButton.Enabled = Content != null && ! (Content is IFixedValueParameter) && !ReadOnly;106 clearValueButton.Enabled = Content != null && Content.Value != null && !(Content is IFixedValueParameter) && !(Content is ValueParameter<T>) && !ReadOnly;107 setValueButton.Enabled = Content != null && !Content.ReadOnly && !(Content is IFixedValueParameter) && !ReadOnly; 108 clearValueButton.Enabled = Content != null && !Content.ReadOnly && Content.Value != null && !(Content is IFixedValueParameter) && !(Content is ValueParameter<T>) && !ReadOnly; 107 109 showInRunCheckBox.Enabled = Content != null && !ReadOnly; 108 110 } … … 113 115 else { 114 116 SetDataTypeTextBoxText(); 115 setValueButton.Enabled = Content != null && ! (Content is IFixedValueParameter) && !ReadOnly;116 clearValueButton.Enabled = Content != null && Content.Value != null && !(Content is IFixedValueParameter<T>) && !(Content is ValueParameter<T>) && !ReadOnly;117 setValueButton.Enabled = Content != null && !Content.ReadOnly && !(Content is IFixedValueParameter) && !ReadOnly; 118 clearValueButton.Enabled = Content != null && !Content.ReadOnly && Content.Value != null && !(Content is IFixedValueParameter<T>) && !(Content is ValueParameter<T>) && !ReadOnly; 117 119 valueViewHost.ViewType = null; 118 120 valueViewHost.Content = Content != null ? Content.Value : null; 121 } 122 } 123 124 protected virtual void Content_ReadOnlyChanged(object sender, EventArgs e) { 125 if (InvokeRequired) 126 Invoke(new EventHandler(Content_ReadOnlyChanged), sender, e); 127 else { 128 SetEnabledStateOfControls(); 119 129 } 120 130 } … … 135 145 try { 136 146 Content.Value = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 137 } 138 catch (Exception ex) { 147 } catch (Exception ex) { 139 148 ErrorHandling.ShowErrorDialog(this, ex); 140 149 } -
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.