Changeset 8086 for branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableConditionView.cs
- Timestamp:
- 06/22/12 11:11:38 (13 years ago)
- Location:
- branches/ScatterSearch (trunk integration)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch (trunk integration)
- Property svn:ignore
-
old new 20 20 bin 21 21 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableConditionView.cs
r5809 r8086 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 0Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.Linq; 23 24 using System.Windows.Forms; 25 using HeuristicLab.Collections; 26 using HeuristicLab.Core; 27 using HeuristicLab.Core.Views; 28 using HeuristicLab.Data; 24 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views; 25 30 using HeuristicLab.MainForm; … … 30 35 [Content(typeof(VariableCondition), true)] 31 36 public partial class VariableConditionView : SymbolView { 37 private CheckedItemCollectionView<StringValue> variableNamesView; 38 32 39 public new VariableCondition Content { 33 40 get { return (VariableCondition)base.Content; } … … 37 44 public VariableConditionView() { 38 45 InitializeComponent(); 46 variableNamesView = new CheckedItemCollectionView<StringValue>(); 47 variableNamesView.Dock = DockStyle.Fill; 48 variableNamesTabPage.Controls.Add(variableNamesView); 49 variableNamesView.Content = new CheckedItemCollection<StringValue>(); 50 51 RegisterVariableNamesViewContentEvents(); 52 } 53 54 private void RegisterVariableNamesViewContentEvents() { 55 variableNamesView.Content.ItemsAdded += new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 56 variableNamesView.Content.ItemsRemoved += new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 57 variableNamesView.Content.CheckedItemsChanged += new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 58 variableNamesView.Content.CollectionReset += new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 59 foreach (var variable in variableNamesView.Content) { 60 variable.ValueChanged += new EventHandler(variable_ValueChanged); 61 } 62 } 63 64 private void DeregisterVariableNamesViewContentEvents() { 65 variableNamesView.Content.ItemsAdded -= new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 66 variableNamesView.Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 67 variableNamesView.Content.CheckedItemsChanged -= new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 68 variableNamesView.Content.CollectionReset -= new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 69 foreach (var variable in variableNamesView.Content) { 70 variable.ValueChanged -= new EventHandler(variable_ValueChanged); 71 } 39 72 } 40 73 … … 76 109 } 77 110 78 79 80 111 private void UpdateControl() { 81 112 if (Content == null) { … … 88 119 slopeChangeMuTextBox.Text = string.Empty; 89 120 slopeChangeSigmaTextBox.Text = string.Empty; 121 // temporarily deregister to prevent circular calling of events 122 DeregisterVariableNamesViewContentEvents(); 123 variableNamesView.Content.Clear(); 124 RegisterVariableNamesViewContentEvents(); 90 125 } else { 126 var existingEntries = variableNamesView.Content.ToList(); 127 128 // temporarily deregister to prevent circular calling of events 129 DeregisterVariableNamesViewContentEvents(); 130 // add additional entries 131 foreach (var variableName in Content.VariableNames.Except(existingEntries.Select(x => x.Value))) 132 variableNamesView.Content.Add(new StringValue(variableName), true); 133 foreach (var oldEntry in existingEntries.Where(x => !Content.VariableNames.Contains(x.Value))) 134 variableNamesView.Content.Remove(oldEntry); 135 RegisterVariableNamesViewContentEvents(); 136 91 137 thresholdInitializationMuTextBox.Text = Content.ThresholdInitializerMu.ToString(); 92 138 thresholdInitializationSigmaTextBox.Text = Content.ThresholdInitializerSigma.ToString(); … … 102 148 103 149 #region control events 150 private void variableNames_Changed(object sender, CollectionItemsChangedEventArgs<StringValue> args) { 151 if (args.Items != null) 152 foreach (var newVar in args.Items) 153 newVar.ValueChanged += new EventHandler(variable_ValueChanged); 154 if (args.OldItems != null) 155 foreach (var oldVar in args.OldItems) 156 oldVar.ValueChanged -= new EventHandler(variable_ValueChanged); 157 UpdateContent(); 158 } 159 160 private void variable_ValueChanged(object sender, EventArgs e) { 161 UpdateContent(); 162 } 163 164 private void UpdateContent() { 165 if (Content != null) { 166 DeregisterContentEvents(); 167 Content.VariableNames = variableNamesView.Content.CheckedItems.Select(x => x.Value).ToList(); 168 RegisterContentEvents(); 169 } 170 } 171 104 172 private void thresholdMuTextBox_TextChanged(object sender, EventArgs e) { 105 173 double value; … … 162 230 } 163 231 #endregion 164 165 232 } 166 233 }
Note: See TracChangeset
for help on using the changeset viewer.