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 {
|
---|
| 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);
|
---|
[2696] | 36 | view.Show();
|
---|
[2545] | 37 | }
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.