- Timestamp:
- 03/19/16 22:35:39 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Views/ExpertSystemViewBase.cs
r13718 r13720 25 25 using HeuristicLab.OptimizationExpertSystem.Common; 26 26 using System; 27 using System.ComponentModel; 27 28 28 29 namespace HeuristicLab.OptimizationExpertSystem { … … 42 43 } 43 44 45 #region Event Registration 44 46 protected override void RegisterContentEvents() { 45 47 base.RegisterContentEvents(); 48 Content.PropertyChanged += ContentOnPropertyChanged; 46 49 Content.DownloadStarted += ContentOnDownloadStarted; 50 RegisterContentProblemEvents(); 51 RegisterContentProblemInstancesEvents(); 52 RegisterContentSolutionSeedingPoolEvents(); 53 RegisterContentSuggestedInstancesEvents(); 54 } 55 56 private void RegisterContentProblemEvents() { 57 Content.Problem.ProblemChanged += ContentOnProblemChanged; 58 Content.Problem.Solutions.CollectionReset += ContentOnProblemSolutionsChanged; 59 Content.Problem.Solutions.ItemsAdded += ContentOnProblemSolutionsChanged; 60 Content.Problem.Solutions.ItemsReplaced += ContentOnProblemSolutionsChanged; 61 Content.Problem.Solutions.ItemsRemoved += ContentOnProblemSolutionsChanged; 62 } 63 64 private void RegisterContentProblemInstancesEvents() { 65 Content.ProblemInstances.UpdateOfRunsInProgressChanged += ContentOnProblemInstancesChanged; 66 Content.ProblemInstances.ItemsAdded += ContentOnProblemInstancesChanged; 67 Content.ProblemInstances.ItemsRemoved += ContentOnProblemInstancesChanged; 68 Content.ProblemInstances.CollectionReset += ContentOnProblemInstancesChanged; 69 Content.ProblemInstances.ItemChanged += ContentOnProblemInstancesChanged; 70 } 71 72 private void RegisterContentSolutionSeedingPoolEvents() { 73 Content.SolutionSeedingPool.CheckedItemsChanged += ContentOnSolutionSeedingPoolChanged; 74 Content.SolutionSeedingPool.CollectionReset += ContentOnSolutionSeedingPoolChanged; 75 Content.SolutionSeedingPool.ItemsAdded += ContentOnSolutionSeedingPoolChanged; 76 Content.SolutionSeedingPool.ItemsRemoved += ContentOnSolutionSeedingPoolChanged; 77 Content.SolutionSeedingPool.ItemsReplaced += ContentOnSolutionSeedingPoolChanged; 78 } 79 80 private void RegisterContentSuggestedInstancesEvents() { 81 Content.SuggestedInstances.CollectionReset += ContentOnSuggestedInstancesChanged; 82 Content.SuggestedInstances.ItemsAdded += ContentOnSuggestedInstancesChanged; 83 Content.SuggestedInstances.ItemsMoved += ContentOnSuggestedInstancesChanged; 84 Content.SuggestedInstances.ItemsRemoved += ContentOnSuggestedInstancesChanged; 85 Content.SuggestedInstances.ItemsReplaced += ContentOnSuggestedInstancesChanged; 47 86 } 48 87 49 88 protected override void DeregisterContentEvents() { 50 89 base.DeregisterContentEvents(); 90 Content.PropertyChanged -= ContentOnPropertyChanged; 51 91 Content.DownloadStarted -= ContentOnDownloadStarted; 92 DeregisterContentProblemEvents(); 93 DeregisterContentProblemInstancesEvents(); 94 DeregisterContentSolutionSeedingPoolEvents(); 95 DeregisterContentSuggestedInstancesEvents(); 52 96 } 53 97 54 protected virtual void OnDownloadStarted() { } 98 private void DeregisterContentProblemEvents() { 99 Content.Problem.ProblemChanged -= ContentOnProblemChanged; 100 Content.Problem.Solutions.CollectionReset -= ContentOnProblemSolutionsChanged; 101 Content.Problem.Solutions.ItemsAdded -= ContentOnProblemSolutionsChanged; 102 Content.Problem.Solutions.ItemsReplaced -= ContentOnProblemSolutionsChanged; 103 Content.Problem.Solutions.ItemsRemoved -= ContentOnProblemSolutionsChanged; 104 } 105 106 private void DeregisterContentProblemInstancesEvents() { 107 Content.ProblemInstances.UpdateOfRunsInProgressChanged -= ContentOnProblemInstancesChanged; 108 Content.ProblemInstances.ItemsAdded -= ContentOnProblemInstancesChanged; 109 Content.ProblemInstances.ItemsRemoved -= ContentOnProblemInstancesChanged; 110 Content.ProblemInstances.CollectionReset -= ContentOnProblemInstancesChanged; 111 Content.ProblemInstances.ItemChanged -= ContentOnProblemInstancesChanged; 112 } 113 114 private void DeregisterContentSolutionSeedingPoolEvents() { 115 Content.SolutionSeedingPool.CheckedItemsChanged -= ContentOnSolutionSeedingPoolChanged; 116 Content.SolutionSeedingPool.CollectionReset -= ContentOnSolutionSeedingPoolChanged; 117 Content.SolutionSeedingPool.ItemsAdded -= ContentOnSolutionSeedingPoolChanged; 118 Content.SolutionSeedingPool.ItemsRemoved -= ContentOnSolutionSeedingPoolChanged; 119 Content.SolutionSeedingPool.ItemsReplaced -= ContentOnSolutionSeedingPoolChanged; 120 } 121 122 private void DeregisterContentSuggestedInstancesEvents() { 123 Content.SuggestedInstances.CollectionReset -= ContentOnSuggestedInstancesChanged; 124 Content.SuggestedInstances.ItemsAdded -= ContentOnSuggestedInstancesChanged; 125 Content.SuggestedInstances.ItemsMoved -= ContentOnSuggestedInstancesChanged; 126 Content.SuggestedInstances.ItemsRemoved -= ContentOnSuggestedInstancesChanged; 127 Content.SuggestedInstances.ItemsReplaced -= ContentOnSuggestedInstancesChanged; 128 } 129 #endregion 130 131 private void ContentOnPropertyChanged(object sender, PropertyChangedEventArgs e) { 132 if (InvokeRequired) Invoke((Action<string>)OnPropertyChanged, e.PropertyName); 133 else { 134 switch (e.PropertyName) { 135 case "Problem": RegisterContentProblemEvents(); break; 136 case "ProblemInstances": RegisterContentProblemInstancesEvents(); break; 137 case "SolutionSeedingPool": RegisterContentSolutionSeedingPoolEvents(); break; 138 case "SuggestedInstances": RegisterContentSuggestedInstancesEvents(); break; 139 } 140 OnPropertyChanged(e.PropertyName); 141 } 142 } 143 144 protected virtual void OnDownloadStarted(IProgress progress) { } 55 145 protected virtual void OnDownloadEnded() { } 146 protected virtual void OnPropertyChanged(string propertyName) { } 147 protected virtual void OnProblemChanged() { } 148 protected virtual void OnProblemSolutionsChanged() { } 149 protected virtual void OnProblemInstancesChanged() { } 150 protected virtual void OnSolutionSeedingPoolChanged() { } 151 protected virtual void OnSuggestedInstancesChanged() { } 56 152 153 #region Content Event Handlers 57 154 private void ContentOnDownloadStarted(object sender, EventArgs<IProgress> e) { 58 155 if (InvokeRequired) { Invoke((Action<object, EventArgs<IProgress>>)ContentOnDownloadStarted, sender, e); return; } 59 156 MainForm.AddOperationProgressToView(this, e.Value); 60 157 e.Value.ProgressStateChanged += ProgressOnStateChanged; 61 OnDownloadStarted( );158 OnDownloadStarted(e.Value); 62 159 } 63 160 … … 68 165 OnDownloadEnded(); 69 166 } 167 168 private void ContentOnProblemChanged(object sender, EventArgs e) { 169 if (InvokeRequired) Invoke((Action)OnProblemChanged); 170 else OnProblemChanged(); 171 } 172 173 private void ContentOnProblemSolutionsChanged(object sender, EventArgs e) { 174 if (InvokeRequired) Invoke((Action)OnProblemSolutionsChanged); 175 else OnProblemSolutionsChanged(); 176 } 177 178 private void ContentOnProblemInstancesChanged(object sender, EventArgs e) { 179 if (InvokeRequired) Invoke((Action)OnProblemInstancesChanged); 180 else OnProblemInstancesChanged(); 181 } 182 183 private void ContentOnSolutionSeedingPoolChanged(object sender, EventArgs e) { 184 if (InvokeRequired) Invoke((Action)OnSolutionSeedingPoolChanged); 185 else OnSolutionSeedingPoolChanged(); 186 } 187 188 private void ContentOnSuggestedInstancesChanged(object sender, EventArgs e) { 189 if (InvokeRequired) Invoke((Action)OnSuggestedInstancesChanged); 190 else OnSuggestedInstancesChanged(); 191 } 192 #endregion 70 193 } 71 194 }
Note: See TracChangeset
for help on using the changeset viewer.