Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 4181 was 4176, checked in by abeham, 14 years ago

#567

  • Updated installer
  • Updated View template
  • Added Algorithm template (untested)
File size: 2.5 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        shouldAddItem = true;
62      } else shouldAddItem = false;
63    }
64
65    public bool ShouldAddProjectItem(string filePath) {
66      return shouldAddItem;
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.