[2656] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Windows.Forms;
|
---|
| 6 | using System.Drawing;
|
---|
| 7 | using HeuristicLab.MainForm;
|
---|
| 8 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 9 | using HeuristicLab.Common.Resources;
|
---|
| 10 | using HeuristicLab.Core;
|
---|
| 11 | using HeuristicLab.Core.Views;
|
---|
| 12 |
|
---|
| 13 | namespace 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 | }
|
---|