Changeset 16774 for branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs
- Timestamp:
- 04/10/19 16:46:46 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs
r16772 r16774 22 22 set { base.Content = value; } 23 23 } 24 24 25 public IntervalConstraintView() { 25 26 InitializeComponent(); … … 27 28 definitionInput.ReadOnly = true; 28 29 derivationInput.ReadOnly = true; 30 if (derivationInput.Text == "False") 31 numberderivationInput.ReadOnly = true; 29 32 } 30 33 … … 46 49 base.OnContentChanged(); 47 50 UpdateControls(); 48 UpdateValues();49 51 } 52 50 53 51 54 protected override void SetEnabledStateOfControls() { … … 78 81 } 79 82 80 private void UpdateValues() {83 private void expressionInput_TextChanged(object sender, EventArgs e) { 81 84 85 } 86 87 private void variableInput_TextChanged(object sender, EventArgs e) { 88 89 } 90 91 private void numberderivationInput_TextChanged(object sender, EventArgs e) { 92 if (int.TryParse(numberderivationInput.Text, out var derivation)) { 93 if (derivation >= 0) { 94 Content.NumberOfDerivation = derivation; 95 errorProvider.SetError(numberderivationInput, string.Empty); 96 } else { 97 errorProvider.SetError(numberderivationInput, "Invalid Input: Derivation must be positive!"); 98 } 99 } else { 100 errorProvider.SetError(numberderivationInput, "Invalid Input: Derivation must be an integer!"); 101 } 102 } 103 104 private void lowerboundInput_TextChanged(object sender, EventArgs e) { 105 var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput); 106 if (!double.IsNaN(value)) { 107 if (value <= Content.Interval.UpperBound) { 108 Content.Interval = new Interval(value, Content.Interval.UpperBound); 109 errorProvider.SetError(lowerboundInput, string.Empty); 110 } else { 111 errorProvider.SetError(lowerboundInput, "Invalid Input: Lowerbound must be smaller than Upperbound!"); 112 } 113 } 114 } 115 116 private double ParseDoubleValue(string input, Control control) { 117 input = input.ToLower(); 118 switch (input) { 119 case "inf.": 120 case "+inf.": 121 return double.PositiveInfinity; 122 case "-inf.": 123 return double.NegativeInfinity; 124 default: { 125 if (double.TryParse(input, out var value)) 126 return value; 127 else { 128 errorProvider.SetError(control, "Invalid Input: Value must be a double!"); 129 return double.NaN; 130 } 131 } 132 } 82 133 } 83 134 }
Note: See TracChangeset
for help on using the changeset viewer.