Changeset 6760 for branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols
- Timestamp:
- 09/14/11 13:59:25 (13 years ago)
- Location:
- branches/PersistenceSpeedUp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceSpeedUp
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableView.cs
r5809 r6760 23 23 using System.Linq; 24 24 using System.Windows.Forms; 25 using HeuristicLab.Collections; 26 using HeuristicLab.Core; 27 using HeuristicLab.Core.Views; 28 using HeuristicLab.Data; 25 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views; 26 30 using HeuristicLab.MainForm; 27 31 using HeuristicLab.MainForm.WindowsForms; 28 using HeuristicLab.Core;29 using HeuristicLab.Data;30 using HeuristicLab.Core.Views;31 using HeuristicLab.Collections;32 32 33 33 34 34 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 35 36 35 [View("Variable View")] 37 36 [Content(typeof(Variable), true)] … … 59 58 variableNamesView.Content.CheckedItemsChanged += new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 60 59 variableNamesView.Content.CollectionReset += new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 61 } 60 foreach (var variable in variableNamesView.Content) { 61 variable.ValueChanged += new EventHandler(variable_ValueChanged); 62 } 63 } 64 62 65 63 66 private void DeregisterVariableNamesViewContentEvents() { … … 66 69 variableNamesView.Content.CheckedItemsChanged -= new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 67 70 variableNamesView.Content.CollectionReset -= new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed); 71 foreach (var variable in variableNamesView.Content) { 72 variable.ValueChanged -= new EventHandler(variable_ValueChanged); 73 } 68 74 } 69 75 … … 81 87 protected override void OnContentChanged() { 82 88 base.OnContentChanged(); 89 variableNamesView.Content.Clear(); 83 90 UpdateControl(); 84 91 } … … 104 111 #region control event handlers 105 112 private void variableNames_Changed(object sender, CollectionItemsChangedEventArgs<StringValue> args) { 113 if (args.Items != null) 114 foreach (var newVar in args.Items) 115 newVar.ValueChanged += new EventHandler(variable_ValueChanged); 116 if (args.OldItems != null) 117 foreach (var oldVar in args.OldItems) 118 oldVar.ValueChanged -= new EventHandler(variable_ValueChanged); 119 UpdateContent(); 120 } 121 122 private void variable_ValueChanged(object sender, EventArgs e) { 123 UpdateContent(); 124 } 125 126 private void UpdateContent() { 106 127 if (Content != null) { 128 Content.Changed -= new EventHandler(Content_Changed); 107 129 Content.VariableNames = variableNamesView.Content.CheckedItems.Select(x => x.Value).ToList(); 108 } 109 } 130 Content.Changed += new EventHandler(Content_Changed); 131 } 132 } 133 110 134 111 135 private void weightMuTextBox_TextChanged(object sender, EventArgs e) { … … 137 161 } 138 162 } 139 140 163 private void multiplicativeWeightChangeSigmaTextBox_TextChanged(object sender, EventArgs e) { 141 164 double sigma; … … 161 184 RegisterVariableNamesViewContentEvents(); 162 185 } else { 163 var existingEntries = variableNamesView.Content. Select(x => x.Value);164 186 var existingEntries = variableNamesView.Content.ToList(); 187 165 188 // temporarily deregister to prevent circular calling of events 166 189 DeregisterVariableNamesViewContentEvents(); 167 190 // add additional entries 168 foreach (var variableName in Content.VariableNames.Except(existingEntries )) {191 foreach (var variableName in Content.VariableNames.Except(existingEntries.Select(x => x.Value))) 169 192 variableNamesView.Content.Add(new StringValue(variableName), true); 170 } 193 foreach (var oldEntry in existingEntries.Where(x => !Content.VariableNames.Contains(x.Value))) 194 variableNamesView.Content.Remove(oldEntry); 171 195 RegisterVariableNamesViewContentEvents(); 172 196
Note: See TracChangeset
for help on using the changeset viewer.