Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/ViewContextMenuStrip.cs @ 2545

Last change on this file since 2545 was 2545, checked in by mkommend, 13 years ago

added ViewContextMenuStrip (ticket #771)

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Diagnostics;
5using System.Linq;
6using System.Text;
7using System.Windows.Forms;
8
9namespace HeuristicLab.MainForm.WindowsForms {
10  public partial class ViewContextMenuStrip : ContextMenuStrip {
11    private object item;
12    public ViewContextMenuStrip() {
13      InitializeComponent();
14    }
15
16    public ViewContextMenuStrip(object item) :this() {
17      if (item != null) {
18        this.item = item;
19        IEnumerable<Type> types = MainFormManager.GetViewTypes(item.GetType());
20        if (types != null) {
21          foreach (Type t in types) {
22            ToolStripMenuItem menuItem = new ToolStripMenuItem() {
23              Text = t.Name,
24              Tag = t
25            };
26            this.Items.Add(menuItem);
27          }
28        }
29      }
30    }
31
32    private void ViewContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) {
33      if (item != null) {
34        Type viewType = e.ClickedItem.Tag as Type;
35        IView view = MainFormManager.CreateView(viewType, this.item);
36        MainFormManager.MainForm.ShowView(view);
37      }
38    }
39
40  }
41}
Note: See TracBrowser for help on using the repository browser.