Changeset 16862 for branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs
- Timestamp:
- 04/23/19 10:21:59 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs
r16830 r16862 29 29 [View("Interval Constraint Detail View")] 30 30 [Content(typeof(IntervalConstraint), true)] 31 public partial class IntervalConstraintView : ItemView {31 public sealed partial class IntervalConstraintView : ItemView { 32 32 33 33 public new IntervalConstraint Content { … … 41 41 expressionInput.ReadOnly = true; 42 42 definitionInput.ReadOnly = true; 43 derivationInput.Enabled = false;44 derivationInput.Checked = false;45 43 numberderivationInput.DataSource = items; 46 44 } … … 57 55 58 56 protected override void DeregisterContentEvents() { 57 Content.Changed -= new EventHandler(Content_Changed); 59 58 base.DeregisterContentEvents(); 60 Content.Changed -= new EventHandler(Content_Changed);61 59 } 62 60 63 61 protected override void SetEnabledStateOfControls() { 64 62 base.SetEnabledStateOfControls(); 65 lowerboundInput.Enabled = Content != null && !Locked; 63 lowerboundInput.Enabled = Content != null && !Locked && !ReadOnly; 64 upperboundInput.Enabled = Content != null && !Locked && !ReadOnly; 65 expressionInput.Enabled = Content != null && !Locked && !ReadOnly; 66 definitionInput.Enabled = Content != null && !Locked && !ReadOnly; 67 definitionInput.ReadOnly = true; 68 expressionInput.ReadOnly = true; 66 69 } 67 70 … … 70 73 #region helpers 71 74 72 private double ParseDoubleValue(string input, Control control) {75 private static double ParseDoubleValue(string input, Control control, ErrorProvider errorProvider) { 73 76 input = input.ToLower(); 74 77 switch (input) { … … 81 84 return double.NegativeInfinity; 82 85 default: { 83 if (double.TryParse(input, NumberStyles.Any, CultureInfo.InvariantCulture,out var value))86 if (double.TryParse(input, out var value)) 84 87 return value; 85 88 else { … … 98 101 incllowerboundInput.Checked = true; 99 102 inclupperboundInput.Checked = true; 103 return; 104 } 105 106 expressionInput.Text = Content.Expression; 107 definitionInput.Text = Content.Definition; 108 lowerboundInput.Text = Content.Interval.LowerBound.ToString(); 109 upperboundInput.Text = Content.Interval.UpperBound.ToString(); 110 incllowerboundInput.Checked = Content.InclusiveLowerBound; 111 inclupperboundInput.Checked = Content.InclusiveUpperBound; 112 variableInput.Text = Content.Variable; 113 if (!Content.IsDerivation) { 114 numberderivationInput.Visible = false; 115 numberderivationLabel.Visible = false; 100 116 } else { 101 expressionInput.Text = Content.Expression; 102 definitionInput.Text = Content.Definition; 103 lowerboundInput.Text = Content.Interval.LowerBound.ToString(CultureInfo.InvariantCulture); 104 upperboundInput.Text = Content.Interval.UpperBound.ToString(CultureInfo.InvariantCulture); 105 incllowerboundInput.Checked = Content.InclusiveLowerBound; 106 inclupperboundInput.Checked = Content.InclusiveUpperBound; 107 derivationInput.Checked = Content.IsDerivation; 108 variableInput.Text = Content.Variable; 109 if (!Content.IsDerivation) { 110 numberderivationInput.Enabled = false; 111 } else { 112 numberderivationInput.Enabled = true; 113 numberderivationInput.SelectedItem = Content.NumberOfDerivation; 114 } 115 116 ischeckedCheckBox.Checked = Content.Enabled; 117 } 118 SetEnabledStateOfControls(); 117 numberderivationLabel.Visible = true; 118 numberderivationInput.Visible = true; 119 numberderivationInput.Enabled = true; 120 numberderivationInput.SelectedItem = Content.NumberOfDerivation; 121 } 122 123 ischeckedCheckBox.Checked = Content.Enabled; 119 124 } 120 125 … … 136 141 constraint.Interval.UpperBound, 137 142 (constraint.InclusiveUpperBound) ? "]" : "[", 138 PrintNumberOfDerivation(constraint.numberOfDerivation),139 PrintNumberOfDerivation(constraint.numberOfDerivation));143 GetDerivationString(constraint.numberOfDerivation), 144 GetDerivationString(constraint.numberOfDerivation)); 140 145 } 141 146 … … 143 148 } 144 149 145 private static string PrintNumberOfDerivation(int derivation) {150 private static string GetDerivationString(int derivation) { 146 151 switch (derivation) { 147 152 case 1: … … 160 165 #region control event handlers 161 166 private void lowerboundInput_Validating(object sender, CancelEventArgs e) { 162 var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput );167 var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput, this.errorProvider); 163 168 if (double.IsNaN(value)) { 164 169 errorProvider.SetError(lowerboundInput, "Invalid Input: Lowerbound must be a double value!"); … … 178 183 179 184 private void lowerboundInput_Validated(object sender, EventArgs e) { 180 var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput );185 var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput, this.errorProvider); 181 186 if (!double.IsNaN(value)) { 182 187 Content.Interval = new Interval(value, Content.Interval.UpperBound); … … 188 193 189 194 private void upperboundInput_Validating(object sender, CancelEventArgs e) { 190 var value = ParseDoubleValue(upperboundInput.Text, upperboundInput );195 var value = ParseDoubleValue(upperboundInput.Text, upperboundInput, this.errorProvider); 191 196 if (double.IsNaN(value)) { 192 197 errorProvider.SetError(upperboundInput, "Invalid Input: Upperbound must be a double value!"); … … 206 211 207 212 private void upperboundInput_Validated(object sender, EventArgs e) { 208 var value = ParseDoubleValue(upperboundInput.Text, upperboundInput );213 var value = ParseDoubleValue(upperboundInput.Text, upperboundInput, this.errorProvider); 209 214 if (!double.IsNaN(value)) { 210 215 Content.Interval = new Interval(Content.Interval.LowerBound, value); … … 216 221 217 222 private void incllowerboundInput_CheckedChanged(object sender, EventArgs e) { 218 if (Content.InclusiveLowerBound != incllowerboundInput.Checked) {219 223 Content.InclusiveLowerBound = incllowerboundInput.Checked; 220 224 var exp = UpdateExpression(Content); 221 225 Content.Name = exp; 222 226 Content.Expression = exp; 223 }224 225 226 227 } 227 228 228 229 private void inclupperboundInput_CheckedChanged(object sender, EventArgs e) { 229 if (Content.InclusiveUpperBound != inclupperboundInput.Checked) {230 230 Content.InclusiveUpperBound = inclupperboundInput.Checked; 231 231 var exp = UpdateExpression(Content); 232 232 Content.Name = exp; 233 233 Content.Expression = exp; 234 }235 234 } 236 235 237 236 private void ischeckedCheckBox_CheckedChanged(object sender, EventArgs e) { 238 if (Content.Enabled != ischeckedCheckBox.Checked) {239 237 Content.Enabled = ischeckedCheckBox.Checked; 240 //UpdateControls();241 }242 238 } 243 239 … … 262 258 UpdateControls(); 263 259 } 264 265 266 260 #endregion 267 268 261 } 269 262 }
Note: See TracChangeset
for help on using the changeset viewer.