- Timestamp:
- 03/19/16 22:35:39 (9 years ago)
- Location:
- branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3
- Files:
-
- 10 added
- 14 edited
- 2 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/ExpertSystemView.cs
r13718 r13720 237 237 238 238 private void RefreshMapButtonOnClick(object sender, EventArgs e) { 239 Content.UpdateInstanceProjection();240 239 UpdateProjectionComboBox(); 241 240 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/HeuristicLab.OptimizationExpertSystem-3.3.csproj
r13718 r13720 183 183 </Compile> 184 184 <Compile Include="Interfaces\IOptimizationExpertSystemUi.cs" /> 185 <Compile Include="KnowledgeBaseView.cs"> 186 <SubType>UserControl</SubType> 187 </Compile> 188 <Compile Include="KnowledgeBaseView.Designer.cs"> 189 <DependentUpon>KnowledgeBaseView.cs</DependentUpon> 190 </Compile> 185 191 <Compile Include="Menu\0_Config\40_AdministerOkbMenuItem.cs" /> 186 192 <Compile Include="Menu\0_Config\30_DownloadFromOkbMenuItem.cs" /> 187 193 <Compile Include="Menu\0_Config\10_SetCredentialsMenuItem.cs" /> 188 194 <Compile Include="Menu\200_Solving\210_SolverMenuItem.cs" /> 189 <Compile Include="Menu\300_Learning\310_AlgorithmInstancesMenuItem.cs" /> 195 <Compile Include="Menu\300_Learning\310_KnowledgeBaseMenuItem.cs" /> 196 <Compile Include="Menu\900_Tools\900_CSharpScriptMenuItem.cs" /> 190 197 <Compile Include="Menu\900_Tools\910_NewCSharpScriptMenuItem.cs" /> 191 198 <Compile Include="Menu\900_Tools\930_SaveCSharpScriptMenuItem.cs" /> 199 <Compile Include="Menu\900_Tools\990_ShowAllInOneViewMenuItem.cs" /> 192 200 <Compile Include="Menu\900_Tools\920_OpenCSharpScriptMenuItem.cs" /> 193 201 <Compile Include="Menu\MenuItemBase.cs" /> … … 202 210 </Compile> 203 211 <Compile Include="Plugin.cs" /> 212 <Compile Include="SolverView.cs"> 213 <SubType>UserControl</SubType> 214 </Compile> 215 <Compile Include="SolverView.Designer.cs"> 216 <DependentUpon>SolverView.cs</DependentUpon> 217 </Compile> 204 218 <Compile Include="UnderstandingProblemInstanceView.cs"> 205 219 <SubType>UserControl</SubType> … … 207 221 <Compile Include="UnderstandingProblemInstanceView.Designer.cs"> 208 222 <DependentUpon>UnderstandingProblemInstanceView.cs</DependentUpon> 223 </Compile> 224 <Compile Include="UnderstandingSolutionsView.cs"> 225 <SubType>UserControl</SubType> 226 </Compile> 227 <Compile Include="UnderstandingSolutionsView.Designer.cs"> 228 <DependentUpon>UnderstandingSolutionsView.cs</DependentUpon> 209 229 </Compile> 210 230 <Compile Include="Views\ExpertSystemViewBase.cs"> … … 252 272 <DependentUpon>ExpertSystemView.cs</DependentUpon> 253 273 </EmbeddedResource> 274 <EmbeddedResource Include="KnowledgeBaseView.resx"> 275 <DependentUpon>KnowledgeBaseView.cs</DependentUpon> 276 </EmbeddedResource> 254 277 <EmbeddedResource Include="OptimizationExpertSystem.resx"> 255 278 <DependentUpon>OptimizationExpertSystem.cs</DependentUpon> 256 279 </EmbeddedResource> 280 <EmbeddedResource Include="SolverView.resx"> 281 <DependentUpon>SolverView.cs</DependentUpon> 282 </EmbeddedResource> 257 283 <EmbeddedResource Include="UnderstandingProblemInstanceView.resx"> 258 284 <DependentUpon>UnderstandingProblemInstanceView.cs</DependentUpon> 285 </EmbeddedResource> 286 <EmbeddedResource Include="UnderstandingSolutionsView.resx"> 287 <DependentUpon>UnderstandingSolutionsView.cs</DependentUpon> 259 288 </EmbeddedResource> 260 289 <EmbeddedResource Include="Views\ExpertSystemViewBase.resx"> -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/0_Config/10_SetCredentialsMenuItem.cs
r13718 r13720 28 28 get { return "Set Username / Password..."; } 29 29 } 30 30 31 public override IEnumerable<string> Structure { 31 32 get { return new[] { "Config" }; } 32 33 } 34 33 35 public override int Position { 34 36 get { return 10; } 35 37 } 38 36 39 public override string ToolTipText { 37 40 get { return "Set username and password for accessing HeuristicLab services"; } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/0_Config/20_SetProblemMenuItem.cs
r13718 r13720 20 20 #endregion 21 21 22 using HeuristicLab.Common.Resources; 22 23 using System.Collections.Generic; 24 using System.Drawing; 23 25 24 26 namespace HeuristicLab.OptimizationExpertSystem.Menu { 25 27 internal class SetProblemMenuItem : MenuItemBase { 26 public override void Execute() { 27 MainForm.ShowContent(MainForm.ExpertSystem.Problem, true); 28 public override Image Image { get { return VSImageLibrary.Edit; } } 29 30 public override string Name { 31 get { return "Problem Instance"; } 28 32 } 29 33 … … 32 36 } 33 37 34 public override string Name{35 get { return "Problem Instance"; }38 public override int Position { 39 get { return 20; } 36 40 } 37 41 … … 40 44 } 41 45 42 public override int Position{43 get { return 20; }46 public override void Execute() { 47 MainForm.ShowContent(MainForm.ExpertSystem.Problem, true); 44 48 } 45 49 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/0_Config/30_DownloadFromOkbMenuItem.cs
r13718 r13720 20 20 #endregion 21 21 22 using HeuristicLab.Common.Resources; 23 using System; 22 24 using System.Collections.Generic; 25 using System.Drawing; 23 26 24 27 namespace HeuristicLab.OptimizationExpertSystem.Menu { 25 28 internal class DownloadFromOKBMenuItem : MenuItemBase { 26 public override void Execute() { 27 MainForm.ExpertSystem.UpdateKnowledgeBaseAsync(); 29 public override Image Image { get { return VSImageLibrary.ArrowDown; } } 30 31 public override string Name { 32 get { return "Download"; } 28 33 } 29 34 30 35 public override IEnumerable<string> Structure { 31 get { return new[] { "Config" }; } 32 } 33 34 public override string Name { 35 get { return "Download from OKB"; } 36 get { return new[] { "Config", "OKB" }; } 36 37 } 37 38 … … 39 40 get { return 30; } 40 41 } 42 43 public override string ToolTipText { get { return "Download relevant runs from the knowledge base."; } } 44 45 public override void Execute() { 46 MainForm.ExpertSystem.UpdateKnowledgeBaseAsync(); 47 } 48 49 protected override void OnToolStripItemSet(EventArgs e) { 50 base.OnToolStripItemSet(e); 51 ToolStripItem.Enabled = MainForm.ExpertSystem.Problem.ProblemId != -1; 52 MainForm.ExpertSystem.Problem.ProblemChanged += OnProblemChanged; 53 } 54 55 private void OnProblemChanged(object sender, EventArgs e) { 56 ToolStripItem.Enabled = MainForm.ExpertSystem.Problem.ProblemId != -1; 57 } 41 58 } 42 59 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/0_Config/40_AdministerOkbMenuItem.cs
r13718 r13720 22 22 using HeuristicLab.Clients.OKB; 23 23 using HeuristicLab.Clients.OKB.Administration; 24 using HeuristicLab.Common.Resources; 24 25 using HeuristicLab.MainForm; 25 26 using System.Collections.Generic; 27 using System.Drawing; 26 28 using System.Windows.Forms; 27 29 28 30 namespace HeuristicLab.OptimizationExpertSystem.Menu { 29 31 internal class AdministerOKBMenuItem : MenuItemBase { 32 public override Image Image { get { return VSImageLibrary.Database; } } 33 30 34 public override string Name { 31 get { return "Admin ister OKB"; }35 get { return "Admin"; } 32 36 } 37 33 38 public override IEnumerable<string> Structure { 34 get { return new[] { "Config" }; }39 get { return new[] { "Config", "OKB" }; } 35 40 } 41 36 42 public override int Position { 37 43 get { return 40; } 38 44 } 45 46 public override string ToolTipText { get { return "Administrate the OKB."; } } 39 47 40 48 public override void Execute() { -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/100_Understanding/110_ProblemInstanceMenuItem.cs
r13718 r13720 20 20 #endregion 21 21 22 using HeuristicLab.Common.Resources; 23 using HeuristicLab.MainForm.WindowsForms; 22 24 using System.Collections.Generic; 25 using System.Drawing; 23 26 using System.Linq; 24 27 25 28 namespace HeuristicLab.OptimizationExpertSystem.Menu { 26 29 internal class ProblemInstanceMenuItem : MenuItemBase { 27 public override void Execute() {28 var view = MainForm.Views.OfType<UnderstandingProblemInstanceView>().FirstOrDefault(); 29 if (view != null) view.Show();30 else MainForm.ShowContent(MainForm.ExpertSystem, typeof(UnderstandingProblemInstanceView));30 public override Image Image { get { return VSImageLibrary.Statistics; } } 31 32 public override string Name { 33 get { return "Problem Instance"; } 31 34 } 32 35 … … 35 38 } 36 39 37 public override string Name {38 get { return "Problem Instance"; }39 }40 41 40 public override int Position { 42 41 get { return 110; } 43 42 } 43 44 public override void Execute() { 45 var viewType = typeof(UnderstandingProblemInstanceView); 46 var view = MainForm.Views.FirstOrDefault(x => viewType == ((x is ViewHost) ? ((ViewHost)x).ActiveView : x).GetType()); 47 if (view != null) view.Show(); 48 else MainForm.ShowContent(MainForm.ExpertSystem, viewType); 49 } 44 50 } 45 51 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/100_Understanding/120_SolutionsMenuItem.cs
r13718 r13720 20 20 #endregion 21 21 22 using System; 22 using HeuristicLab.Common.Resources; 23 using HeuristicLab.MainForm.WindowsForms; 23 24 using System.Collections.Generic; 25 using System.Drawing; 26 using System.Linq; 24 27 25 28 namespace HeuristicLab.OptimizationExpertSystem.Menu { 26 29 internal class SolutionSimilarityMenuItem : MenuItemBase { 30 public override Image Image { get { return VSImageLibrary.Performance; } } 31 27 32 public override void Execute() { 28 throw new NotImplementedException(); 33 var viewType = typeof(UnderstandingSolutionsView); 34 var view = MainForm.Views.FirstOrDefault(x => viewType == ((x is ViewHost) ? ((ViewHost)x).ActiveView : x).GetType()); 35 if (view != null) view.Show(); 36 else MainForm.ShowContent(MainForm.ExpertSystem, viewType); 29 37 } 30 38 -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/200_Solving/210_SolverMenuItem.cs
r13718 r13720 20 20 #endregion 21 21 22 using System; 22 using HeuristicLab.Common.Resources; 23 using HeuristicLab.MainForm.WindowsForms; 23 24 using System.Collections.Generic; 25 using System.Drawing; 26 using System.Linq; 24 27 25 28 namespace HeuristicLab.OptimizationExpertSystem.Menu { 26 29 internal class SolverMenuItem : MenuItemBase { 27 public override void Execute() { 28 throw new NotImplementedException(); 30 public override Image Image { get { return VSImageLibrary.Event; } } 31 32 public override string Name { 33 get { return "Solver"; } 29 34 } 30 35 … … 33 38 } 34 39 35 public override string Name {36 get { return "Solver"; }37 }38 39 40 public override int Position { 40 41 get { return 210; } 41 42 } 43 44 public override string ToolTipText { get { return "Solve the problem instance."; } } 45 46 public override void Execute() { 47 var viewType = typeof(SolverView); 48 var view = MainForm.Views.FirstOrDefault(x => viewType == ((x is ViewHost) ? ((ViewHost)x).ActiveView : x).GetType()); 49 if (view != null) view.Show(); 50 else MainForm.ShowContent(MainForm.ExpertSystem, viewType); 51 } 42 52 } 43 53 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/300_Learning/310_KnowledgeBaseMenuItem.cs
r13719 r13720 20 20 #endregion 21 21 22 using System; 22 using HeuristicLab.Common.Resources; 23 using HeuristicLab.MainForm.WindowsForms; 23 24 using System.Collections.Generic; 25 using System.Drawing; 26 using System.Linq; 24 27 25 28 namespace HeuristicLab.OptimizationExpertSystem.Menu { 26 29 internal class AlgorithmInstancesMenuItem : MenuItemBase { 27 public override void Execute() { 28 throw new NotImplementedException(); 30 public override Image Image { get { return VSImageLibrary.Library; } } 31 32 public override string Name { 33 get { return "Knowledge Base"; } 29 34 } 30 35 … … 33 38 } 34 39 35 public override string Name {36 get { return "Algorithm Instances"; }37 }38 39 40 public override int Position { 40 41 get { return 310; } 41 42 } 43 44 public override string ToolTipText { get { return "Study previously conducted runs on problem instances of the same class that are stored in the OKB."; } } 45 46 public override void Execute() { 47 var viewType = typeof(KnowledgeBaseView); 48 var view = MainForm.Views.FirstOrDefault(x => viewType == ((x is ViewHost) ? ((ViewHost)x).ActiveView : x).GetType()); 49 if (view != null) view.Show(); 50 else MainForm.ShowContent(MainForm.ExpertSystem, viewType); 51 } 42 52 } 43 53 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/900_Tools/900_CSharpScriptMenuItem.cs
r13718 r13720 20 20 #endregion 21 21 22 using HeuristicLab. Scripting;22 using HeuristicLab.Common.Resources; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 25 26 namespace HeuristicLab.OptimizationExpertSystem.Menu { 26 internal class NewCSharpScriptMenuItem : MenuItemBase { 27 #region CodeTemplate 28 private static readonly string CodeTemplate = @" 29 // use 'vars' to access variables in the script's variable store (e.g. vars.x = 5) 30 // use 'vars[string]' to access variables via runtime strings (e.g. vars[""x""] = 5) 31 // use 'vars.Contains(string)' to check if a variable exists 32 // use 'vars.Clear()' to remove all variables 33 // use 'foreach (KeyValuePair<string, object> v in vars) { ... }' to iterate over all variables 34 // use 'variables' to work with IEnumerable<T> extension methods on the script's variable store 35 36 using System; 37 using System.Linq; 38 using System.Collections.Generic; 39 40 using QueryClient = HeuristicLab.Clients.OKB.Query.QueryClient; 41 using RunCreationClient = HeuristicLab.Clients.OKB.RunCreation.RunCreationClient; 42 using AdministrationClient = HeuristicLab.Clients.OKB.Administration.AdministrationClient; 43 using HeuristicLab.Core; 44 using HeuristicLab.Common; 45 using HeuristicLab.Collections; 46 using HeuristicLab.Data; 47 using HeuristicLab.Optimization; 48 using HeuristicLab.OptimizationExpertSystem; 49 using HeuristicLab.OptimizationExpertSystem.Common; 50 using HeuristicLab.Random; 51 52 public class MyScript : HeuristicLab.Scripting.CSharpScriptBase { 53 public ExpertSystem Instance { get { return ((OptimizationExpertSystem)HeuristicLab.MainForm.MainFormManager.MainForm).ExpertSystem; } } 54 55 public override void Main() { 56 // type your code here 57 } 58 59 // implement further classes and methods 60 61 }"; 62 #endregion 63 64 public override void Execute() { 65 MainForm.ShowContent(new CSharpScript(CodeTemplate)); 27 internal class CSharpScriptMenuItem : MenuItemBase { 28 public override Image Image { get { return VSImageLibrary.Script; } } 29 30 public override string Name { 31 get { return "C# Script"; } 66 32 } 67 33 68 34 public override IEnumerable<string> Structure { 69 get { return new[] { "Tools", "C# Script" }; } 70 } 71 72 public override string Name { 73 get { return "New"; } 35 get { return new[] { "Tools" }; } 74 36 } 75 37 76 38 public override int Position { 77 get { return 9 10; }39 get { return 900; } 78 40 } 41 42 public override void Execute() { } 79 43 } 80 44 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/900_Tools/910_NewCSharpScriptMenuItem.cs
r13718 r13720 20 20 #endregion 21 21 22 using HeuristicLab.Common.Resources; 22 23 using HeuristicLab.Scripting; 23 24 using System.Collections.Generic; 25 using System.Drawing; 24 26 25 27 namespace HeuristicLab.OptimizationExpertSystem.Menu { 26 28 internal class NewCSharpScriptMenuItem : MenuItemBase { 29 public override Image Image { get { return VSImageLibrary.NewDocument; } } 30 27 31 #region CodeTemplate 28 32 private static readonly string CodeTemplate = @" … … 62 66 #endregion 63 67 64 public override void Execute(){65 MainForm.ShowContent(new CSharpScript(CodeTemplate));68 public override string Name { 69 get { return "New"; } 66 70 } 67 71 … … 70 74 } 71 75 72 public override string Name {73 get { return "New"; }74 }75 76 76 public override int Position { 77 77 get { return 910; } 78 78 } 79 80 public override string ToolTipText { get { return "Create a new C# Script"; } } 81 82 public override void Execute() { 83 MainForm.ShowContent(new CSharpScript(CodeTemplate)); 84 } 79 85 } 80 86 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/900_Tools/920_OpenCSharpScriptMenuItem.cs
r13718 r13720 21 21 22 22 using HeuristicLab.Common; 23 using HeuristicLab.Common.Resources; 23 24 using HeuristicLab.Scripting; 24 25 using System.Collections.Generic; 26 using System.Drawing; 25 27 using System.Windows.Forms; 26 28 27 29 namespace HeuristicLab.OptimizationExpertSystem.Menu { 28 30 internal class OpenCSharpScriptMenuItem : MenuItemBase { 31 public override Image Image { get { return VSImageLibrary.Open; } } 32 33 public override string Name { 34 get { return "Open"; } 35 } 36 37 public override IEnumerable<string> Structure { 38 get { return new[] { "Tools", "C# Script" }; } 39 } 40 41 public override int Position { 42 get { return 920; } 43 } 44 45 public override string ToolTipText { get { return "Open an existing C# Script."; } } 46 29 47 public override void Execute() { 30 48 using (var dialog = new OpenFileDialog()) { … … 36 54 } 37 55 } 38 39 public override IEnumerable<string> Structure {40 get { return new[] { "Tools", "C# Script" }; }41 }42 43 public override string Name {44 get { return "Open"; }45 }46 47 public override int Position {48 get { return 920; }49 }50 56 } 51 57 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/900_Tools/990_ShowAllInOneViewMenuItem.cs
r13719 r13720 20 20 #endregion 21 21 22 using HeuristicLab.Common;23 using HeuristicLab.MainForm;24 using HeuristicLab.Scripting;25 using System;26 22 using System.Collections.Generic; 27 using System.Windows.Forms;28 23 29 24 namespace HeuristicLab.OptimizationExpertSystem.Menu { 30 internal class SaveCSharpScriptMenuItem : MenuItemBase { 31 protected override void OnActiveViewChanged(object sender, EventArgs e) { 32 base.OnActiveViewChanged(sender, e); 33 var contentView = MainForm.ActiveView as IContentView; 34 ToolStripItem.Enabled = (contentView != null && contentView.Content is CSharpScript); 35 } 36 25 internal class ShowAllInOneViewMenuItem : MenuItemBase { 37 26 public override void Execute() { 38 using (var dialog = new SaveFileDialog()) { 39 dialog.Filter = "HL Files|*.hl"; 40 if (dialog.ShowDialog(MainForm) != DialogResult.OK) return; 41 ContentManager.Save((CSharpScript)((IContentView)MainForm.ActiveView).Content, dialog.FileName, true); 42 } 27 MainForm.ShowContent(MainForm.ExpertSystem, typeof(ExpertSystemView)); 43 28 } 44 29 45 30 public override IEnumerable<string> Structure { 46 get { return new[] { "Tools" , "C# Script"}; }31 get { return new[] { "Tools" }; } 47 32 } 48 33 49 34 public override string Name { 50 get { return " Save"; }35 get { return "All-In-One View"; } 51 36 } 52 37 53 38 public override int Position { 54 get { return 9 30; }39 get { return 990; } 55 40 } 56 41 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/OptimizationExpertSystem.cs
r13667 r13720 20 20 #endregion 21 21 22 using HeuristicLab.Common; 23 using HeuristicLab.MainForm; 22 24 using HeuristicLab.MainForm.WindowsForms; 23 25 using HeuristicLab.OptimizationExpertSystem.Common; 24 26 using System; 27 using System.Windows.Forms; 25 28 26 29 namespace HeuristicLab.OptimizationExpertSystem { 27 30 public partial class OptimizationExpertSystem : DockingMainForm { 31 private ToolStripProgressBar progressBar; 32 private ToolStripLabel progressLabel; 28 33 29 34 public ExpertSystem ExpertSystem { get; private set; } 30 35 31 36 public OptimizationExpertSystem(Type userInterfaceType) : base(userInterfaceType) { 32 37 InitializeComponent(); 33 38 ExpertSystem = new ExpertSystem(); 39 ExpertSystem.DownloadStarted += ExpertSystemOnDownloadStarted; 40 ShowContentInViewHost = false; 41 } 42 43 private void ExpertSystemOnDownloadStarted(object sender, EventArgs<IProgress> e) { 44 e.Value.ProgressStateChanged += OnProgressStateChanged; 45 e.Value.ProgressValueChanged += OnProgressValueChanged; 46 e.Value.StatusChanged += OnProgressStatusChanged; 47 progressBar.Value = progressBar.Minimum; 48 progressLabel.Text = string.Empty; 49 progressBar.Visible = true; 50 progressLabel.Visible = true; 51 } 52 53 private void OnProgressStateChanged(object sender, EventArgs e) { 54 var progress = (IProgress)sender; 55 if (progress.ProgressState == ProgressState.Canceled 56 || progress.ProgressState == ProgressState.Finished) { 57 progress.ProgressStateChanged -= OnProgressStateChanged; 58 progress.ProgressValueChanged -= OnProgressValueChanged; 59 progress.StatusChanged -= OnProgressStatusChanged; 60 progressBar.Visible = false; 61 progressLabel.Visible = false; 62 } 63 } 64 65 private void OnProgressValueChanged(object sender, EventArgs e) { 66 var progress = (IProgress)sender; 67 progressBar.Value = Math.Max(progressBar.Minimum, Math.Min(progressBar.Maximum, (int)(progress.ProgressValue * 100))); 68 } 69 70 private void OnProgressStatusChanged(object sender, EventArgs e) { 71 var progress = (IProgress)sender; 72 progressLabel.Text = progress.Status.Replace(Environment.NewLine, " "); 73 } 74 75 protected override void AdditionalCreationOfGuiElements() { 76 base.AdditionalCreationOfGuiElements(); 77 progressBar = new ToolStripProgressBar(); 78 statusStrip.Items.Add(progressBar); 79 progressLabel = new ToolStripLabel(); 80 statusStrip.Items.Add(progressLabel); 34 81 } 35 82 36 83 private void OptimizationExpertSystem_Load(object sender, EventArgs e) { 37 ShowContent(ExpertSystem );84 ShowContent(ExpertSystem.Problem); 38 85 } 39 86 } -
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/UnderstandingProblemInstanceView.cs
r13718 r13720 20 20 #endregion 21 21 22 using HeuristicLab.Clients.OKB.RunCreation;23 22 using HeuristicLab.MainForm; 24 23 using HeuristicLab.OptimizationExpertSystem.Common; … … 37 36 } 38 37 39 #region Register Content Events40 protected override void RegisterContentEvents() {41 base.RegisterContentEvents();42 RegisterProblemEvents(Content.Problem);43 }44 45 protected override void DeregisterContentEvents() {46 base.DeregisterContentEvents();47 DeregisterProblemEvents(Content.Problem);48 }49 50 private void DeregisterProblemEvents(OKBProblem problem) {51 if (problem == null) return;52 problem.ProblemChanged -= ContentOnProblemChanged;53 }54 55 private void RegisterProblemEvents(OKBProblem problem) {56 if (problem == null) return;57 problem.ProblemChanged += ContentOnProblemChanged;58 }59 #endregion60 61 38 protected override void OnContentChanged() { 62 39 base.OnContentChanged(); … … 67 44 } else { 68 45 problemInstancesView.Content = Content.ProblemInstances; 69 Content.UpdateInstanceProjection();70 46 UpdateProjectionComboBox(); 71 47 } 72 48 } 73 49 74 private void ContentOnProblemChanged(object sender, EventArgs eventArgs) { 50 #region Content Event Handlers 51 protected override void OnProblemChanged() { 52 base.OnProblemChanged(); 75 53 SetEnabledStateOfControls(); 54 } 55 56 protected override void OnProblemInstancesChanged() { 57 base.OnProblemInstancesChanged(); 58 if (Content.ProblemInstances.UpdateOfRunsInProgress) return; 59 UpdateProjectionComboBox(); 76 60 } 77 61 … … 80 64 UpdateProjectionComboBox(); 81 65 } 82 66 #endregion 67 83 68 public IEnumerable<string> GetProjections() { 84 69 return Content.ProblemInstances … … 129 114 projectionComboBox.Items.Add(str); 130 115 } 116 if (projectionComboBox.Items.Count > 0) 117 projectionComboBox.SelectedIndex = 0; 131 118 } 132 119 } -
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.