Changeset 9126 for branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableConditionView.cs
- Timestamp:
- 01/08/13 15:36:13 (12 years ago)
- Location:
- branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4
- Property svn:ignore
-
old new 2 2 obj 3 3 *.user 4 HeuristicLabProblemsDataAnalysisSymbolicViewsPlugin.cs5 4 *.vs10x 6 5 Plugin.cs
-
- Property svn:ignore
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableConditionView.cs
r5809 r9126 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 readonly 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 // temporarily deregister to prevent circular calling of events 127 DeregisterVariableNamesViewContentEvents(); 128 variableNamesView.Content.Clear(); 129 foreach (var variableName in Content.AllVariableNames) { 130 variableNamesView.Content.Add(new StringValue(variableName), Content.VariableNames.Contains(variableName)); 131 } 132 RegisterVariableNamesViewContentEvents(); 133 91 134 thresholdInitializationMuTextBox.Text = Content.ThresholdInitializerMu.ToString(); 92 135 thresholdInitializationSigmaTextBox.Text = Content.ThresholdInitializerSigma.ToString(); … … 102 145 103 146 #region control events 104 private void thresholdMuTextBox_TextChanged(object sender, EventArgs e) { 147 private void VariableNames_Changed(object sender, CollectionItemsChangedEventArgs<StringValue> e) { 148 foreach (var newVar in e.Items) 149 newVar.ValueChanged += new EventHandler(Variable_ValueChanged); 150 foreach (var oldVar in e.OldItems) 151 oldVar.ValueChanged -= new EventHandler(Variable_ValueChanged); 152 UpdateContent(); 153 } 154 155 private void Variable_ValueChanged(object sender, EventArgs e) { 156 UpdateContent(); 157 } 158 159 private void UpdateContent() { 160 if (Content != null) { 161 DeregisterContentEvents(); 162 Content.VariableNames = variableNamesView.Content.CheckedItems.Select(x => x.Value).ToList(); 163 RegisterContentEvents(); 164 } 165 } 166 167 private void ThresholdInitializationMuTextBox_TextChanged(object sender, EventArgs e) { 105 168 double value; 106 169 if (double.TryParse(thresholdInitializationMuTextBox.Text, out value)) { … … 109 172 } else errorProvider.SetError(thresholdInitializationMuTextBox, "Invalid value"); 110 173 } 111 private void thresholdInitializationSigmaTextBox_TextChanged(object sender, EventArgs e) {174 private void ThresholdInitializationSigmaTextBox_TextChanged(object sender, EventArgs e) { 112 175 double value; 113 176 if (double.TryParse(thresholdInitializationSigmaTextBox.Text, out value)) { … … 116 179 } else errorProvider.SetError(thresholdInitializationSigmaTextBox, "Invalid value"); 117 180 } 118 private void slopeInitializationMuTextBox_TextChanged(object sender, EventArgs e) {181 private void SlopeInitializationMuTextBox_TextChanged(object sender, EventArgs e) { 119 182 double value; 120 183 if (double.TryParse(slopeInitializationMuTextBox.Text, out value)) { … … 123 186 } else errorProvider.SetError(slopeInitializationMuTextBox, "Invalid value"); 124 187 } 125 private void slopeInitializationSigmaTextBox_TextChanged(object sender, EventArgs e) {188 private void SlopeInitializationSigmaTextBox_TextChanged(object sender, EventArgs e) { 126 189 double value; 127 190 if (double.TryParse(slopeInitializationSigmaTextBox.Text, out value)) { … … 131 194 } 132 195 133 private void thresholdChangeMuTextBox_TextChanged(object sender, EventArgs e) {196 private void ThresholdChangeMuTextBox_TextChanged(object sender, EventArgs e) { 134 197 double value; 135 198 if (double.TryParse(thresholdChangeMuTextBox.Text, out value)) { … … 139 202 } 140 203 141 private void thresholdChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {204 private void ThresholdChangeSigmaTextBox_TextChanged(object sender, EventArgs e) { 142 205 double value; 143 206 if (double.TryParse(thresholdChangeSigmaTextBox.Text, out value)) { … … 146 209 } else errorProvider.SetError(thresholdChangeSigmaTextBox, "Invalid value"); 147 210 } 148 private void slopeChangeMuTextBox_TextChanged(object sender, EventArgs e) {211 private void SlopeChangeMuTextBox_TextChanged(object sender, EventArgs e) { 149 212 double value; 150 213 if (double.TryParse(slopeChangeMuTextBox.Text, out value)) { … … 154 217 } 155 218 156 private void slopeChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {219 private void SlopeChangeSigmaTextBox_TextChanged(object sender, EventArgs e) { 157 220 double value; 158 221 if (double.TryParse(slopeChangeSigmaTextBox.Text, out value)) { … … 162 225 } 163 226 #endregion 164 165 227 } 166 228 }
Note: See TracChangeset
for help on using the changeset viewer.