Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/OperatorsMenuItem.cs @ 2668

Last change on this file since 2668 was 2656, checked in by swagner, 15 years ago

Committing first results of the refactoring of HeuristicLab.Core and related plugins (#95)

File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows.Forms;
6using System.Drawing;
7using HeuristicLab.MainForm;
8using HeuristicLab.MainForm.WindowsForms;
9using HeuristicLab.Common.Resources;
10using HeuristicLab.Core;
11using HeuristicLab.Core.Views;
12
13namespace HeuristicLab.Optimizer.MenuItems {
14  internal class OperatorsMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItemBase, IOptimizerUserInterfaceItemProvider {
15    private OperatorsSidebar view;
16    private ToolStripMenuItem menuItem;
17
18    public override string Name {
19      get { return "&Operators"; }
20    }
21    public override IEnumerable<string> Structure {
22      get { return new string[] { "&View" }; }
23    }
24    public override int Position {
25      get { return 2100; }
26    }
27    public override ToolStripItemDisplayStyle ToolStripItemDisplayStyle {
28      get { return ToolStripItemDisplayStyle.Text; }
29    }
30
31    public override void MainFormInitialized(object sender, EventArgs e) {
32      view = new OperatorsSidebar();
33      view.Dock = DockStyle.Left;
34      MainFormManager.MainForm.ViewHidden += new EventHandler<ViewEventArgs>(MainForm_ViewHidden);
35
36      menuItem = ToolStripItem as ToolStripMenuItem;
37      if (menuItem != null) {
38        menuItem.Checked = true;
39        menuItem.CheckOnClick = true;
40      }
41      MainFormManager.MainForm.ShowView(view);
42    }
43
44    private void MainForm_ViewHidden(object sender, ViewEventArgs e) {
45      if ((e.View == view) && (menuItem != null))
46        menuItem.Checked = false;
47    }
48
49    public override void Execute() {
50      if (menuItem != null) {
51        if (menuItem.Checked)
52          MainFormManager.MainForm.ShowView(view);
53        else
54          MainFormManager.MainForm.HideView(view);
55      } else {
56        MainFormManager.MainForm.ShowView(view);
57      }
58    }
59  }
60}
Note: See TracBrowser for help on using the repository browser.