Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/MenuItems/CreateExperimentMenuItemV2.cs @ 8517

Last change on this file since 8517 was 8517, checked in by jkarder, 12 years ago

#1853:

  • created branch for ParameterConfigurationEncoding
  • added CreateExperimentDialog that uses the extracted encoding
File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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;
23#region License Information
24/* HeuristicLab
25 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
26 *
27 * This file is part of HeuristicLab.
28 *
29 * HeuristicLab is free software: you can redistribute it and/or modify
30 * it under the terms of the GNU General Public License as published by
31 * the Free Software Foundation, either version 3 of the License, or
32 * (at your option) any later version.
33 *
34 * HeuristicLab is distributed in the hope that it will be useful,
35 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37 * GNU General Public License for more details.
38 *
39 * You should have received a copy of the GNU General Public License
40 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
41 */
42#endregion
43
44using System.Collections.Generic;
45using System.Windows.Forms;
46using HeuristicLab.Core;
47using HeuristicLab.MainForm;
48using HeuristicLab.Optimization;
49using HeuristicLab.Optimizer;
50using HeuristicLab.PluginInfrastructure;
51
52namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
53  public class CreateExperimentMenuItemV2 : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
54    public override string Name {
55      get { return "Create Experiment (v2)"; }
56    }
57    public override IEnumerable<string> Structure {
58      get { return new string[] { "&Edit" }; }
59    }
60    public override int Position {
61      get { return 2400; }
62    }
63    public override string ToolTipText {
64      get { return "Create an experiment for the shown optimizer"; }
65    }
66
67    protected override void OnToolStripItemSet(EventArgs e) {
68      ToolStripItem.Enabled = false;
69    }
70    protected override void OnActiveViewChanged(object sender, EventArgs e) {
71      IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
72      ToolStripItem.Enabled = (activeView != null) && (activeView.Content != null) && (activeView.Content is IAlgorithm) && !activeView.Locked;
73    }
74
75    public override void Execute() {
76      IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
77      if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IAlgorithm) && !activeView.Locked) {
78        using (CreateExperimentDialogV2 dialog = new CreateExperimentDialogV2((IAlgorithm)activeView.Content, ApplicationManager.Manager.GetInstances<IEngine>())) {
79          if (dialog.ShowDialog() == DialogResult.OK) MainFormManager.MainForm.ShowContent(dialog.Experiment);
80        }
81      }
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.