Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/12/19 13:09:17 (5 years ago)
Author:
chaider
Message:

#2971

  • Changed field numberOfDerivation
  • Added numberOfDerivation to Expression string
  • Added numberOfDerivation to parser
File:
1 edited

Legend:

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

    r16777 r16778  
    2525    public IntervalConstraintView() {
    2626      InitializeComponent();
     27      int [] items = {1, 2, 3};
    2728      expressionInput.ReadOnly = true;
    2829      definitionInput.ReadOnly = true;
    2930      derivationInput.Enabled = false;
    3031      derivationInput.Checked = Content?.IsDerivation ?? false;
    31       if (Content != null && !Content.IsDerivation)
    32         numberderivationInput.ReadOnly = true;
     32      numberderivationInput.DataSource = items;
    3333    }
    3434
     
    8585        derivationInput.Checked = Content.IsDerivation;
    8686        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        }
    8893        ischeckedCheckBox.Checked = Content.IsChecked;
    89         //Content.Changed += Content_Changed;
    90 
     94        Content.Changed += Content_Changed;
    9195      }
    9296      SetEnabledStateOfControls();
     
    104108          (Content.InclusiveUpperBound) ? "]" : "[");
    105109      } else {
    106         expression = string.Format("\u2202Target/\u2202{0} in {1}{2} .. {3}{4}",
     110        expression = string.Format("\u2202{5}Target/\u2202{0}{6} in {1}{2} .. {3}{4}",
    107111          Content.Variable,
    108112          (Content.InclusiveLowerBound) ? "[" : "]",
    109113          Content.Interval.LowerBound,
    110114          Content.Interval.UpperBound,
    111           (Content.InclusiveUpperBound) ? "]" : "[");
     115          (Content.InclusiveUpperBound) ? "]" : "[",
     116          PrintNumberOfDerivation(Content.numberOfDerivation),
     117          PrintNumberOfDerivation(Content.numberOfDerivation));
    112118      }
    113119
     
    117123    }
    118124
     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
    119138    #endregion
    120139
    121140    #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 
    145141    private void lowerboundInput_Validating(object sender, CancelEventArgs e) {
    146142      var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput);
     
    212208    }
    213209
     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
    214221    #endregion
    215222
     
    221228
    222229    #endregion
     230
     231
    223232  }
    224233}
Note: See TracChangeset for help on using the changeset viewer.