Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/tools/Templates/HeuristicLab.VS2010Wizards/AlgorithmWizard.cs @ 5304

Last change on this file since 5304 was 4187, checked in by abeham, 14 years ago

#567

  • Worked on Algorithm Template
File size: 2.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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 System.Collections.Generic;
23using EnvDTE;
24using Microsoft.VisualStudio.TemplateWizard;
25
26namespace HeuristicLab.VS2010Wizards {
27  public class AlgorithmWizard : IWizard {
28    private bool shouldAddItem;
29    private AlgorithmWizardForm form;
30
31    public AlgorithmWizard() {
32      form = new AlgorithmWizardForm();
33    }
34
35    public void BeforeOpeningFile(ProjectItem projectItem) {
36    }
37
38    public void ProjectFinishedGenerating(Project project) {
39    }
40
41    public void ProjectItemFinishedGenerating(ProjectItem projectItem) {
42    }
43
44    public void RunFinished() {
45    }
46
47    public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) {
48      if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
49        replacementsDictionary.Add("$algorithmName$", form.AlgorithmName);
50        replacementsDictionary.Add("$algorithmDescription$", form.AlgorithmDescription);
51        string problemType = @"public override Type ProblemType {
52      get { return typeof(IMultiObjectiveProblem); }
53    }
54    public new IMultiObjectiveProblem Problem {
55      get { return (IMultiObjectiveProblem)base.Problem; }
56      set { base.Problem = value; }
57    }";
58        replacementsDictionary.Add("$problemType$", problemType);
59        if (!form.IsMultiObjective)
60          replacementsDictionary["$problemType$"] = problemType.Replace("Multi", "Single");
61        replacementsDictionary.Add("$parameterProperties$", form.ParameterProperties);
62        replacementsDictionary.Add("$properties$", form.Properties);
63        replacementsDictionary.Add("$parameterInitializers$", form.ParameterInitializers);
64        shouldAddItem = true;
65      } else shouldAddItem = false;
66    }
67
68    public bool ShouldAddProjectItem(string filePath) {
69      return shouldAddItem;
70    }
71  }
72}
Note: See TracBrowser for help on using the repository browser.