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/Menu/900_Tools
Files:
1 added
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.