Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1614_GeneralizedQAP/HeuristicLab.OptimizationExpertSystem/3.3/Menu/900_Tools/910_NewCSharpScriptMenuItem.cs @ 15721

Last change on this file since 15721 was 13750, checked in by abeham, 8 years ago

#2457: Added SOM projection for problem instances, fixed a bug (learningRadius was not used)

File size: 3.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Common.Resources;
23using HeuristicLab.Scripting;
24using System.Collections.Generic;
25using System.Drawing;
26
27namespace HeuristicLab.OptimizationExpertSystem.Menu {
28  internal class NewCSharpScriptMenuItem : MenuItemBase {
29    public override Image Image { get { return VSImageLibrary.NewDocument; } }
30
31    #region CodeTemplate
32    private static readonly string CodeTemplate = @"
33// use 'vars' to access variables in the script's variable store (e.g. vars.x = 5)
34// use 'vars[string]' to access variables via runtime strings (e.g. vars[""x""] = 5)
35// use 'vars.Contains(string)' to check if a variable exists
36// use 'vars.Clear()' to remove all variables
37// use 'foreach (KeyValuePair<string, object> v in vars) { ... }' to iterate over all variables
38// use 'variables' to work with IEnumerable<T> extension methods on the script's variable store
39
40using System;
41using System.Linq;
42using System.Collections.Generic;
43
44using QueryClient = HeuristicLab.Clients.OKB.Query.QueryClient;
45using RunCreationClient = HeuristicLab.Clients.OKB.RunCreation.RunCreationClient;
46using AdministrationClient = HeuristicLab.Clients.OKB.Administration.AdministrationClient;
47using HeuristicLab.Core;
48using HeuristicLab.Common;
49using HeuristicLab.Collections;
50using HeuristicLab.Data;
51using HeuristicLab.Optimization;
52using HeuristicLab.OptimizationExpertSystem;
53using HeuristicLab.OptimizationExpertSystem.Common;
54using HeuristicLab.Random;
55
56public class MyScript : HeuristicLab.Scripting.CSharpScriptBase {
57  public KnowledgeCenter Instance { get { return ((OptimizationKnowledgeCenter)HeuristicLab.MainForm.MainFormManager.MainForm).ExpertSystem; } }
58
59  public override void Main() {
60    // type your code here
61  }
62
63  // implement further classes and methods
64
65}";
66    #endregion
67
68    public override string Name {
69      get { return "New"; }
70    }
71
72    public override IEnumerable<string> Structure {
73      get { return new[] { "Tools", "C# Script" }; }
74    }
75
76    public override int Position {
77      get { return 910; }
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    }
85  }
86}
Note: See TracBrowser for help on using the repository browser.