Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 2723 was 2696, checked in by mkommend, 14 years ago

first version of redesigned MainForm (ticket #857)

File size: 1.1 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        view.Show();
37      }
38    }
39
40  }
41}
Note: See TracBrowser for help on using the repository browser.