Changeset 11376
- Timestamp:
- 09/17/14 13:34:06 (10 years ago)
- Location:
- branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ChartAnalysisView.cs
r11375 r11376 25 25 using System.Threading.Tasks; 26 26 using System.Windows.Forms; 27 using HeuristicLab.Collections; 27 28 using HeuristicLab.Common; 29 using HeuristicLab.Core; 28 30 using HeuristicLab.Core.Views; 29 31 using HeuristicLab.Data; 30 32 using HeuristicLab.MainForm; 31 using HeuristicLab.MainForm.WindowsForms;32 33 using HeuristicLab.Optimization; 33 34 using HeuristicLab.PluginInfrastructure; … … 50 51 private IProgress progress; 51 52 private bool valuesAdded = false; 53 private bool suppressUpdates = false; 52 54 53 55 public ChartAnalysisView() { … … 75 77 protected override void OnContentChanged() { 76 78 base.OnContentChanged(); 79 UpdateComboboxes(); 80 UpdateCaption(); 81 } 82 83 private void UpdateCaption() { 84 Caption = Content != null ? Content.OptimizerName + " Chart Analysis" : ViewAttribute.GetViewName(GetType()); 85 } 86 87 private void UpdateComboboxes() { 77 88 dataTableComboBox.Items.Clear(); 78 89 dataRowComboBox.Items.Clear(); … … 81 92 UpdateDataTableComboBox(); 82 93 } 83 UpdateCaption();84 }85 86 private void UpdateCaption() {87 Caption = Content != null ? Content.OptimizerName + " Chart Analysis" : ViewAttribute.GetViewName(GetType());88 94 } 89 95 90 96 protected override void RegisterContentEvents() { 91 97 base.RegisterContentEvents(); 92 Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);93 Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);94 Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);98 Content.ItemsAdded += Content_ItemsAdded; 99 Content.ItemsRemoved += Content_ItemsRemoved; 100 Content.CollectionReset += Content_CollectionReset; 95 101 Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged; 102 RegisterRunEvents(Content); 96 103 } 97 104 98 105 protected override void DeregisterContentEvents() { 99 106 base.DeregisterContentEvents(); 100 Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);101 Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);102 Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);107 Content.ItemsAdded -= Content_ItemsAdded; 108 Content.ItemsRemoved -= Content_ItemsRemoved; 109 Content.CollectionReset -= Content_CollectionReset; 103 110 Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged; 104 } 105 106 private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 111 DeregisterRunEvents(Content); 112 } 113 114 private void RegisterRunEvents(IEnumerable<IRun> runs) { 115 foreach (IRun run in runs) { 116 RegisterRunParametersEvents(run); 117 RegisterRunResultsEvents(run); 118 } 119 } 120 121 private void DeregisterRunEvents(IEnumerable<IRun> runs) { 122 foreach (IRun run in runs) { 123 DeregisterRunParametersEvents(run); 124 DeregisterRunResultsEvents(run); 125 } 126 } 127 128 private void RegisterRunParametersEvents(IRun run) { 129 IObservableDictionary<string, IItem> dict = run.Parameters; 130 dict.ItemsAdded += run_Changed; 131 dict.ItemsRemoved += run_Changed; 132 dict.ItemsReplaced += run_Changed; 133 dict.CollectionReset += run_Changed; 134 } 135 136 private void RegisterRunResultsEvents(IRun run) { 137 IObservableDictionary<string, IItem> dict = run.Results; 138 dict.ItemsAdded += run_Changed; 139 dict.ItemsRemoved += run_Changed; 140 dict.ItemsReplaced += run_Changed; 141 dict.CollectionReset += run_Changed; 142 } 143 144 private void DeregisterRunParametersEvents(IRun run) { 145 IObservableDictionary<string, IItem> dict = run.Parameters; 146 dict.ItemsAdded -= run_Changed; 147 dict.ItemsRemoved -= run_Changed; 148 dict.ItemsReplaced -= run_Changed; 149 dict.CollectionReset -= run_Changed; 150 } 151 152 private void DeregisterRunResultsEvents(IRun run) { 153 IObservableDictionary<string, IItem> dict = run.Results; 154 dict.ItemsAdded -= run_Changed; 155 dict.ItemsRemoved -= run_Changed; 156 dict.ItemsReplaced -= run_Changed; 157 dict.CollectionReset -= run_Changed; 158 } 159 160 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 161 DeregisterRunEvents(e.OldItems); 162 RegisterRunEvents(e.Items); 163 UpdateComboboxes(); 107 164 RebuildDataTableAsync(); 108 165 } 109 166 110 private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 167 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 168 DeregisterRunEvents(e.Items); 111 169 RebuildDataTableAsync(); 112 170 } 113 171 114 private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 172 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 173 RegisterRunEvents(e.Items); 115 174 RebuildDataTableAsync(); 116 175 } 117 176 118 177 void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 119 if (!Content.UpdateOfRunsInProgress && !valuesAdded) { 178 suppressUpdates = Content.UpdateOfRunsInProgress; 179 180 if (!suppressUpdates && !valuesAdded) { 120 181 RebuildDataTableAsync(); 121 182 } 122 183 if (valuesAdded) { 123 184 valuesAdded = false; 185 } 186 } 187 188 private void run_Changed(object sender, EventArgs e) { 189 if (InvokeRequired) 190 Invoke(new EventHandler(run_Changed), sender, e); 191 else if (!suppressUpdates) { 192 UpdateComboboxes(); 124 193 } 125 194 } … … 147 216 148 217 private void addLineToChart_Click(object sender, EventArgs e) { 149 MainFormManager.GetMainForm< HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Adding fitted lines to charts...");150 151 var task = System.Threading.Tasks.Task.Factory.StartNew(AddLineToChart);218 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Adding fitted lines to charts..."); 219 220 var task = Task.Factory.StartNew(AddLineToChart); 152 221 153 222 task.ContinueWith((t) => { 154 MainFormManager.GetMainForm< HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);223 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 155 224 ErrorHandling.ShowErrorDialog("An error occured while adding lines to charts. ", t.Exception); 156 225 }, TaskContinuationOptions.OnlyOnFaulted); 157 226 158 227 task.ContinueWith((t) => { 159 MainFormManager.GetMainForm< HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);228 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 160 229 }, TaskContinuationOptions.OnlyOnRanToCompletion); 161 230 } … … 227 296 228 297 private void RebuildDataTableAsync() { 229 progress = MainFormManager.GetMainForm< HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values...");298 progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values..."); 230 299 231 300 var task = Task.Factory.StartNew(RebuildDataTable); 232 301 233 302 task.ContinueWith((t) => { 234 MainFormManager.GetMainForm< HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);303 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 235 304 ErrorHandling.ShowErrorDialog("An error occured while calculating values. ", t.Exception); 236 305 }, TaskContinuationOptions.OnlyOnFaulted); 237 306 238 307 task.ContinueWith((t) => { 239 MainFormManager.GetMainForm< HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);308 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 240 309 }, TaskContinuationOptions.OnlyOnRanToCompletion); 241 310 } … … 298 367 299 368 i++; 300 progress.ProgressValue = runs.Count/ i;369 progress.ProgressValue = ((double)runs.Count) / i; 301 370 } 302 371 stringConvertibleMatrixView.Content = dt; -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.cs
r11375 r11376 43 43 44 44 private bool suppressUpdates = false; 45 private string xAxisValue;46 45 private string yAxisValue; 47 46 private Dictionary<int, Dictionary<object, double>> categoricalMapping; … … 139 138 } 140 139 141 private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {140 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 142 141 DeregisterRunEvents(e.OldItems); 143 142 RegisterRunEvents(e.Items); 144 143 } 145 private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {144 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 146 145 DeregisterRunEvents(e.Items); 147 146 } 148 private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {147 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 149 148 RegisterRunEvents(e.Items); 150 149 } … … 397 396 398 397 399 this.xAxisValue = xAxisComboBox.Text;400 398 if (!yAxisComboBox.DroppedDown) 401 399 this.yAxisValue = (string)yAxisComboBox.SelectedItem;
Note: See TracChangeset
for help on using the changeset viewer.