Last change
on this file since 3103 was
2992,
checked in by mkommend, 15 years ago
|
overloaded GetViewTypes in MainFormManager(ticket #902)
|
File size:
1.5 KB
|
Rev | Line | |
---|
[2545] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.ComponentModel;
|
---|
| 4 | using System.Diagnostics;
|
---|
| 5 | using System.Linq;
|
---|
| 6 | using System.Text;
|
---|
| 7 | using System.Windows.Forms;
|
---|
| 8 |
|
---|
| 9 | namespace HeuristicLab.MainForm.WindowsForms {
|
---|
[2837] | 10 | public sealed partial class ViewContextMenuStrip : ContextMenuStrip {
|
---|
[2545] | 11 | public ViewContextMenuStrip() {
|
---|
| 12 | InitializeComponent();
|
---|
[2837] | 13 | this.menuItems = new Dictionary<Type, ToolStripMenuItem>();
|
---|
[2545] | 14 | }
|
---|
| 15 |
|
---|
[2837] | 16 | public ViewContextMenuStrip(object item)
|
---|
| 17 | : this() {
|
---|
| 18 | this.Item = item;
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | private object item;
|
---|
| 22 | public object Item {
|
---|
| 23 | get { return this.item; }
|
---|
| 24 | set {
|
---|
| 25 | if (this.item != value) {
|
---|
| 26 | this.item = value;
|
---|
| 27 | this.RefreshMenuItems();
|
---|
[2545] | 28 | }
|
---|
| 29 | }
|
---|
| 30 | }
|
---|
| 31 |
|
---|
[2837] | 32 | private Dictionary<Type, ToolStripMenuItem> menuItems;
|
---|
| 33 | public IEnumerable<KeyValuePair<Type, ToolStripMenuItem>> MenuItems {
|
---|
| 34 | get { return this.menuItems; }
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | private void RefreshMenuItems() {
|
---|
| 38 | this.Items.Clear();
|
---|
| 39 | this.menuItems.Clear();
|
---|
| 40 |
|
---|
| 41 | if (this.item != null) {
|
---|
| 42 | ToolStripMenuItem menuItem;
|
---|
[2992] | 43 | IEnumerable<Type> types = MainFormManager.GetViewTypes(item.GetType(),true);
|
---|
[2837] | 44 | foreach (Type t in types) {
|
---|
| 45 | menuItem = new ToolStripMenuItem();
|
---|
| 46 | menuItem.Tag = t;
|
---|
| 47 | menuItem.Text = ViewAttribute.GetViewName(t);
|
---|
| 48 |
|
---|
| 49 | this.menuItems.Add(t, menuItem);
|
---|
| 50 | this.Items.Add(menuItem);
|
---|
| 51 | }
|
---|
[2545] | 52 | }
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
| 55 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.