Changeset 16787


Ignore:
Timestamp:
04/16/19 10:11:38 (2 months ago)
Author:
chaider
Message:

#2971 Fixed isChecked events

Location:
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
3 edited

Legend:

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

    r16778 r16787  
    3838      this.variableInput = new System.Windows.Forms.TextBox();
    3939      this.groupBox1 = new System.Windows.Forms.GroupBox();
     40      this.numberderivationInput = new System.Windows.Forms.ComboBox();
    4041      this.ischeckedCheckBox = new System.Windows.Forms.CheckBox();
    4142      this.expressionInput = new System.Windows.Forms.TextBox();
     
    4546      this.derivationInput = new System.Windows.Forms.CheckBox();
    4647      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    47       this.numberderivationInput = new System.Windows.Forms.ComboBox();
    4848      this.groupBox1.SuspendLayout();
    4949      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     
    191191      this.groupBox1.Text = "Interval Constraints Detail";
    192192      //
     193      // numberderivationInput
     194      //
     195      this.numberderivationInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     196            | System.Windows.Forms.AnchorStyles.Right)));
     197      this.numberderivationInput.FormattingEnabled = true;
     198      this.numberderivationInput.Location = new System.Drawing.Point(111, 224);
     199      this.numberderivationInput.Name = "numberderivationInput";
     200      this.numberderivationInput.Size = new System.Drawing.Size(470, 21);
     201      this.numberderivationInput.TabIndex = 27;
     202      this.numberderivationInput.SelectedIndexChanged += new System.EventHandler(this.numberderivationInput_SelectedIndexChanged);
     203      //
    193204      // ischeckedCheckBox
    194205      //
     
    200211      this.ischeckedCheckBox.Text = "Enabled";
    201212      this.ischeckedCheckBox.UseVisualStyleBackColor = true;
    202       this.ischeckedCheckBox.CheckStateChanged += new System.EventHandler(this.ischeckedCheckBox_CheckStateChanged);
     213      this.ischeckedCheckBox.CheckedChanged += new System.EventHandler(this.ischeckedCheckBox_CheckedChanged);
    203214      //
    204215      // expressionInput
     
    253264      this.errorProvider.ContainerControl = this;
    254265      this.errorProvider.RightToLeft = true;
    255       //
    256       // numberderivationInput
    257       //
    258       this.numberderivationInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    259             | System.Windows.Forms.AnchorStyles.Right)));
    260       this.numberderivationInput.FormattingEnabled = true;
    261       this.numberderivationInput.Location = new System.Drawing.Point(111, 224);
    262       this.numberderivationInput.Name = "numberderivationInput";
    263       this.numberderivationInput.Size = new System.Drawing.Size(470, 21);
    264       this.numberderivationInput.TabIndex = 27;
    265       this.numberderivationInput.SelectedIndexChanged += new System.EventHandler(this.numberderivationInput_SelectedIndexChanged);
    266266      //
    267267      // IntervalConstraintView
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs

    r16778 r16787  
    3838    }
    3939
     40    protected override void RegisterContentEvents() {
     41      base.RegisterContentEvents();
     42      Content.Changed += new EventHandler(Content_Changed);
     43    }
     44
     45    protected override void DeregisterContentEvents() {
     46      base.DeregisterContentEvents();
     47      Content.Changed -= new EventHandler(Content_Changed);
     48    }
    4049
    4150    protected override void SetEnabledStateOfControls() {
     
    91100          numberderivationInput.SelectedItem = Content.NumberOfDerivation;
    92101        }
     102
    93103        ischeckedCheckBox.Checked = Content.IsChecked;
    94         Content.Changed += Content_Changed;
    95104      }
    96105      SetEnabledStateOfControls();
     
    201210    }
    202211
    203     private void ischeckedCheckBox_CheckStateChanged(object sender, EventArgs e) {
     212    private void ischeckedCheckBox_CheckedChanged(object sender, EventArgs e) {
    204213      if (Content.IsChecked != ischeckedCheckBox.Checked) {
    205214        Content.IsChecked = ischeckedCheckBox.Checked;
     
    227236    }
    228237
     238
    229239    #endregion
    230 
    231240
    232241  }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.cs

    r16778 r16787  
    11using System;
     2using System.Collections.Generic;
    23using HeuristicLab.Collections;
    34using HeuristicLab.Core;
     
    1920      errorOutput.Text = "";
    2021      intervalConstraints = new CheckedItemList<IntervalConstraint>();
    21       intervalConstraints.CheckedItemsChanged += constraints_CheckedItemsChanged;
     22      intervalConstraints.CheckedItemsChanged += constraint_CheckedItemChanged;
    2223    }
    2324
     
    2728    }
    2829
    29     private CheckedItemList<IntervalConstraint> ParseConstraints(string input) {
    30       CheckedItemList<IntervalConstraint> constraints = new CheckedItemList<IntervalConstraint>(IntervalConstraintsParser.ParseInput(input, Content.ProblemData.TargetVariable, Content.ProblemData.AllowedInputVariables));
    31       return constraints;
     30    private IEnumerable<IntervalConstraint> ParseConstraints(string input) {
     31      return IntervalConstraintsParser.ParseInput(input, Content.ProblemData.TargetVariable,
     32        Content.ProblemData.AllowedInputVariables);
    3233    }
    3334
    3435    private void parseBtn_Click(object sender, EventArgs e) {
    3536      if (constraintsInput.Text != null) {
    36         intervalConstraints = ParseConstraints(constraintsInput.Text);
    37         intervalConstraints.CheckedItemsChanged -= constraints_CheckedItemsChanged;
    38         intervalConstraints.CheckedItemsChanged += constraints_CheckedItemsChanged;
     37        ClearConstraints();
     38        var parsedConstraints = ParseConstraints(constraintsInput.Text);
     39        foreach (var constraint in parsedConstraints) {
     40          constraint.Changed += constraint_Changed;
     41          intervalConstraints.Add(constraint, constraint.IsChecked);
     42        }
    3943        constraintsOutput.Content = intervalConstraints;
    4044        Content.Constraints = intervalConstraints;
     
    4953      if (Content == null) {
    5054        ClearConstraints();
    51         constraintsInput.Text = string.Empty;
    52         errorOutput.Text = string.Empty;
    53         constraintsOutput.Content = intervalConstraints;
     55        constraintsOutput.Content = intervalConstraints.AsReadOnly();
    5456      } else {
     57        ClearConstraints();
    5558        constraintsInput.Text = Content.Input;
    5659        foreach (var constraint in Content.Constraints) {
    57           constraint.Changed += new EventHandler(Content_Changed);
     60          constraint.Changed += constraint_Changed;
    5861          intervalConstraints.Add(constraint, constraint.IsChecked);
    5962        }
     63
     64        constraintsOutput.Content = intervalConstraints.AsReadOnly();
    6065      }
    61       constraintsOutput.Content = intervalConstraints;
     66      SetEnabledStateOfControls();
     67    }
     68
     69    private void constraint_Changed(object sender, EventArgs e) {
     70      var constraint = (IntervalConstraint) sender;
     71      intervalConstraints.SetItemCheckedState(constraint, constraint.IsChecked);
     72    }
     73
     74    private void constraint_CheckedItemChanged(object sender,
     75      CollectionItemsChangedEventArgs<IndexedItem<IntervalConstraint>> e) {
     76      ICheckedItemList<IntervalConstraint> checkedItemList = (ICheckedItemList<IntervalConstraint>) sender;
     77      foreach (var indexedItem in e.Items) {
     78        indexedItem.Value.IsChecked = checkedItemList.ItemChecked(indexedItem.Value);
     79      }
    6280    }
    6381
     
    6684    }
    6785
    68     private void Content_Changed(object sender, EventArgs e) {
    69       var constraint = (IntervalConstraint) sender;
    70       intervalConstraints.SetItemCheckedState(constraint, constraint.IsChecked);
    71       constraintsOutput.Content = intervalConstraints;
    72     }
    73 
    74     private void constraints_CheckedItemsChanged(object sender,
    75       CollectionItemsChangedEventArgs<IndexedItem<IntervalConstraint>> e) {
    76       var checkedItemList = (ICheckedItemList<IntervalConstraint>) sender;
    77       foreach (var indexedItem in e.Items) {
    78         indexedItem.Value.IsChecked = checkedItemList.ItemChecked(indexedItem.Value);
    79       }
    80     }
    81 
    8286    private void ClearConstraints() {
    8387      foreach (var constraint in intervalConstraints) {
    84         constraint.Changed -= new EventHandler(Content_Changed);
     88        constraint.Changed -= constraint_Changed;
    8589      }
    8690      intervalConstraints.Clear();
Note: See TracChangeset for help on using the changeset viewer.