Changeset 16778 for branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs
- Timestamp:
- 04/12/19 13:09:17 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs
r16777 r16778 25 25 public IntervalConstraintView() { 26 26 InitializeComponent(); 27 int [] items = {1, 2, 3}; 27 28 expressionInput.ReadOnly = true; 28 29 definitionInput.ReadOnly = true; 29 30 derivationInput.Enabled = false; 30 31 derivationInput.Checked = Content?.IsDerivation ?? false; 31 if (Content != null && !Content.IsDerivation) 32 numberderivationInput.ReadOnly = true; 32 numberderivationInput.DataSource = items; 33 33 } 34 34 … … 85 85 derivationInput.Checked = Content.IsDerivation; 86 86 variableInput.Text = Content.Variable; 87 numberderivationInput.Text = Content.NumberOfDerivation.ToString(); 87 if (!Content.IsDerivation) { 88 numberderivationInput.Enabled = false; 89 } else { 90 numberderivationInput.Enabled = true; 91 numberderivationInput.SelectedItem = Content.NumberOfDerivation; 92 } 88 93 ischeckedCheckBox.Checked = Content.IsChecked; 89 //Content.Changed += Content_Changed; 90 94 Content.Changed += Content_Changed; 91 95 } 92 96 SetEnabledStateOfControls(); … … 104 108 (Content.InclusiveUpperBound) ? "]" : "["); 105 109 } else { 106 expression = string.Format("\u2202 Target/\u2202{0} in {1}{2} .. {3}{4}",110 expression = string.Format("\u2202{5}Target/\u2202{0}{6} in {1}{2} .. {3}{4}", 107 111 Content.Variable, 108 112 (Content.InclusiveLowerBound) ? "[" : "]", 109 113 Content.Interval.LowerBound, 110 114 Content.Interval.UpperBound, 111 (Content.InclusiveUpperBound) ? "]" : "["); 115 (Content.InclusiveUpperBound) ? "]" : "[", 116 PrintNumberOfDerivation(Content.numberOfDerivation), 117 PrintNumberOfDerivation(Content.numberOfDerivation)); 112 118 } 113 119 … … 117 123 } 118 124 125 private string PrintNumberOfDerivation(int derivation) { 126 switch (derivation) { 127 case 1: 128 return ""; 129 case 2: 130 return "²"; 131 case 3: 132 return "³"; 133 default: 134 return ""; 135 } 136 } 137 119 138 #endregion 120 139 121 140 #region control event handlers 122 123 private void numberderivationInput_Validating(object sender, CancelEventArgs e) {124 if (int.TryParse(numberderivationInput.Text, out var derivation)) {125 if (derivation >= 0) {126 errorProvider.SetError(numberderivationInput, string.Empty);127 e.Cancel = false;128 } else {129 errorProvider.SetError(numberderivationInput, "Invalid Input: Derivation must be positive!");130 e.Cancel = true;131 }132 } else {133 errorProvider.SetError(numberderivationInput, "Invalid Input: Derivation must be an integer!");134 e.Cancel = true;135 }136 }137 138 private void numberderivationInput_Validated(object sender, EventArgs e) {139 if (int.TryParse(numberderivationInput.Text, out var derivation)) {140 Content.NumberOfDerivation = derivation;141 UpdateExpression();142 }143 }144 145 141 private void lowerboundInput_Validating(object sender, CancelEventArgs e) { 146 142 var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput); … … 212 208 } 213 209 210 private void numberderivationInput_SelectedIndexChanged(object sender, EventArgs e) { 211 if ((int)numberderivationInput.SelectedItem == 1) 212 Content.numberOfDerivation = 1; 213 else if ((int)numberderivationInput.SelectedItem == 2) 214 Content.numberOfDerivation = 2; 215 else if ((int)numberderivationInput.SelectedItem == 3) 216 Content.numberOfDerivation = 3; 217 218 UpdateExpression(); 219 } 220 214 221 #endregion 215 222 … … 221 228 222 229 #endregion 230 231 223 232 } 224 233 }
Note: See TracChangeset
for help on using the changeset viewer.