Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/10/19 16:46:46 (5 years ago)
Author:
chaider
Message:

#2971 Changed Parser and IntevalConstraint View

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs

    r16772 r16774  
    2222      set { base.Content = value; }
    2323    }
     24
    2425    public IntervalConstraintView() {
    2526      InitializeComponent();
     
    2728      definitionInput.ReadOnly = true;
    2829      derivationInput.ReadOnly = true;
     30      if (derivationInput.Text == "False")
     31        numberderivationInput.ReadOnly = true;
    2932    }
    3033
     
    4649      base.OnContentChanged();
    4750      UpdateControls();
    48       UpdateValues();
    4951    }
     52
    5053
    5154    protected override void SetEnabledStateOfControls() {
     
    7881    }
    7982
    80     private void UpdateValues() {
     83    private void expressionInput_TextChanged(object sender, EventArgs e) {
    8184
     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      }
    82133    }
    83134  }
Note: See TracChangeset for help on using the changeset viewer.