本文整理汇总了C#中System.Workflow.ComponentModel.Design.WorkflowMenuCommands.Collapse字段的典型用法代码示例。如果您正苦于以下问题:C# WorkflowMenuCommands.Collapse字段的具体用法?C# WorkflowMenuCommands.Collapse怎么用?C# WorkflowMenuCommands.Collapse使用的例子?那么恭喜您, 这里精选的字段代码示例或许可以为您提供帮助。您也可以进一步了解该字段所在类System.Workflow.ComponentModel.Design.WorkflowMenuCommands
的用法示例。
在下文中一共展示了WorkflowMenuCommands.Collapse字段的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WorkflowMenuCommandService
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();
}
}
}
示例2: Initialize
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());
}
}