www.pudn.com > wxwinter2.rar > wxdWFMenu.cs
using System;
using System.IO;
using System.Text;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Windows.Forms;
using System.Drawing;
namespace wxwinter.wf.Design
{
//ÏÔʾÓÒ¼ü²Ëµ¥
public sealed class wxdWFMenu : MenuCommandService
{
public wxdWFMenu(IServiceProvider serviceProvider)
: base(serviceProvider)
{
}
public override void ShowContextMenu(CommandID menuID, int x, int y)
{
if (menuID == WorkflowMenuCommands.SelectionMenu)
{
ContextMenu contextMenu = new ContextMenu();
foreach (DesignerVerb verb in Verbs)
{
MenuItem menuItem = new MenuItem(verb.Text, new EventHandler(OnMenuClicked));
menuItem.Tag = verb;
contextMenu.MenuItems.Add(menuItem);
}
MenuItem[] items = GetSelectionMenuItems();
if (items.Length > 0)
{
contextMenu.MenuItems.Add(new MenuItem("-"));
foreach (MenuItem item in items)
contextMenu.MenuItems.Add(item);
}
WorkflowView workflowView = GetService(typeof(WorkflowView)) as WorkflowView;
if (workflowView != null)
contextMenu.Show(workflowView, workflowView.PointToClient(new Point(x, y)));
}
}
private void OnMenuClicked(object sender, EventArgs e)
{
MenuItem menuItem = sender as MenuItem;
if (menuItem != null && menuItem.Tag is MenuCommand)
{
MenuCommand command = menuItem.Tag as MenuCommand;
command.Invoke();
}
}
private MenuItem[] GetSelectionMenuItems()
{
List