- Timestamp:
- 04/24/19 10:59:39 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.cs
r16862 r16870 40 40 errorOutput.Text = ""; 41 41 intervalConstraints = new CheckedItemList<IntervalConstraint>(); 42 intervalConstraints.CheckedItemsChanged += constraint_CheckedItemChanged;43 //intervalConstraints.ItemsRemoved44 42 } 45 43 … … 48 46 UpdateControl(); 49 47 } 50 //ParameterCollectionView 51 //Remove method directly at parsebutton event 48 49 protected override void RegisterContentEvents() { 50 base.RegisterContentEvents(); 51 intervalConstraints.CheckedItemsChanged += constraint_CheckedItemChanged; 52 intervalConstraints.ItemsAdded += constraints_Updated; 53 intervalConstraints.ItemsRemoved += constraints_Updated; 54 } 55 56 protected override void DeregisterContentEvents() { 57 intervalConstraints.CheckedItemsChanged -= constraint_CheckedItemChanged; 58 intervalConstraints.ItemsAdded -= constraints_Updated; 59 intervalConstraints.ItemsRemoved -= constraints_Updated; 60 base.DeregisterContentEvents(); 61 } 62 63 52 64 private IEnumerable<IntervalConstraint> ParseConstraints(string input) { 53 65 return IntervalConstraintsParser.ParseInput(input, Content.ProblemData.TargetVariable, … … 57 69 private void parseBtn_Click(object sender, EventArgs e) { 58 70 if (constraintsInput.Text != null) { 59 ClearConstraints();71 intervalConstraints.Clear(); 60 72 var parsedConstraints = ParseConstraints(constraintsInput.Text); 61 73 foreach (var constraint in parsedConstraints) { 62 constraint.Changed += constraint_Changed;63 74 intervalConstraints.Add(constraint, constraint.Enabled); 64 75 } … … 74 85 private void UpdateControl() { 75 86 if (Content == null) { 76 ClearConstraints();87 intervalConstraints.Clear(); 77 88 constraintsOutput.Content = intervalConstraints.AsReadOnly(); 78 89 } else { 79 ClearConstraints();90 intervalConstraints.Clear(); 80 91 constraintsInput.Text = Content.Input; 81 92 foreach (var constraint in Content.Constraints) { 82 constraint.Changed += constraint_Changed;83 93 intervalConstraints.Add(constraint, constraint.Enabled); 84 94 } … … 91 101 var constraint = (IntervalConstraint) sender; 92 102 intervalConstraints.SetItemCheckedState(constraint, constraint.Enabled); 103 } 104 105 private void constraints_Updated(object sender, CollectionItemsChangedEventArgs<IndexedItem<IntervalConstraint>> e) { 106 foreach (var addedItem in e.Items) { 107 addedItem.Value.Changed += constraint_Changed; 108 } 93 109 } 94 110 … … 105 121 } 106 122 107 private void ClearConstraints() {108 foreach (var constraint in intervalConstraints) {109 constraint.Changed -= constraint_Changed;110 }111 intervalConstraints.Clear();112 }113 114 123 } 115 124 }
Note: See TracChangeset
for help on using the changeset viewer.