Changeset 11378 for branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/CorrelationView.cs
- Timestamp:
- 09/17/14 17:34:43 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/CorrelationView.cs
r11375 r11378 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Windows.Forms; 25 using HeuristicLab.Collections; 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Core.Views; 27 28 using HeuristicLab.Data; … … 49 50 50 51 private Dictionary<string, ResultParameterType> resultsParameters; 52 private bool suppressUpdates = false; 51 53 52 54 public CorrelationView() { … … 61 63 62 64 if (Content != null) { 63 resultsParameters = GetRowNames();64 65 UpdateResultComboBox(); 65 66 } … … 78 79 Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 79 80 Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged; 81 RegisterRunEvents(Content); 80 82 } 81 83 … … 86 88 Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 87 89 Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged; 90 DeregisterRunEvents(Content); 91 } 92 93 private void RegisterRunEvents(IEnumerable<IRun> runs) { 94 foreach (IRun run in runs) { 95 RegisterRunResultsEvents(run); 96 RegisterRunParametersEvents(run); 97 run.PropertyChanged += run_PropertyChanged; 98 } 99 } 100 101 private void DeregisterRunEvents(IEnumerable<IRun> runs) { 102 foreach (IRun run in runs) { 103 DeregisterRunResultsEvents(run); 104 DeregisterRunParametersEvents(run); 105 run.PropertyChanged -= run_PropertyChanged; 106 } 107 } 108 109 private void RegisterRunResultsEvents(IRun run) { 110 IObservableDictionary<string, IItem> dict = run.Results; 111 dict.ItemsAdded += run_Changed; 112 dict.ItemsRemoved += run_Changed; 113 dict.ItemsReplaced += run_Changed; 114 dict.CollectionReset += run_Changed; 115 } 116 117 private void DeregisterRunResultsEvents(IRun run) { 118 IObservableDictionary<string, IItem> dict = run.Results; 119 dict.ItemsAdded -= run_Changed; 120 dict.ItemsRemoved -= run_Changed; 121 dict.ItemsReplaced -= run_Changed; 122 dict.CollectionReset -= run_Changed; 123 } 124 125 private void RegisterRunParametersEvents(IRun run) { 126 IObservableDictionary<string, IItem> dict = run.Parameters; 127 dict.ItemsAdded += run_Changed; 128 dict.ItemsRemoved += run_Changed; 129 dict.ItemsReplaced += run_Changed; 130 dict.CollectionReset += run_Changed; 131 } 132 133 private void DeregisterRunParametersEvents(IRun run) { 134 IObservableDictionary<string, IItem> dict = run.Parameters; 135 dict.ItemsAdded -= run_Changed; 136 dict.ItemsRemoved -= run_Changed; 137 dict.ItemsReplaced -= run_Changed; 138 dict.CollectionReset -= run_Changed; 88 139 } 89 140 90 141 private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 91 RebuildCorrelationTable();142 UpdateUI(); 92 143 } 93 144 94 145 private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 95 RebuildCorrelationTable();146 UpdateUI(); 96 147 } 97 148 98 149 private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 99 RebuildCorrelationTable(); 100 } 101 102 void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 103 if (!Content.UpdateOfRunsInProgress) { 150 UpdateUI(); 151 } 152 153 private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 154 suppressUpdates = Content.UpdateOfRunsInProgress; 155 UpdateUI(); 156 } 157 158 private void run_Changed(object sender, EventArgs e) { 159 if (InvokeRequired) { 160 Invoke(new EventHandler(run_Changed), sender, e); 161 } 162 UpdateUI(); 163 } 164 165 void run_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { 166 UpdateUI(); 167 } 168 #endregion 169 170 private void UpdateUI() { 171 if (!suppressUpdates) { 172 UpdateResultComboBox(); 104 173 RebuildCorrelationTable(); 105 174 } 106 175 } 107 #endregion108 176 109 177 private void UpdateResultComboBox() { 178 resultsParameters = GetRowNames(); 179 string selectedResult = (string)this.resultComboBox.SelectedItem; 110 180 resultComboBox.Items.Clear(); 111 112 181 resultComboBox.Items.AddRange(resultsParameters.Keys.ToArray()); 113 if (resultComboBox.Items.Count > 0) resultComboBox.SelectedItem = resultComboBox.Items[0]; 182 183 if (selectedResult != null && resultComboBox.Items.Contains(selectedResult)) { 184 resultComboBox.SelectedItem = selectedResult; 185 } else if (resultComboBox.Items.Count > 0) { 186 resultComboBox.SelectedItem = resultComboBox.Items[0]; 187 } 114 188 } 115 189 … … 195 269 var resultVals = GetDoublesFromResults(runs.Where(x => x.Results.ContainsKey(resultName)).Where(x => x.Results[resultName] is DoubleValue || x.Results[resultName] is IntValue).ToList(), resultName); 196 270 197 List<double> resultRowVals = new List<double>();271 List<double> resultRowVals; 198 272 if (rowName.Value == ResultParameterType.Result) { 199 273 resultRowVals = GetDoublesFromResults(runs.Where(x => x.Results.ContainsKey(rowName.Key)).Where(x => x.Results[rowName.Key] is DoubleValue || x.Results[rowName.Key] is IntValue).ToList(), rowName.Key);
Note: See TracChangeset
for help on using the changeset viewer.