- Timestamp:
- 07/07/15 11:05:07 (9 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis.Statistics.Views/3.3/ChartAnalysisView.cs
r12599 r12631 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Threading; 25 26 using System.Threading.Tasks; 26 27 using System.Windows.Forms; … … 52 53 private bool valuesAdded = false; 53 54 private bool suppressUpdates = false; 55 private SemaphoreSlim sem = new SemaphoreSlim(1, 1); 54 56 55 57 public ChartAnalysisView() { … … 119 121 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_ColumnsChanged, sender, e); 120 122 else { 123 UpdateDataTableComboBox(); 121 124 RebuildDataTableAsync(); 122 125 } … … 138 141 139 142 if (!suppressUpdates && !valuesAdded) { 143 UpdateDataTableComboBox(); 140 144 RebuildDataTableAsync(); 141 145 } … … 164 168 165 169 private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) { 170 if (suppressUpdates) return; 166 171 RebuildDataTableAsync(); 167 172 } … … 266 271 string rowName = (string)dataRowComboBox.SelectedItem; 267 272 268 progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values..."); 269 var task = Task.Factory.StartNew(() => RebuildDataTable(resultName, rowName)); 273 var task = Task.Factory.StartNew(() => { 274 sem.Wait(); 275 progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values..."); 276 RebuildDataTable(resultName, rowName); 277 }); 270 278 271 279 task.ContinueWith((t) => { 272 280 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 273 281 ErrorHandling.ShowErrorDialog("An error occured while calculating values. ", t.Exception); 282 sem.Release(); 274 283 }, TaskContinuationOptions.OnlyOnFaulted); 275 284 276 285 task.ContinueWith((t) => { 277 286 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 287 sem.Release(); 278 288 }, TaskContinuationOptions.OnlyOnRanToCompletion); 279 289 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs
r12599 r12631 24 24 using System.ComponentModel; 25 25 using System.Linq; 26 using System.Windows.Forms;27 26 using HeuristicLab.Analysis; 28 27 using HeuristicLab.Collections; … … 41 40 } 42 41 43 private int rowNumber = 0;42 private int rowNumber; 44 43 private bool suppressUpdates; 45 44 private readonly Dictionary<IRun, IEnumerable<DataRow>> runMapping; … … 60 59 protected override void RegisterContentEvents() { 61 60 base.RegisterContentEvents(); 62 Content.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);63 Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);64 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);65 Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);66 Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged);61 Content.ItemsAdded += Content_ItemsAdded; 62 Content.ItemsRemoved += Content_ItemsRemoved; 63 Content.CollectionReset += Content_CollectionReset; 64 Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged; 65 Content.OptimizerNameChanged += Content_AlgorithmNameChanged; 67 66 } 68 67 protected override void DeregisterContentEvents() { 69 Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);70 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);71 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);72 Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);73 Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged);68 Content.ItemsAdded -= Content_ItemsAdded; 69 Content.ItemsRemoved -= Content_ItemsRemoved; 70 Content.CollectionReset -= Content_CollectionReset; 71 Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged; 72 Content.OptimizerNameChanged -= Content_AlgorithmNameChanged; 74 73 base.DeregisterContentEvents(); 75 74 } 76 75 77 76 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 77 if (suppressUpdates) return; 78 78 if (InvokeRequired) { 79 79 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); 80 80 return; 81 81 } 82 UpdateDataTableComboBox(); 83 UpdateDataRowComboBox(); 82 84 AddRuns(e.Items); 83 85 } 84 86 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 87 if (suppressUpdates) return; 85 88 if (InvokeRequired) { 86 89 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e); 87 90 return; 88 91 } 92 UpdateDataTableComboBox(); 93 UpdateDataRowComboBox(); 89 94 RemoveRuns(e.Items); 90 95 } 91 96 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 97 if (suppressUpdates) return; 92 98 if (InvokeRequired) { 93 99 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e); 94 100 return; 95 101 } 102 UpdateDataTableComboBox(); 103 UpdateDataRowComboBox(); 96 104 RemoveRuns(e.OldItems); 97 105 AddRuns(e.Items); … … 108 116 } 109 117 suppressUpdates = Content.UpdateOfRunsInProgress; 110 if (!suppressUpdates) UpdateRuns(Content); 118 if (!suppressUpdates) { 119 UpdateDataTableComboBox(); 120 UpdateDataRowComboBox(); 121 UpdateRuns(Content); 122 } 111 123 } 112 124 … … 124 136 var run = (IRun)sender; 125 137 if (e.PropertyName == "Color" || e.PropertyName == "Visible") 126 UpdateRuns(new IRun[] { run });138 UpdateRuns(new[] { run }); 127 139 } 128 140 } … … 205 217 206 218 private void UpdateDataTableComboBox() { 219 string selectedItem = (string)dataTableComboBox.SelectedItem; 220 207 221 dataTableComboBox.Items.Clear(); 208 222 var dataTables = (from run in Content … … 212 226 213 227 dataTableComboBox.Items.AddRange(dataTables); 214 if (dataTableComboBox.Items.Count > 0) dataTableComboBox.SelectedItem = dataTableComboBox.Items[0]; 228 if (selectedItem != null && dataTableComboBox.Items.Contains(selectedItem)) { 229 dataTableComboBox.SelectedItem = selectedItem; 230 } else if (dataTableComboBox.Items.Count > 0) { 231 dataTableComboBox.SelectedItem = dataTableComboBox.Items[0]; 232 } 215 233 } 216 234 … … 220 238 221 239 private void UpdateDataRowComboBox() { 240 string selectedItem = (string)dataRowComboBox.SelectedItem; 241 222 242 dataRowComboBox.Items.Clear(); 223 243 var resultName = (string)dataTableComboBox.SelectedItem; … … 231 251 dataRowComboBox.Items.AddRange(rowNames); 232 252 dataRowComboBox.Items.Add(AllDataRows); 233 if (dataRowComboBox.Items.Count > 0) dataRowComboBox.SelectedItem = dataRowComboBox.Items[0]; 234 } 235 236 private void dataTableComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 237 UpdateDataRowComboBox(); 238 } 239 private void dataRowComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 253 if (selectedItem != null && dataRowComboBox.Items.Contains(selectedItem)) { 254 dataRowComboBox.SelectedItem = selectedItem; 255 } else if (dataRowComboBox.Items.Count > 0) { 256 dataRowComboBox.SelectedItem = dataRowComboBox.Items[0]; 257 } 258 } 259 260 private void dataTableComboBox_SelectedIndexChanged(object sender, EventArgs e) { 261 UpdateDataRowComboBox(); 262 } 263 private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) { 264 if (suppressUpdates) return; 240 265 RebuildCombinedDataTable(); 241 266 }
Note: See TracChangeset
for help on using the changeset viewer.