Changeset 13720 for branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/900_Tools
- Timestamp:
- 03/19/16 22:35:39 (9 years ago)
- 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 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 }
Note: See TracChangeset
for help on using the changeset viewer.