Ignore:
Timestamp:
04/23/19 10:21:59 (5 months ago)
Author:
chaider
Message:

#2971 Changed some views

File:
1 edited

Legend:

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

    r16830 r16862  
    2929  [View("Interval Constraint Detail View")]
    3030  [Content(typeof(IntervalConstraint), true)]
    31   public partial class IntervalConstraintView : ItemView {
     31  public sealed partial class IntervalConstraintView : ItemView {
    3232
    3333    public new IntervalConstraint Content {
     
    4141      expressionInput.ReadOnly = true;
    4242      definitionInput.ReadOnly = true;
    43       derivationInput.Enabled = false;
    44       derivationInput.Checked = false;
    4543      numberderivationInput.DataSource = items;
    4644    }
     
    5755
    5856    protected override void DeregisterContentEvents() {
     57      Content.Changed -= new EventHandler(Content_Changed);
    5958      base.DeregisterContentEvents();
    60       Content.Changed -= new EventHandler(Content_Changed);
    6159    }
    6260
    6361    protected override void SetEnabledStateOfControls() {
    6462      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;
    6669    }
    6770
     
    7073    #region helpers
    7174
    72     private double ParseDoubleValue(string input, Control control) {
     75    private static double ParseDoubleValue(string input, Control control, ErrorProvider errorProvider) {
    7376      input = input.ToLower();
    7477      switch (input) {
     
    8184          return double.NegativeInfinity;
    8285        default: {
    83           if (double.TryParse(input, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
     86          if (double.TryParse(input, out var value))
    8487            return value;
    8588          else {
     
    98101        incllowerboundInput.Checked = true;
    99102        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;
    100116      } 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;
    119124    }
    120125
     
    136141          constraint.Interval.UpperBound,
    137142          (constraint.InclusiveUpperBound) ? "]" : "[",
    138           PrintNumberOfDerivation(constraint.numberOfDerivation),
    139           PrintNumberOfDerivation(constraint.numberOfDerivation));
     143          GetDerivationString(constraint.numberOfDerivation),
     144          GetDerivationString(constraint.numberOfDerivation));
    140145      }
    141146
     
    143148    }
    144149
    145     private static string PrintNumberOfDerivation(int derivation) {
     150    private static string GetDerivationString(int derivation) {
    146151      switch (derivation) {
    147152        case 1:
     
    160165    #region control event handlers
    161166    private void lowerboundInput_Validating(object sender, CancelEventArgs e) {
    162       var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput);
     167      var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput, this.errorProvider);
    163168      if (double.IsNaN(value)) {
    164169        errorProvider.SetError(lowerboundInput, "Invalid Input: Lowerbound must be a double value!");
     
    178183
    179184    private void lowerboundInput_Validated(object sender, EventArgs e) {
    180       var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput);
     185      var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput, this.errorProvider);
    181186      if (!double.IsNaN(value)) {
    182187        Content.Interval = new Interval(value, Content.Interval.UpperBound);
     
    188193
    189194    private void upperboundInput_Validating(object sender, CancelEventArgs e) {
    190       var value = ParseDoubleValue(upperboundInput.Text, upperboundInput);
     195      var value = ParseDoubleValue(upperboundInput.Text, upperboundInput, this.errorProvider);
    191196      if (double.IsNaN(value)) {
    192197        errorProvider.SetError(upperboundInput, "Invalid Input: Upperbound must be a double value!");
     
    206211
    207212    private void upperboundInput_Validated(object sender, EventArgs e) {
    208       var value = ParseDoubleValue(upperboundInput.Text, upperboundInput);
     213      var value = ParseDoubleValue(upperboundInput.Text, upperboundInput, this.errorProvider);
    209214      if (!double.IsNaN(value)) {
    210215        Content.Interval = new Interval(Content.Interval.LowerBound, value);
     
    216221
    217222    private void incllowerboundInput_CheckedChanged(object sender, EventArgs e) {
    218       if (Content.InclusiveLowerBound != incllowerboundInput.Checked) {
    219223        Content.InclusiveLowerBound = incllowerboundInput.Checked;
    220224        var exp = UpdateExpression(Content);
    221225        Content.Name = exp;
    222226        Content.Expression = exp;
    223       }
    224      
    225      
    226227    }
    227228
    228229    private void inclupperboundInput_CheckedChanged(object sender, EventArgs e) {
    229       if (Content.InclusiveUpperBound != inclupperboundInput.Checked) {
    230230        Content.InclusiveUpperBound = inclupperboundInput.Checked;
    231231        var exp = UpdateExpression(Content);
    232232        Content.Name = exp;
    233233        Content.Expression = exp;
    234       }
    235234    }
    236235
    237236    private void ischeckedCheckBox_CheckedChanged(object sender, EventArgs e) {
    238       if (Content.Enabled != ischeckedCheckBox.Checked) {
    239237        Content.Enabled = ischeckedCheckBox.Checked;
    240         //UpdateControls();
    241       }
    242238    }
    243239
     
    262258      UpdateControls();
    263259    }
    264 
    265 
    266260    #endregion
    267 
    268261  }
    269262}
Note: See TracChangeset for help on using the changeset viewer.