Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16776


Ignore:
Timestamp:
04/12/19 07:48:00 (6 years ago)
Author:
chaider
Message:

#2971

  • Added Expression change event
  • Added errorProvider Validation
Location:
branches/2971_named_intervals
Files:
7 edited

Legend:

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

    r16774 r16776  
    2525    private void InitializeComponent() {
    2626      this.components = new System.ComponentModel.Container();
    27       this.expressionLabel = new System.Windows.Forms.Label();
    2827      this.definitionLabel = new System.Windows.Forms.Label();
    2928      this.lowerboundLabel = new System.Windows.Forms.Label();
     
    3534      this.numberderivationLabel = new System.Windows.Forms.Label();
    3635      this.definitionInput = new System.Windows.Forms.TextBox();
    37       this.expressionInput = new System.Windows.Forms.TextBox();
    3836      this.upperboundInput = new System.Windows.Forms.TextBox();
    3937      this.lowerboundInput = new System.Windows.Forms.TextBox();
    4038      this.variableInput = new System.Windows.Forms.TextBox();
    4139      this.numberderivationInput = new System.Windows.Forms.TextBox();
    42       this.upperCombo = new System.Windows.Forms.ComboBox();
    43       this.lowerCombo = new System.Windows.Forms.ComboBox();
    44       this.derivationInput = new System.Windows.Forms.TextBox();
    4540      this.groupBox1 = new System.Windows.Forms.GroupBox();
     41      this.inclupperboundInput = new System.Windows.Forms.CheckBox();
     42      this.incllowerboundInput = new System.Windows.Forms.CheckBox();
     43      this.derivationInput = new System.Windows.Forms.CheckBox();
     44      this.expressionLabel = new System.Windows.Forms.Label();
     45      this.expressionInput = new System.Windows.Forms.TextBox();
    4646      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    4747      this.groupBox1.SuspendLayout();
    4848      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    4949      this.SuspendLayout();
    50       //
    51       // expressionLabel
    52       //
    53       this.expressionLabel.AutoSize = true;
    54       this.expressionLabel.Location = new System.Drawing.Point(11, 20);
    55       this.expressionLabel.Name = "expressionLabel";
    56       this.expressionLabel.Size = new System.Drawing.Size(61, 13);
    57       this.expressionLabel.TabIndex = 0;
    58       this.expressionLabel.Text = "Expression:";
    5950      //
    6051      // definitionLabel
     
    139130      this.definitionInput.TabIndex = 9;
    140131      //
    141       // expressionInput
    142       //
    143       this.expressionInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    144             | System.Windows.Forms.AnchorStyles.Right)));
    145       this.expressionInput.Location = new System.Drawing.Point(111, 17);
    146       this.expressionInput.Name = "expressionInput";
    147       this.expressionInput.Size = new System.Drawing.Size(473, 20);
    148       this.expressionInput.TabIndex = 10;
    149       this.expressionInput.TextChanged += new System.EventHandler(this.expressionInput_TextChanged);
    150       //
    151132      // upperboundInput
    152133      //
     
    157138      this.upperboundInput.Size = new System.Drawing.Size(473, 20);
    158139      this.upperboundInput.TabIndex = 11;
     140      this.upperboundInput.Validating += new System.ComponentModel.CancelEventHandler(this.upperboundInput_Validating);
     141      this.upperboundInput.Validated += new System.EventHandler(this.upperboundInput_Validated);
    159142      //
    160143      // lowerboundInput
     
    166149      this.lowerboundInput.Size = new System.Drawing.Size(473, 20);
    167150      this.lowerboundInput.TabIndex = 12;
    168       this.lowerboundInput.TextChanged += new System.EventHandler(this.lowerboundInput_TextChanged);
     151      this.lowerboundInput.Validating += new System.ComponentModel.CancelEventHandler(this.lowerboundInput_Validating);
     152      this.lowerboundInput.Validated += new System.EventHandler(this.lowerboundInput_Validated);
    169153      //
    170154      // variableInput
     
    176160      this.variableInput.Size = new System.Drawing.Size(473, 20);
    177161      this.variableInput.TabIndex = 15;
    178       this.variableInput.TextChanged += new System.EventHandler(this.variableInput_TextChanged);
    179162      //
    180163      // numberderivationInput
     
    184167      this.numberderivationInput.Location = new System.Drawing.Point(111, 221);
    185168      this.numberderivationInput.Name = "numberderivationInput";
    186       this.numberderivationInput.Size = new System.Drawing.Size(473, 20);
     169      this.numberderivationInput.Size = new System.Drawing.Size(470, 20);
    187170      this.numberderivationInput.TabIndex = 17;
    188       this.numberderivationInput.TextChanged += new System.EventHandler(this.numberderivationInput_TextChanged);
    189       //
    190       // upperCombo
    191       //
    192       this.upperCombo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    193             | System.Windows.Forms.AnchorStyles.Right)));
    194       this.upperCombo.FormattingEnabled = true;
    195       this.upperCombo.Items.AddRange(new object[] {
    196             "True",
    197             "False"});
    198       this.upperCombo.Location = new System.Drawing.Point(111, 146);
    199       this.upperCombo.Name = "upperCombo";
    200       this.upperCombo.Size = new System.Drawing.Size(473, 21);
    201       this.upperCombo.TabIndex = 19;
    202       //
    203       // lowerCombo
    204       //
    205       this.lowerCombo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    206             | System.Windows.Forms.AnchorStyles.Right)));
    207       this.lowerCombo.FormattingEnabled = true;
    208       this.lowerCombo.Items.AddRange(new object[] {
    209             "True",
    210             "False"});
    211       this.lowerCombo.Location = new System.Drawing.Point(111, 119);
    212       this.lowerCombo.Name = "lowerCombo";
    213       this.lowerCombo.Size = new System.Drawing.Size(473, 21);
    214       this.lowerCombo.TabIndex = 20;
    215       //
    216       // derivationInput
    217       //
    218       this.derivationInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    219             | System.Windows.Forms.AnchorStyles.Right)));
    220       this.derivationInput.Location = new System.Drawing.Point(111, 170);
    221       this.derivationInput.Name = "derivationInput";
    222       this.derivationInput.Size = new System.Drawing.Size(473, 20);
    223       this.derivationInput.TabIndex = 21;
     171      this.numberderivationInput.Validating += new System.ComponentModel.CancelEventHandler(this.numberderivationInput_Validating);
     172      this.numberderivationInput.Validated += new System.EventHandler(this.numberderivationInput_Validated);
    224173      //
    225174      // groupBox1
    226175      //
     176      this.groupBox1.Controls.Add(this.expressionInput);
     177      this.groupBox1.Controls.Add(this.expressionLabel);
     178      this.groupBox1.Controls.Add(this.inclupperboundInput);
     179      this.groupBox1.Controls.Add(this.incllowerboundInput);
    227180      this.groupBox1.Controls.Add(this.derivationInput);
    228       this.groupBox1.Controls.Add(this.lowerCombo);
    229       this.groupBox1.Controls.Add(this.upperCombo);
    230181      this.groupBox1.Controls.Add(this.numberderivationInput);
    231182      this.groupBox1.Controls.Add(this.variableInput);
    232183      this.groupBox1.Controls.Add(this.lowerboundInput);
    233184      this.groupBox1.Controls.Add(this.upperboundInput);
    234       this.groupBox1.Controls.Add(this.expressionInput);
    235185      this.groupBox1.Controls.Add(this.definitionInput);
    236186      this.groupBox1.Controls.Add(this.numberderivationLabel);
     
    242192      this.groupBox1.Controls.Add(this.lowerboundLabel);
    243193      this.groupBox1.Controls.Add(this.definitionLabel);
    244       this.groupBox1.Controls.Add(this.expressionLabel);
    245194      this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
    246195      this.groupBox1.Location = new System.Drawing.Point(0, 0);
     
    251200      this.groupBox1.Text = "Interval Constraints Detail";
    252201      //
     202      // inclupperboundInput
     203      //
     204      this.inclupperboundInput.AutoSize = true;
     205      this.inclupperboundInput.Location = new System.Drawing.Point(111, 146);
     206      this.inclupperboundInput.Name = "inclupperboundInput";
     207      this.inclupperboundInput.Size = new System.Drawing.Size(15, 14);
     208      this.inclupperboundInput.TabIndex = 23;
     209      this.inclupperboundInput.UseVisualStyleBackColor = true;
     210      this.inclupperboundInput.CheckedChanged += new System.EventHandler(this.inclupperboundInput_CheckedChanged);
     211      //
     212      // incllowerboundInput
     213      //
     214      this.incllowerboundInput.AutoSize = true;
     215      this.incllowerboundInput.Location = new System.Drawing.Point(111, 122);
     216      this.incllowerboundInput.Name = "incllowerboundInput";
     217      this.incllowerboundInput.Size = new System.Drawing.Size(15, 14);
     218      this.incllowerboundInput.TabIndex = 22;
     219      this.incllowerboundInput.UseVisualStyleBackColor = true;
     220      this.incllowerboundInput.CheckedChanged += new System.EventHandler(this.incllowerboundInput_CheckedChanged);
     221      //
     222      // derivationInput
     223      //
     224      this.derivationInput.AutoSize = true;
     225      this.derivationInput.Location = new System.Drawing.Point(111, 173);
     226      this.derivationInput.Name = "derivationInput";
     227      this.derivationInput.Size = new System.Drawing.Size(15, 14);
     228      this.derivationInput.TabIndex = 21;
     229      this.derivationInput.UseVisualStyleBackColor = true;
     230      //
     231      // expressionLabel
     232      //
     233      this.expressionLabel.AutoSize = true;
     234      this.expressionLabel.Location = new System.Drawing.Point(11, 20);
     235      this.expressionLabel.Name = "expressionLabel";
     236      this.expressionLabel.Size = new System.Drawing.Size(61, 13);
     237      this.expressionLabel.TabIndex = 24;
     238      this.expressionLabel.Text = "Expression:";
     239      //
     240      // expressionInput
     241      //
     242      this.expressionInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     243            | System.Windows.Forms.AnchorStyles.Right)));
     244      this.expressionInput.Location = new System.Drawing.Point(108, 17);
     245      this.expressionInput.Name = "expressionInput";
     246      this.expressionInput.Size = new System.Drawing.Size(473, 20);
     247      this.expressionInput.TabIndex = 25;
     248      //
    253249      // errorProvider
    254250      //
    255251      this.errorProvider.ContainerControl = this;
     252      this.errorProvider.RightToLeft = true;
    256253      //
    257254      // IntervalConstraintView
     
    269266
    270267    #endregion
    271 
    272     private System.Windows.Forms.Label expressionLabel;
    273268    private System.Windows.Forms.Label definitionLabel;
    274269    private System.Windows.Forms.Label lowerboundLabel;
     
    280275    private System.Windows.Forms.Label numberderivationLabel;
    281276    private System.Windows.Forms.TextBox definitionInput;
    282     private System.Windows.Forms.TextBox expressionInput;
    283277    private System.Windows.Forms.TextBox upperboundInput;
    284278    private System.Windows.Forms.TextBox lowerboundInput;
    285279    private System.Windows.Forms.TextBox variableInput;
    286280    private System.Windows.Forms.TextBox numberderivationInput;
    287     private System.Windows.Forms.ComboBox upperCombo;
    288     private System.Windows.Forms.ComboBox lowerCombo;
    289     private System.Windows.Forms.TextBox derivationInput;
    290281    private System.Windows.Forms.GroupBox groupBox1;
     282    private System.Windows.Forms.CheckBox derivationInput;
     283    private System.Windows.Forms.CheckBox inclupperboundInput;
     284    private System.Windows.Forms.CheckBox incllowerboundInput;
     285    private System.Windows.Forms.TextBox expressionInput;
     286    private System.Windows.Forms.Label expressionLabel;
    291287    private System.Windows.Forms.ErrorProvider errorProvider;
    292288  }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs

    r16774 r16776  
    1919
    2020    public new IntervalConstraint Content {
    21       get { return (IntervalConstraint)base.Content; }
    22       set { base.Content = value; }
     21      get => (IntervalConstraint) base.Content;
     22      set => base.Content = value;
    2323    }
    2424
     
    2727      expressionInput.ReadOnly = true;
    2828      definitionInput.ReadOnly = true;
    29       derivationInput.ReadOnly = true;
    30       if (derivationInput.Text == "False")
     29      derivationInput.Enabled = false;
     30      derivationInput.Checked = Content?.IsDerivation ?? false;
     31      if (Content != null && !Content.IsDerivation)
    3132        numberderivationInput.ReadOnly = true;
    32     }
    33 
    34     protected override void RegisterContentEvents() {
    35       base.RegisterContentEvents();
    36       Content.Changed += new EventHandler(Content_Changed);
    37     }
    38 
    39     protected override void DeregisterContentEvents() {
    40       base.DeregisterContentEvents();
    41       Content.Changed -= new EventHandler(Content_Changed);
    42     }
    43 
    44     private void Content_Changed(object sender, EventArgs e) {
    45       UpdateControls();
    4633    }
    4734
     
    5744    }
    5845
    59     private void UpdateControls() {
    60       if (Content == null) {
    61         expressionInput.Text = string.Empty;
    62         definitionInput.Text = string.Empty;
    63         lowerboundInput.Text = string.Empty;
    64         upperboundInput.Text = string.Empty;
    65         lowerCombo.SelectedItem = null;
    66         lowerCombo.SelectedText = "--Nothing set--";
    67         upperCombo.SelectedItem = null;
    68         upperCombo.SelectedText = "--Nothing set--";
    69       } else {
    70         expressionInput.Text = Content.Expression;
    71         definitionInput.Text = Content.Definition;
    72         lowerboundInput.Text = Content.Interval.LowerBound.ToString(CultureInfo.InvariantCulture);
    73         upperboundInput.Text = Content.Interval.UpperBound.ToString(CultureInfo.InvariantCulture);
    74         lowerCombo.SelectedIndex = lowerCombo.FindString(Content.InclusiveLowerBound ? "True" : "False");
    75         upperCombo.SelectedIndex = upperCombo.FindString(Content.InclusiveUpperBound ? "True" : "False");
    76         derivationInput.Text = Content.IsDerivation ? "True" : "False";
    77         variableInput.Text = Content.Variable;
    78         numberderivationInput.Text = Content.NumberOfDerivation.ToString();
    79       }
    80       SetEnabledStateOfControls();
    81     }
    82 
    83     private void expressionInput_TextChanged(object sender, EventArgs e) {
    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     }
     46
     47
     48    #region helpers
    11549
    11650    private double ParseDoubleValue(string input, Control control) {
     
    11953        case "inf.":
    12054        case "+inf.":
     55        case "Infinity":
    12156          return double.PositiveInfinity;
    12257        case "-inf.":
     58        case "-Infinity":
    12359          return double.NegativeInfinity;
    124         default: { 
    125           if (double.TryParse(input, out var value))
     60        default: {
     61          if (double.TryParse(input, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
    12662            return value;
    12763          else {
     
    13268      }
    13369    }
     70
     71    private void UpdateControls() {
     72      if (Content == null) {
     73        expressionInput.Text = string.Empty;
     74        lowerboundInput.Text = string.Empty;
     75        upperboundInput.Text = string.Empty;
     76        incllowerboundInput.Checked = true;
     77        inclupperboundInput.Checked = true;
     78      } else {
     79        expressionInput.Text = Content.Expression;
     80        definitionInput.Text = Content.Definition;
     81        lowerboundInput.Text = Content.Interval.LowerBound.ToString(CultureInfo.InvariantCulture);
     82        upperboundInput.Text = Content.Interval.UpperBound.ToString(CultureInfo.InvariantCulture);
     83        incllowerboundInput.Checked = Content.InclusiveLowerBound;
     84        inclupperboundInput.Checked = Content.InclusiveUpperBound;
     85        derivationInput.Checked = Content.IsDerivation;
     86        variableInput.Text = Content.Variable;
     87        numberderivationInput.Text = Content.NumberOfDerivation.ToString();
     88      }
     89      SetEnabledStateOfControls();
     90    }
     91
     92    private void UpdateExpression() {
     93      var expression = "";
     94
     95      if (!Content.IsDerivation) {
     96        expression = string.Format("{0} in {1}{2} .. {3}{4}",
     97          Content.Variable,
     98          (Content.InclusiveLowerBound) ? "[" : "]",
     99          Content.Interval.LowerBound,
     100          Content.Interval.UpperBound,
     101          (Content.InclusiveUpperBound) ? "]" : "[");
     102      } else {
     103        expression = string.Format("\u2202Target/\u2202{0} in {1}{2} .. {3}{4}",
     104          Content.Variable,
     105          (Content.InclusiveLowerBound) ? "[" : "]",
     106          Content.Interval.LowerBound,
     107          Content.Interval.UpperBound,
     108          (Content.InclusiveUpperBound) ? "]" : "[");
     109      }
     110
     111      Content.Expression = expression;
     112      Content.Name = expression;
     113      UpdateControls();
     114    }
     115
     116    #endregion
     117
     118    #region content event handlers
     119
     120    private void numberderivationInput_Validating(object sender, CancelEventArgs e) {
     121      if (int.TryParse(numberderivationInput.Text, out var derivation)) {
     122        if (derivation >= 0) {
     123          errorProvider.SetError(numberderivationInput, string.Empty);
     124          e.Cancel = false;
     125        } else {
     126          errorProvider.SetError(numberderivationInput, "Invalid Input: Derivation must be positive!");
     127          e.Cancel = true;
     128        }
     129      } else {
     130        errorProvider.SetError(numberderivationInput, "Invalid Input: Derivation must be an integer!");
     131        e.Cancel = true;
     132      }
     133    }
     134
     135    private void numberderivationInput_Validated(object sender, EventArgs e) {
     136      if (int.TryParse(numberderivationInput.Text, out var derivation)) {
     137        Content.NumberOfDerivation = derivation;
     138        UpdateExpression();
     139      }
     140    }
     141
     142    private void lowerboundInput_Validating(object sender, CancelEventArgs e) {
     143      var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput);
     144      if (!double.IsNaN(value)) {
     145        if (value <= Content.Interval.UpperBound) {
     146          errorProvider.SetError(lowerboundInput, string.Empty);
     147          e.Cancel = false;
     148        } else {
     149          errorProvider.SetError(lowerboundInput, "Invalid Input: Lowerbound must be smaller than Upperbound!");
     150          e.Cancel = true;
     151        }
     152      } else {
     153        e.Cancel = true;
     154      }
     155    }
     156
     157    private void lowerboundInput_Validated(object sender, EventArgs e) {
     158      var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput);
     159      if (!double.IsNaN(value)) {
     160        Content.Interval = new Interval(value, Content.Interval.UpperBound);
     161        UpdateExpression();
     162      }
     163    }
     164
     165    private void upperboundInput_Validating(object sender, CancelEventArgs e) {
     166      var value = ParseDoubleValue(upperboundInput.Text, upperboundInput);
     167      if (!double.IsNaN(value)) {
     168        if (value >= Content.Interval.LowerBound) {
     169          errorProvider.SetError(upperboundInput, string.Empty);
     170          e.Cancel = false;
     171        } else {
     172          errorProvider.SetError(lowerboundInput, "Invalid Input: Upperbound must be bigger than Lowerbound!");
     173          e.Cancel = true;
     174        }
     175      } else {
     176        e.Cancel = true;
     177      }
     178    }
     179
     180    private void upperboundInput_Validated(object sender, EventArgs e) {
     181      var value = ParseDoubleValue(upperboundInput.Text, upperboundInput);
     182      if (!double.IsNaN(value)) {
     183        Content.Interval = new Interval(Content.Interval.LowerBound, value);
     184        UpdateExpression();
     185      }
     186    }
     187
     188    private void incllowerboundInput_CheckedChanged(object sender, EventArgs e) {
     189      if (Content.InclusiveLowerBound != incllowerboundInput.Checked) {
     190        Content.InclusiveLowerBound = incllowerboundInput.Checked;
     191        UpdateExpression();
     192      }
     193     
     194     
     195    }
     196
     197    private void inclupperboundInput_CheckedChanged(object sender, EventArgs e) {
     198      if (Content.InclusiveUpperBound != incllowerboundInput.Checked) {
     199        Content.InclusiveUpperBound = incllowerboundInput.Checked;
     200        UpdateExpression();
     201      }
     202    }
     203    #endregion
     204
     205
    134206  }
    135207}
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.cs

    r16774 r16776  
    99  [Content(typeof(ParsedConstraint), true)]
    1010  public partial class ParsedConstraintView : AsynchronousContentView {
    11 
     11    private CheckedItemList<IntervalConstraint> intervalConstraints;
    1212    public new ParsedConstraint Content {
    1313      get => (ParsedConstraint)base.Content;
     
    1818      InitializeComponent();
    1919      errorOutput.Text = "";
     20      intervalConstraints = new CheckedItemList<IntervalConstraint>();
     21    }
     22
     23    private void Content_Changed(object sender, EventArgs e) {
     24      constraintsOutput.Content = intervalConstraints;
    2025    }
    2126
    2227    protected override void OnContentChanged() {
    2328      base.OnContentChanged();
    24       if (Content == null) {
    25         constraintsInput.Text = string.Empty;
    26         errorOutput.Text = "";
    27       } else {
    28         constraintsInput.Text = Content.Input;
    29         constraintsOutput.Content = new ItemList<IntervalConstraint>(Content.Constraints) ?? new ItemList<IntervalConstraint>();
    30       }
     29      UpdateControl();
    3130    }
    3231
    33     private ItemList<IntervalConstraint> ParseConstraints(string input) {
    34       ItemList<IntervalConstraint> constraints = new ItemList<IntervalConstraint>(IntervalConstraintsParser.ParseInput(input, Content.ProblemData.TargetVariable, Content.ProblemData.AllowedInputVariables));
     32    private CheckedItemList<IntervalConstraint> ParseConstraints(string input) {
     33      CheckedItemList<IntervalConstraint> constraints = new CheckedItemList<IntervalConstraint>(IntervalConstraintsParser.ParseInput(input, Content.ProblemData.TargetVariable, Content.ProblemData.AllowedInputVariables));
    3534      return constraints;
    3635    }
     
    4847    }
    4948
     49    private void UpdateControl() {
     50      if (Content == null) {
     51        ClearConstraints();
     52        constraintsInput.Text = string.Empty;
     53        errorOutput.Text = string.Empty;
     54        constraintsOutput.Content = intervalConstraints;
     55      } else {
     56        constraintsInput.Text = Content.Input;
     57        foreach (var constraint in Content.Constraints) {
     58          constraint.Changed += new EventHandler(Content_Changed);
     59          intervalConstraints.Add(constraint, true);
     60        }
     61      }
     62    }
     63
    5064    private void constraintsInput_TextChanged(object sender, EventArgs e) {
    5165      errorOutput.Text = "Unparsed changes! Press parse button to save changes.";
    5266    }
     67
     68    private void ClearConstraints() {
     69      foreach (var constraint in intervalConstraints) {
     70        constraint.Changed -= new EventHandler(Content_Changed);
     71      }
     72      intervalConstraints.Clear();
     73    }
     74
    5375  }
    5476}
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.designer.cs

    r16774 r16776  
    3131      this.label1 = new System.Windows.Forms.Label();
    3232      //this.constraintsOutput = new System.Windows.Forms.Label();
    33       this.constraintsOutput = new HeuristicLab.Core.Views.ItemListView<IntervalConstraint>();
     33      this.constraintsOutput = new HeuristicLab.Core.Views.CheckedItemListView<IntervalConstraint>();
    3434      this.errorOutput = new System.Windows.Forms.Label();
    3535      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
     
    149149
    150150    //private System.Windows.Forms.Label constraintsOutput;
    151     private HeuristicLab.Core.Views.ItemListView<IntervalConstraint> constraintsOutput;
     151    private HeuristicLab.Core.Views.CheckedItemListView<IntervalConstraint> constraintsOutput;
    152152  }
    153153}
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraint.cs

    r16774 r16776  
    1212  [Item("Interval Constraint", "Constraint on intervals.")]
    1313  public class IntervalConstraint : NamedItem {
    14     public string Expression { get; set; }
     14    private string expression;
     15    public string Expression {
     16      get => expression;
     17      set {
     18        if (value != expression) {
     19          expression = value;
     20        }
     21      }
     22    }
    1523    public string Definition { get; set; }
    1624    public Interval Interval { get; set; }
    17     public bool InclusiveLowerBound { get; set; }
     25    private bool inclusiveLowerBound;
     26
     27    public bool InclusiveLowerBound {
     28      get => inclusiveLowerBound;
     29      set {
     30        if (value != inclusiveLowerBound) {
     31          inclusiveLowerBound = value;
     32          OnChanged(EventArgs.Empty);
     33        }
     34      }
     35    }
    1836    public bool InclusiveUpperBound { get; set; }
    1937    public bool IsDerivation { get; set; }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r16774 r16776  
    181181                           "#double: upperbound of the interval" + Environment.NewLine +
    182182                           "#bracket: open or closed regarding to open or closed interval definition" + Environment.NewLine +
    183                            "#Y2 in [0 .. 1.2]" + Environment.NewLine + Environment.NewLine +
     183                           "#Target:Y2 in [0 .. 1.2]" + Environment.NewLine + Environment.NewLine +
    184184                           "#Constraints on model parameters:" + Environment.NewLine +
    185185                           "#derivation symbol: d or ∂" + Environment.NewLine +
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ParsedConstraint.cs

    r16774 r16776  
    2525    public IEnumerable<IntervalConstraint> Constraints {
    2626      get => constraints;
    27       set => constraints = value;
    28     }
     27      set {
     28        constraints = value;
     29        OnChanged(EventArgs.Empty);
     30      }
     31  }
    2932
    3033    protected IRegressionProblemData problemData;
     
    3841      : base(original, cloner) {
    3942      this.input = original.Input ?? string.Empty;
    40       this.constraints = original.Constraints ?? new ItemList<IntervalConstraint>();
     43      this.constraints = original.Constraints ?? new CheckedItemList<IntervalConstraint>();
    4144     
    4245    }
     
    4851    public ParsedConstraint() {
    4952      this.input = string.Empty;
    50       this.constraints = new ItemList<IntervalConstraint>();
     53      this.constraints = new CheckedItemList<IntervalConstraint>();
    5154    }
    5255
    5356    public ParsedConstraint(string input, IRegressionProblemData problemData) {
    5457      this.input = input;
    55       this.constraints = new ItemList<IntervalConstraint>();
     58      this.constraints = new CheckedItemList<IntervalConstraint>();
    5659      this.problemData = problemData;
    5760    }
     
    6164      this.constraints = constraints;
    6265    }
     66
     67    public event EventHandler Changed;
     68    protected virtual void OnChanged(EventArgs e) {
     69      EventHandler handlers = Changed;
     70      if (handlers != null)
     71        handlers(this, e);
     72    }
    6373  }
    6474}
Note: See TracChangeset for help on using the changeset viewer.