本文整理汇总了C#中IMenuCommandService.AddCommand方法的典型用法代码示例。如果您正苦于以下问题:C# IMenuCommandService.AddCommand方法的具体用法?C# IMenuCommandService.AddCommand怎么用?C# IMenuCommandService.AddCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMenuCommandService
的用法示例。
在下文中一共展示了IMenuCommandService.AddCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTo
public void AddTo (IMenuCommandService commands)
{
commands.AddCommand (new MenuCommand (Copy, StandardCommands.Copy));
commands.AddCommand (new MenuCommand (Cut, StandardCommands.Cut));
commands.AddCommand (new MenuCommand (Paste, StandardCommands.Paste));
commands.AddCommand (new MenuCommand (Delete, StandardCommands.Delete));
commands.AddCommand (new MenuCommand (SelectAll, StandardCommands.SelectAll));
}
示例2: AddCommandHandlers
public override void AddCommandHandlers(IMenuCommandService menuCommandService)
{
//ModelExplorerCut = new CommandID(GuidSymbol, CutIDSymbol);
ModelExplorerCopy = new CommandID(GuidSymbol, CopyIDSymbol);
ModelExplorerPaste = new CommandID(GuidSymbol, PasteIDSymbol);
//menuCommandService.AddCommand(
// new DynamicStatusMenuCommand(new EventHandler(OnStatusCut), new EventHandler(OnMenuCut), ModelExplorerCut));
menuCommandService.AddCommand(
new DynamicStatusMenuCommand(new EventHandler(OnStatusCopy), new EventHandler(OnMenuCopy), ModelExplorerCopy));
menuCommandService.AddCommand(
new DynamicStatusMenuCommand(new EventHandler(OnStatusPaste), new EventHandler(OnMenuPaste), ModelExplorerPaste));
base.AddCommandHandlers(menuCommandService);
}
示例3: Register
public virtual void Register(IMenuCommandService mcs)
{
var menuCommandID = new CommandID(GuidList.GuidEasyCodeCmdSet, CommandID);
var menuCommand = new OleMenuCommand(ExcuteCommand, menuCommandID);
menuCommand.BeforeQueryStatus += new EventHandler(menuCommand_BeforeQueryStatus);
mcs.AddCommand(menuCommand);
}
示例4: RegisterCommand
private OleMenuCommand RegisterCommand(Guid guidId, int id, IMenuCommandService menuCommandService)
{
var menuCommandID = new CommandID(guidId, id);
var menuItem = new OleMenuCommand(Exec, menuCommandID);
menuItem.BeforeQueryStatus += QueryStatus;
menuCommandService.AddCommand(menuItem);
return menuItem;
}
示例5: CompareToBranchCommand
public CompareToBranchCommand(IMenuCommandService menuCommandService, ILogger _logger, ITFSVersionControl _tfs)
{
branches = new List<string>();
logger = _logger;
tfsVersionControl = _tfs;
CommandID compareToBranchId = new CommandID(GuidList.guidTFSProductivityPackCmdSet, PkgCmdIDList.cmdIdDynamicCompareToBranchCommand);
compareToBranchOleCommand = new OleDynamicCommand(compareToBranchId, IsValidDynamicItem, Exec, QueryStatus);
menuCommandService.AddCommand(compareToBranchOleCommand);
}
示例6: AddCommand
/// <summary>
/// Add a command handler and status query handler for a menu item
/// </summary>
private static OleMenuCommand AddCommand(
IMenuCommandService menuCommandService,
int commandId,
EventHandler invokeHandler,
EventHandler beforeQueryStatus)
{
var commandIdWithGroupId = new CommandID(Guids.RoslynGroupId, commandId);
var command = new OleMenuCommand(invokeHandler, delegate { }, beforeQueryStatus, commandIdWithGroupId);
menuCommandService.AddCommand(command);
return command;
}
示例7: Bind
public static void Bind(IMenuCommandService menuCommandService)
{
var menuHandlers = IoC.GetInstances<IComboBoxCommandHandler>();
foreach (IComboBoxCommandHandler handler in menuHandlers)
{
var handlesComboBoxdAttributes = (HandlesComboBoxCommandAttribute[])handler.GetType().GetCustomAttributes(typeof(HandlesComboBoxCommandAttribute), false);
foreach (HandlesComboBoxCommandAttribute attribute in handlesComboBoxdAttributes)
{
var requestItemsCommandId = new CommandID(Identifiers.CommandGroupId, attribute.RequestItemsCommandId);
var menuItem = new OleMenuCommand(ProvideItemsCallback, requestItemsCommandId);
menuCommandService.AddCommand(menuItem);
var itemSelectionCommandId = new CommandID(Identifiers.CommandGroupId, attribute.SelectionCommandId);
var itemSelectionMenuItem = new OleMenuCommand(ItemSelectionCallback, itemSelectionCommandId);
menuCommandService.AddCommand(itemSelectionMenuItem);
}
}
}
示例8: Bind
public static void Bind(IMenuCommandService menuCommandService)
{
var menuHandlers = IoC.GetInstances<IMenuCommandHandler>();
foreach (IMenuCommandHandler menuCommandHandler in menuHandlers)
{
var handlesCommandAttributes = (HandlesMenuCommandAttribute[])menuCommandHandler.GetType().GetCustomAttributes(typeof(HandlesMenuCommandAttribute), false);
IEnumerable<int> coomandIdentifiers = handlesCommandAttributes.SelectMany(attr => attr.CommandIdentifiers);
foreach (int commandId in coomandIdentifiers)
{
var menuCommandId = new CommandID(Identifiers.CommandGroupId, commandId);
var menuItem = new OleMenuCommand(MenuItemCallback, menuCommandId);
menuItem.BeforeQueryStatus += OnBeforeQueryStatus;
menuCommandService.AddCommand(menuItem);
}
}
}
示例9: AddCommand
/// <summary>
/// Helper function used to add commands using IMenuCommandService
/// </summary>
/// <param name="mcs"> The IMenuCommandService interface.</param>
/// <param name="menuGroup"> This guid represents the menu group of the command.</param>
/// <param name="cmdID"> The command ID of the command.</param>
/// <param name="commandEvent"> An EventHandler which will be called whenever the command is invoked.</param>
/// <param name="queryEvent"> An EventHandler which will be called whenever we want to query the status of
/// the command. If null is passed in here then no EventHandler will be added.</param>
private static void AddCommand(IMenuCommandService mcs, Guid menuGroup, int cmdID,
EventHandler commandEvent, EventHandler queryEvent)
{
// Create the OleMenuCommand from the menu group, command ID, and command event
CommandID menuCommandID = new CommandID(menuGroup, cmdID);
OleMenuCommand command = new OleMenuCommand(commandEvent, menuCommandID);
// Add an event handler to BeforeQueryStatus if one was passed in
if (null != queryEvent)
{
command.BeforeQueryStatus += queryEvent;
}
// Add the command using our IMenuCommandService instance
mcs.AddCommand(command);
}
示例10: AddCommandHandler
private MenuCommand AddCommandHandler(IMenuCommandService menuCommandService, int roslynCommand, EventHandler handler)
{
var commandID = new CommandID(Guids.RoslynGroupId, roslynCommand);
var menuCommand = new MenuCommand(handler, commandID);
menuCommandService.AddCommand(menuCommand);
return menuCommand;
}
示例11: AddCommand
private static OleMenuCommand AddCommand(IMenuCommandService menuCommandService, int commandID, EventHandler eventHandler)
{
CommandID menuCommandID = new CommandID(GuidList.guidModelViewerCmdSet, commandID);
OleMenuCommand menuItem = new OleMenuCommand(eventHandler, menuCommandID);
menuCommandService.AddCommand(menuItem);
return menuItem;
}
示例12: BuildMenuItem
private OleMenuCommand BuildMenuItem(IMenuCommandService menuCommandService, Int32 commandId, EventHandler onExecute, EventHandler onBeforeQueryStatus)
{
var command = new CommandID(new Guid(Constants.ALIAS_BE_GONE_COMMANDSET_ID_STRING), commandId);
var menuItem = new OleMenuCommand(onExecute, command);
menuItem.BeforeQueryStatus += onBeforeQueryStatus;
menuCommandService.AddCommand(menuItem);
return menuItem;
}
示例13: Initialize
//.........这里部分代码省略.........
try
{
m_oNewCmdCopy = new MenuCommand(new EventHandler(this.OnMenuCopy), StandardCommands.Copy);
}
catch
{
}
try
{
m_oNewCmdPaste = new MenuCommand(new EventHandler(this.OnMenuPaste), StandardCommands.Paste);
}
catch
{
}
if (TreeViewDesigner.MenuAdded == false)
{
try
{
m_oMenuService.RemoveCommand(m_oOldCmdCopy);
}
catch
{
}
try
{
m_oMenuService.RemoveCommand(m_oOldCmdPaste);
}
catch
{
}
try
{
m_oMenuService.AddCommand(m_oNewCmdCopy);
}
catch
{
}
try
{
m_oMenuService.AddCommand(m_oNewCmdPaste);
}
catch
{
}
TreeViewDesigner.MenuAdded = true;
}
m_oTreeView.Invalidate();
#region action menus
#region node menu
m_oActionMenuNode = new ActionMenuNative();
m_oActionMenuNode.Width = 170;
m_oActionMenuNode.Title = "Node Action Menu";
ActionMenuGroup oMenuGroup = m_oActionMenuNode.AddMenuGroup("Editing");
oMenuGroup.Expanded = true;
m_oActionMenuNode.AddMenuItem(oMenuGroup, "Add Node");
m_oActionMenuNode.AddMenuItem(oMenuGroup, "Delete Node");
m_oActionMenuNode.AddMenuItem(oMenuGroup, "Add Panel");
m_oActionMenuNode.AddMenuItem(oMenuGroup, "-");
m_oActionMenuNode.AddMenuItem(oMenuGroup, "Clear Content");
示例14: AddCommand
private static void AddCommand(IMenuCommandService mcs, Guid menuGroup, int cmdId, EventHandler invokeHandler, EventHandler beforeQueryStatus)
{
var id = new CommandID(menuGroup, cmdId);
var command = new OleMenuCommand(invokeHandler, id) { Visible = true };
if (beforeQueryStatus != null)
{
command.BeforeQueryStatus += beforeQueryStatus;
}
mcs.AddCommand(command);
}
示例15: AddSolutionExplorerCommand
void AddSolutionExplorerCommand(IMenuCommandService mcs, OleMenuCommand command, UDNDocRunningTableMonitor rdtm)
{
command.BeforeQueryStatus += (sender, args) =>
{
var cmd = sender as OleMenuCommand;
if (cmd != null)
{
var selectedItems = (Array)uih.SelectedItems;
if (null != selectedItems)
{
foreach (UIHierarchyItem selectedItem in selectedItems)
{
var projectItem = selectedItem.Object as ProjectItem;
var pathString = projectItem.Properties.Item("FullPath").Value.ToString();
if (!pathString.EndsWith(".udn"))
{
cmd.Visible = false;
break;
}
cmd.Visible = true;
}
}
}
};
mcs.AddCommand(command);
}