Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/16 22:35:39 (9 years ago)
Author:
abeham
Message:

#2457: worked on expert-system

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  
    237237
    238238    private void RefreshMapButtonOnClick(object sender, EventArgs e) {
    239       Content.UpdateInstanceProjection();
    240239      UpdateProjectionComboBox();
    241240    }
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/HeuristicLab.OptimizationExpertSystem-3.3.csproj

    r13718 r13720  
    183183    </Compile>
    184184    <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>
    185191    <Compile Include="Menu\0_Config\40_AdministerOkbMenuItem.cs" />
    186192    <Compile Include="Menu\0_Config\30_DownloadFromOkbMenuItem.cs" />
    187193    <Compile Include="Menu\0_Config\10_SetCredentialsMenuItem.cs" />
    188194    <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" />
    190197    <Compile Include="Menu\900_Tools\910_NewCSharpScriptMenuItem.cs" />
    191198    <Compile Include="Menu\900_Tools\930_SaveCSharpScriptMenuItem.cs" />
     199    <Compile Include="Menu\900_Tools\990_ShowAllInOneViewMenuItem.cs" />
    192200    <Compile Include="Menu\900_Tools\920_OpenCSharpScriptMenuItem.cs" />
    193201    <Compile Include="Menu\MenuItemBase.cs" />
     
    202210    </Compile>
    203211    <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>
    204218    <Compile Include="UnderstandingProblemInstanceView.cs">
    205219      <SubType>UserControl</SubType>
     
    207221    <Compile Include="UnderstandingProblemInstanceView.Designer.cs">
    208222      <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>
    209229    </Compile>
    210230    <Compile Include="Views\ExpertSystemViewBase.cs">
     
    252272      <DependentUpon>ExpertSystemView.cs</DependentUpon>
    253273    </EmbeddedResource>
     274    <EmbeddedResource Include="KnowledgeBaseView.resx">
     275      <DependentUpon>KnowledgeBaseView.cs</DependentUpon>
     276    </EmbeddedResource>
    254277    <EmbeddedResource Include="OptimizationExpertSystem.resx">
    255278      <DependentUpon>OptimizationExpertSystem.cs</DependentUpon>
    256279    </EmbeddedResource>
     280    <EmbeddedResource Include="SolverView.resx">
     281      <DependentUpon>SolverView.cs</DependentUpon>
     282    </EmbeddedResource>
    257283    <EmbeddedResource Include="UnderstandingProblemInstanceView.resx">
    258284      <DependentUpon>UnderstandingProblemInstanceView.cs</DependentUpon>
     285    </EmbeddedResource>
     286    <EmbeddedResource Include="UnderstandingSolutionsView.resx">
     287      <DependentUpon>UnderstandingSolutionsView.cs</DependentUpon>
    259288    </EmbeddedResource>
    260289    <EmbeddedResource Include="Views\ExpertSystemViewBase.resx">
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/0_Config/10_SetCredentialsMenuItem.cs

    r13718 r13720  
    2828      get { return "Set Username / Password..."; }
    2929    }
     30
    3031    public override IEnumerable<string> Structure {
    3132      get { return new[] { "Config" }; }
    3233    }
     34
    3335    public override int Position {
    3436      get { return 10; }
    3537    }
     38
    3639    public override string ToolTipText {
    3740      get { return "Set username and password for accessing HeuristicLab services"; }
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/0_Config/20_SetProblemMenuItem.cs

    r13718 r13720  
    2020#endregion
    2121
     22using HeuristicLab.Common.Resources;
    2223using System.Collections.Generic;
     24using System.Drawing;
    2325
    2426namespace HeuristicLab.OptimizationExpertSystem.Menu {
    2527  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"; }
    2832    }
    2933
     
    3236    }
    3337
    34     public override string Name {
    35       get { return "Problem Instance"; }
     38    public override int Position {
     39      get { return 20; }
    3640    }
    3741
     
    4044    }
    4145
    42     public override int Position {
    43       get { return 20; }
     46    public override void Execute() {
     47      MainForm.ShowContent(MainForm.ExpertSystem.Problem, true);
    4448    }
    4549  }
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/0_Config/30_DownloadFromOkbMenuItem.cs

    r13718 r13720  
    2020#endregion
    2121
     22using HeuristicLab.Common.Resources;
     23using System;
    2224using System.Collections.Generic;
     25using System.Drawing;
    2326
    2427namespace HeuristicLab.OptimizationExpertSystem.Menu {
    2528  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"; }
    2833    }
    2934
    3035    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" }; }
    3637    }
    3738
     
    3940      get { return 30; }
    4041    }
     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    }
    4158  }
    4259}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/0_Config/40_AdministerOkbMenuItem.cs

    r13718 r13720  
    2222using HeuristicLab.Clients.OKB;
    2323using HeuristicLab.Clients.OKB.Administration;
     24using HeuristicLab.Common.Resources;
    2425using HeuristicLab.MainForm;
    2526using System.Collections.Generic;
     27using System.Drawing;
    2628using System.Windows.Forms;
    2729
    2830namespace HeuristicLab.OptimizationExpertSystem.Menu {
    2931  internal class AdministerOKBMenuItem : MenuItemBase {
     32    public override Image Image { get { return VSImageLibrary.Database; } }
     33
    3034    public override string Name {
    31       get { return "Administer OKB"; }
     35      get { return "Admin"; }
    3236    }
     37
    3338    public override IEnumerable<string> Structure {
    34       get { return new[] { "Config" }; }
     39      get { return new[] { "Config", "OKB" }; }
    3540    }
     41
    3642    public override int Position {
    3743      get { return 40; }
    3844    }
     45
     46    public override string ToolTipText { get { return "Administrate the OKB."; } }
    3947
    4048    public override void Execute() {
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/100_Understanding/110_ProblemInstanceMenuItem.cs

    r13718 r13720  
    2020#endregion
    2121
     22using HeuristicLab.Common.Resources;
     23using HeuristicLab.MainForm.WindowsForms;
    2224using System.Collections.Generic;
     25using System.Drawing;
    2326using System.Linq;
    2427
    2528namespace HeuristicLab.OptimizationExpertSystem.Menu {
    2629  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"; }
    3134    }
    3235
     
    3538    }
    3639
    37     public override string Name {
    38       get { return "Problem Instance"; }
    39     }
    40 
    4140    public override int Position {
    4241      get { return 110; }
    4342    }
     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    }
    4450  }
    4551}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/100_Understanding/120_SolutionsMenuItem.cs

    r13718 r13720  
    2020#endregion
    2121
    22 using System;
     22using HeuristicLab.Common.Resources;
     23using HeuristicLab.MainForm.WindowsForms;
    2324using System.Collections.Generic;
     25using System.Drawing;
     26using System.Linq;
    2427
    2528namespace HeuristicLab.OptimizationExpertSystem.Menu {
    2629  internal class SolutionSimilarityMenuItem : MenuItemBase {
     30    public override Image Image { get { return VSImageLibrary.Performance; } }
     31
    2732    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);
    2937    }
    3038
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/200_Solving/210_SolverMenuItem.cs

    r13718 r13720  
    2020#endregion
    2121
    22 using System;
     22using HeuristicLab.Common.Resources;
     23using HeuristicLab.MainForm.WindowsForms;
    2324using System.Collections.Generic;
     25using System.Drawing;
     26using System.Linq;
    2427
    2528namespace HeuristicLab.OptimizationExpertSystem.Menu {
    2629  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"; }
    2934    }
    3035
     
    3338    }
    3439
    35     public override string Name {
    36       get { return "Solver"; }
    37     }
    38 
    3940    public override int Position {
    4041      get { return 210; }
    4142    }
     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    }
    4252  }
    4353}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/300_Learning/310_KnowledgeBaseMenuItem.cs

    r13719 r13720  
    2020#endregion
    2121
    22 using System;
     22using HeuristicLab.Common.Resources;
     23using HeuristicLab.MainForm.WindowsForms;
    2324using System.Collections.Generic;
     25using System.Drawing;
     26using System.Linq;
    2427
    2528namespace HeuristicLab.OptimizationExpertSystem.Menu {
    2629  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"; }
    2934    }
    3035
     
    3338    }
    3439
    35     public override string Name {
    36       get { return "Algorithm Instances"; }
    37     }
    38 
    3940    public override int Position {
    4041      get { return 310; }
    4142    }
     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    }
    4252  }
    4353}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/900_Tools/900_CSharpScriptMenuItem.cs

    r13718 r13720  
    2020#endregion
    2121
    22 using HeuristicLab.Scripting;
     22using HeuristicLab.Common.Resources;
    2323using System.Collections.Generic;
     24using System.Drawing;
    2425
    2526namespace 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"; }
    6632    }
    6733
    6834    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" }; }
    7436    }
    7537
    7638    public override int Position {
    77       get { return 910; }
     39      get { return 900; }
    7840    }
     41
     42    public override void Execute() { }
    7943  }
    8044}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/900_Tools/910_NewCSharpScriptMenuItem.cs

    r13718 r13720  
    2020#endregion
    2121
     22using HeuristicLab.Common.Resources;
    2223using HeuristicLab.Scripting;
    2324using System.Collections.Generic;
     25using System.Drawing;
    2426
    2527namespace HeuristicLab.OptimizationExpertSystem.Menu {
    2628  internal class NewCSharpScriptMenuItem : MenuItemBase {
     29    public override Image Image { get { return VSImageLibrary.NewDocument; } }
     30
    2731    #region CodeTemplate
    2832    private static readonly string CodeTemplate = @"
     
    6266    #endregion
    6367
    64     public override void Execute() {
    65       MainForm.ShowContent(new CSharpScript(CodeTemplate));
     68    public override string Name {
     69      get { return "New"; }
    6670    }
    6771
     
    7074    }
    7175
    72     public override string Name {
    73       get { return "New"; }
    74     }
    75 
    7676    public override int Position {
    7777      get { return 910; }
    7878    }
     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    }
    7985  }
    8086}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/900_Tools/920_OpenCSharpScriptMenuItem.cs

    r13718 r13720  
    2121
    2222using HeuristicLab.Common;
     23using HeuristicLab.Common.Resources;
    2324using HeuristicLab.Scripting;
    2425using System.Collections.Generic;
     26using System.Drawing;
    2527using System.Windows.Forms;
    2628
    2729namespace HeuristicLab.OptimizationExpertSystem.Menu {
    2830  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
    2947    public override void Execute() {
    3048      using (var dialog = new OpenFileDialog()) {
     
    3654      }
    3755    }
    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     }
    5056  }
    5157}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/900_Tools/990_ShowAllInOneViewMenuItem.cs

    r13719 r13720  
    2020#endregion
    2121
    22 using HeuristicLab.Common;
    23 using HeuristicLab.MainForm;
    24 using HeuristicLab.Scripting;
    25 using System;
    2622using System.Collections.Generic;
    27 using System.Windows.Forms;
    2823
    2924namespace 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 {
    3726    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));
    4328    }
    4429
    4530    public override IEnumerable<string> Structure {
    46       get { return new[] { "Tools", "C# Script" }; }
     31      get { return new[] { "Tools" }; }
    4732    }
    4833
    4934    public override string Name {
    50       get { return "Save"; }
     35      get { return "All-In-One View"; }
    5136    }
    5237
    5338    public override int Position {
    54       get { return 930; }
     39      get { return 990; }
    5540    }
    5641  }
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/OptimizationExpertSystem.cs

    r13667 r13720  
    2020#endregion
    2121
     22using HeuristicLab.Common;
     23using HeuristicLab.MainForm;
    2224using HeuristicLab.MainForm.WindowsForms;
    2325using HeuristicLab.OptimizationExpertSystem.Common;
    2426using System;
     27using System.Windows.Forms;
    2528
    2629namespace HeuristicLab.OptimizationExpertSystem {
    2730  public partial class OptimizationExpertSystem : DockingMainForm {
     31    private ToolStripProgressBar progressBar;
     32    private ToolStripLabel progressLabel;
    2833
    2934    public ExpertSystem ExpertSystem { get; private set; }
    30 
     35   
    3136    public OptimizationExpertSystem(Type userInterfaceType) : base(userInterfaceType) {
    3237      InitializeComponent();
    3338      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);
    3481    }
    3582
    3683    private void OptimizationExpertSystem_Load(object sender, EventArgs e) {
    37       ShowContent(ExpertSystem);
     84      ShowContent(ExpertSystem.Problem);
    3885    }
    3986  }
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/UnderstandingProblemInstanceView.cs

    r13718 r13720  
    2020#endregion
    2121
    22 using HeuristicLab.Clients.OKB.RunCreation;
    2322using HeuristicLab.MainForm;
    2423using HeuristicLab.OptimizationExpertSystem.Common;
     
    3736    }
    3837
    39     #region Register Content Events
    40     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     #endregion
    60 
    6138    protected override void OnContentChanged() {
    6239      base.OnContentChanged();
     
    6744      } else {
    6845        problemInstancesView.Content = Content.ProblemInstances;
    69         Content.UpdateInstanceProjection();
    7046        UpdateProjectionComboBox();
    7147      }
    7248    }
    7349
    74     private void ContentOnProblemChanged(object sender, EventArgs eventArgs) {
     50    #region Content Event Handlers
     51    protected override void OnProblemChanged() {
     52      base.OnProblemChanged();
    7553      SetEnabledStateOfControls();
     54    }
     55
     56    protected override void OnProblemInstancesChanged() {
     57      base.OnProblemInstancesChanged();
     58      if (Content.ProblemInstances.UpdateOfRunsInProgress) return;
     59      UpdateProjectionComboBox();
    7660    }
    7761
     
    8064      UpdateProjectionComboBox();
    8165    }
    82 
     66    #endregion
     67   
    8368    public IEnumerable<string> GetProjections() {
    8469      return Content.ProblemInstances
     
    129114        projectionComboBox.Items.Add(str);
    130115      }
     116      if (projectionComboBox.Items.Count > 0)
     117        projectionComboBox.SelectedIndex = 0;
    131118    }
    132119  }
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Views/ExpertSystemViewBase.cs

    r13718 r13720  
    2525using HeuristicLab.OptimizationExpertSystem.Common;
    2626using System;
     27using System.ComponentModel;
    2728
    2829namespace HeuristicLab.OptimizationExpertSystem {
     
    4243    }
    4344
     45    #region Event Registration
    4446    protected override void RegisterContentEvents() {
    4547      base.RegisterContentEvents();
     48      Content.PropertyChanged += ContentOnPropertyChanged;
    4649      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;
    4786    }
    4887
    4988    protected override void DeregisterContentEvents() {
    5089      base.DeregisterContentEvents();
     90      Content.PropertyChanged -= ContentOnPropertyChanged;
    5191      Content.DownloadStarted -= ContentOnDownloadStarted;
     92      DeregisterContentProblemEvents();
     93      DeregisterContentProblemInstancesEvents();
     94      DeregisterContentSolutionSeedingPoolEvents();
     95      DeregisterContentSuggestedInstancesEvents();
    5296    }
    5397
    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) { }
    55145    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() { }
    56152
     153    #region Content Event Handlers
    57154    private void ContentOnDownloadStarted(object sender, EventArgs<IProgress> e) {
    58155      if (InvokeRequired) { Invoke((Action<object, EventArgs<IProgress>>)ContentOnDownloadStarted, sender, e); return; }
    59156      MainForm.AddOperationProgressToView(this, e.Value);
    60157      e.Value.ProgressStateChanged += ProgressOnStateChanged;
    61       OnDownloadStarted();
     158      OnDownloadStarted(e.Value);
    62159    }
    63160
     
    68165      OnDownloadEnded();
    69166    }
     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
    70193  }
    71194}
Note: See TracChangeset for help on using the changeset viewer.