WorkflowMenuCommands Class

Defines a set of CommandID fields that each corresponds to a command function provided by the workflow designers. This class cannot be inherited.

System.Object
  System.ComponentModel.Design.StandardCommands
    System.Workflow.ComponentModel.Design.WorkflowMenuCommands

Namespace:  System.Workflow.ComponentModel.Design
Assembly:  System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)

public sealed class WorkflowMenuCommands : StandardCommands

The WorkflowMenuCommands type exposes the following members.

  NameDescription
Public methodWorkflowMenuCommandsInitializes a new instance of the WorkflowMenuCommands class.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public fieldStatic memberBreakpointActionMenuGets the CommandID for the breakpoint action menu. This field is read-only.
Public fieldStatic memberBreakpointConditionMenuGets the CommandID for the breakpoint condition menu. This field is read-only.
Public fieldStatic memberBreakpointConstraintsMenuGets the CommandID for the breakpoint constraints menu. This field is read-only.
Public fieldStatic memberBreakpointHitCountMenuGets the CommandID for the breakpoint hit count menu. This field is read-only.
Public fieldStatic memberBreakpointLocationMenuGets the CommandID for the breakpoint location menu. This field is read-only.
Public fieldStatic memberChangeThemeGets the CommandID for the change theme menu. This field is read-only.
Public fieldStatic memberClearBreakpointsMenuA CommandID that can be used to access the clear breakpoints menu. This field is read-only.
Public fieldStatic memberCollapseA CommandID that can be used to access the collapse menu. This field is read-only.
Public fieldStatic memberCopyToClipboardA CommandID that can be used to access the copy menu. This field is read-only.
Public fieldStatic memberCreateThemeA CommandID that can be used to access the create theme menu. This field is read-only.
Public fieldStatic memberDebugCommandSetIdProvides a unique identifier for the debug command set. This field is read-only.
Public fieldStatic memberDebugStepBranchMenuA CommandID that can be used to access the debug step branch menu. This field is read-only.
Public fieldStatic memberDebugStepInstanceMenuA CommandID that can be used to access the debug step instance menu. This field is read-only.
Public fieldStatic memberDebugWorkflowGroupIdProvides a unique identifier for the debug workflow group of menus. This field is read-only.
Public fieldStatic memberDefaultFilterA CommandID that can be used to access the default filter menu. This field is read-only.
Public fieldStatic memberDefaultPageA CommandID that can be used to access the default page menu. This field is read-only.
Public fieldStatic memberDesignerActionsMenuA CommandID that can be used to access the designer actions menu. This field is read-only.
Public fieldStatic memberDesignerPropertiesA CommandID that can be used to access the designer properties menu. This field is read-only.
Public fieldStatic memberDisableA CommandID that can be used to access the disable menu. This field is read-only.
Public fieldStatic memberEnableA CommandID that can be used to access the enable menu. This field is read-only.
Public fieldStatic memberEnableBreakpointMenuA CommandID that can be used to access the enable breakpoint menu. This field is read-only.
Public fieldStatic memberExecutionStateMenuA CommandID that can be used to access the execution state menu. This field is read-only.
Public fieldStatic memberExpandA CommandID that can be used to access the expand menu. This field is read-only.
Public fieldStatic memberFirstZoomCommandA CommandID that can be used to access the zoom first menu. This field is read-only.
Public fieldStatic memberGotoDisassemblyMenuA CommandID that can be used to access the goto disassembly menu. This field is read-only.
Public fieldStatic memberInsertBreakpointMenuA CommandID that can be used to access the insert breakpoint menu. This field is read-only.
Public fieldStatic memberInsertTracePointMenuA CommandID that can be used to access the insert tracepoint menu. This field is read-only.
Public fieldStatic memberLastZoomCommandA CommandID that can be used to access the zoom last menu. This field is read-only.
Public fieldStatic memberMenuGuidProvides a unique identifier for the menu. This field is read-only.
Public fieldStatic memberNewDataBreakpointMenuA CommandID that can be used to access the new data breakpoint menu. This field is read-only.
Public fieldStatic memberNewFileTracePointMenuA CommandID that can be used to access the new file tracepoint menu. This field is read-only.
Public fieldStatic memberPageDownA CommandID that can be used to access the PageDown menu. This field is read-only.
Public fieldStatic memberPageLayoutMenuA CommandID that can be used to access the page layout menu. This field is read-only.
Public fieldStatic memberPageSetupA CommandID that can be used to access the page setup menu. This field is read-only.
Public fieldStatic memberPageUpA CommandID that can be used to access the PageUp menu. This field is read-only.
Public fieldStatic memberPanA CommandID that can be used to access the pan menu. This field is read-only.
Public fieldStatic memberPanMenuA CommandID that can be used to access the pan menu. This field is read-only.
Public fieldStatic memberPrintA CommandID that can be used to access the print menu. This field is read-only.
Public fieldStatic memberPrintPreviewA CommandID that can be used to access the print preview menu. This field is read-only.
Public fieldStatic memberPrintPreviewPageA CommandID that can be used to access the print preview page menu. This field is read-only.
Public fieldStatic memberRunToCursorMenuA CommandID that can be used to access the run to cursor menu. This field is read-only.
Public fieldStatic memberSaveAsImageA CommandID that can be used to access the save as image menu. This field is read-only.
Public fieldStatic memberSelectionMenuA CommandID that can be used to access the selection menu. This field is read-only.
Public fieldStatic memberSetNextStatementMenuA CommandID that can be used to access the set next statement menu. This field is read-only.
Public fieldStatic memberShowAllA CommandID that can be used to access the show all menu. This field is read-only.
Public fieldStatic memberShowNextStatementMenuA CommandID that can be used to access the show next statement menu. This field is read-only.
Public fieldStatic memberToggleBreakpointMenuA CommandID that can be used to access the toggle breakpoint menu. This field is read-only.
Public fieldStatic memberVerbGroupActionsA CommandID that can be used to access the verb group actions menu. This field is read-only.
Public fieldStatic memberVerbGroupDesignerActionsA CommandID that can be used to access the verb group designer actions menu. This field is read-only.
Public fieldStatic memberVerbGroupEditA CommandID that can be used to access the edit verb group menu. This field is read-only.
Public fieldStatic memberVerbGroupGeneralA CommandID that can be used to access the general verb group menu. This field is read-only.
Public fieldStatic memberVerbGroupMiscA CommandID that can be used to access the miscellaneous verb group menu. This field is read-only.
Public fieldStatic memberVerbGroupOptionsA CommandID that can be used to access the options verb group menu. This field is read-only.
Public fieldStatic memberVerbGroupViewA CommandID that can be used to access the view verb group menu. This field is read-only.
Public fieldStatic memberWorkflowCommandSetIdProvides a unique identifier for the workflow command set. This field is read-only.
Public fieldStatic memberWorkflowToolBarA CommandID that can be used to access the workflow toolbar menu. This field is read-only.
Public fieldStatic memberZoom100ModeA CommandID that can be used to access the zoom 100% menu. This field is read-only.
Public fieldStatic memberZoom150ModeA CommandID that can be used to access the zoom 150% menu. This field is read-only.
Public fieldStatic memberZoom200ModeA CommandID that can be used to access the zoom 200% menu. This field is read-only.
Public fieldStatic memberZoom300ModeA CommandID that can be used to access the zoom 300% menu. This field is read-only.
Public fieldStatic memberZoom400ModeA CommandID that can be used to access the zoom 400% menu. This field is read-only.
Public fieldStatic memberZoom50ModeA CommandID that can be used to access the zoom 50% menu. This field is read-only.
Public fieldStatic memberZoom75ModeA CommandID that can be used to access the zoom 75% menu. This field is read-only.
Public fieldStatic memberZoomInA CommandID that can be used to access the zoom in menu. This field is read-only.
Public fieldStatic memberZoomLevelComboA CommandID that can be used to access the zoom level combo menu. This field is read-only.
Public fieldStatic memberZoomLevelListHandlerA CommandID that can be used to access the zoom level list handler menu. This field is read-only.
Public fieldStatic memberZoomMenuA CommandID that can be used to access the zoom menu. This field is read-only.
Public fieldStatic memberZoomOutA CommandID that can be used to access the zoom out menu. This field is read-only.
Top

WorkflowMenuCommands contains a set of CommandID fields that can be used to specify a command to link when adding a command using the AddCommand method of the IMenuCommandService.

The following example demonstrates how to create a custom MenuCommandService. In this example, a context menu is created when the ShowContextMenu is called. In the GetSelectionMenuItems method, the WorkflowMenuCommands class is utilized to associate the proper menu commands provided by the workflow designer with their corresponding text. When this is finished, an event handler is associated with each command so that when the command is selected, the appropriate MenuCommand is invoked.


internal sealed class WorkflowMenuCommandService : MenuCommandService
{
    public WorkflowMenuCommandService(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 MenuItem[] GetSelectionMenuItems()
    {
        List<MenuItem> menuItems = new List<MenuItem>();

        bool addMenuItems = true;
        ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
        if (selectionService != null)
        {
            foreach (object obj in selectionService.GetSelectedComponents())
            {
                if (!(obj is Activity))
                {
                    addMenuItems = false;
                    break;
                }
            }
        }

        if (addMenuItems)
        {
            Dictionary<CommandID, string> selectionCommands = new Dictionary<CommandID, string>();
            selectionCommands.Add(WorkflowMenuCommands.Cut, "Cut");
            selectionCommands.Add(WorkflowMenuCommands.Copy, "Copy");
            selectionCommands.Add(WorkflowMenuCommands.Paste, "Paste");
            selectionCommands.Add(WorkflowMenuCommands.Delete, "Delete");
            selectionCommands.Add(WorkflowMenuCommands.Collapse, "Collapse");
            selectionCommands.Add(WorkflowMenuCommands.Expand, "Expand");
            selectionCommands.Add(WorkflowMenuCommands.Disable, "Disable");
            selectionCommands.Add(WorkflowMenuCommands.Enable, "Enable");

            foreach (CommandID id in selectionCommands.Keys)
            {
                MenuCommand command = FindCommand(id);
                if (command != null)
                {
                    MenuItem menuItem = new MenuItem(selectionCommands[id], new EventHandler(OnMenuClicked));
                    menuItem.Tag = command;
                    menuItems.Add(menuItem);
                }
            }
        }

        return menuItems.ToArray();
    }

    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();
        }
    }
}


To enable this service, call the AddService method of the LoaderHost property in a WorkflowDesignerLoader class as shown in the following example.


protected override void Initialize()
{
    base.Initialize();

    IDesignerLoaderHost host = this.LoaderHost;
    if (host != null)
    {
        host.RemoveService(typeof(IIdentifierCreationService));
        host.AddService(typeof(IIdentifierCreationService), new IdentifierCreationService(host));
        host.AddService(typeof(IMenuCommandService), new WorkflowMenuCommandService(host));
        host.AddService(typeof(IToolboxService), new Toolbox(host));
        TypeProvider typeProvider = new TypeProvider(host);
        typeProvider.AddAssemblyReference(typeof(string).Assembly.Location);
        host.AddService(typeof(ITypeProvider), typeProvider, true);
        host.AddService(typeof(IEventBindingService), new EventBindingService());
    }
}


.NET Framework

Supported in: 4, 3.5, 3.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft