本文整理汇总了C#中Microsoft.VisualStudio.Shell.OleMenuCommandService.AddCommand方法的典型用法代码示例。如果您正苦于以下问题:C# OleMenuCommandService.AddCommand方法的具体用法?C# OleMenuCommandService.AddCommand怎么用?C# OleMenuCommandService.AddCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.Shell.OleMenuCommandService
的用法示例。
在下文中一共展示了OleMenuCommandService.AddCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupCommands
public void SetupCommands(OleMenuCommandService commandService)
{
if (Package.DocumentManager == null)
{
return;
}
var guid = typeof(RestoreTabsListCommandIds).GUID;
var commandId = new CommandID(guid, (int)RestoreTabsListCommandIds.RestoreTabsListPlaceholder);
var command = new OleMenuCommand(null, commandId);
command.BeforeQueryStatus += RestoreTabsListPlaceholderCommandOnBeforeQueryStatus;
commandService.AddCommand(command);
for (var i = (int)RestoreTabsListCommandIds.RestoreTabsListStart; i <= (int)RestoreTabsListCommandIds.RestoreTabsListEnd; i++)
{
commandId = new CommandID(guid, i);
command = new OleMenuCommand(ExecuteRestoreTabsCommand, commandId);
command.BeforeQueryStatus += RestoreTabsCommandOnBeforeQueryStatus;
commandService.AddCommand(command);
var index = GetGroupIndex(command);
Package.Environment.SetKeyBindings(command, $"Global::Ctrl+D,{index}", $"Text Editor::Ctrl+D,{index}");
}
}
示例2: CreateMenuCommands
private void CreateMenuCommands(OleMenuCommandService mcs)
{
CommandID runLonestarOnActiveViewMenuCommandID = new CommandID(GuidList.guidLonestarCmdSet, (int)PkgCmdIDList.runLonestarOnActiveView);
CommandID runLonestarOnSolutionMenuCommandID = new CommandID(GuidList.guidLonestarCmdSet, (int)PkgCmdIDList.runLonestarOnSolution);
MenuCommandController controller = new MenuCommandController(this);
MenuCommand menuItem = new MenuCommand(controller.RunLonestarOnActiveView, runLonestarOnActiveViewMenuCommandID);
mcs.AddCommand(menuItem);
MenuCommand runOnSolution = new MenuCommand(controller.RunLonestarOnSolution, runLonestarOnSolutionMenuCommandID);
mcs.AddCommand(runOnSolution);
}
示例3: ZenToolsMain
/// <summary>
/// Initializes a new instance of the <see cref="ZenToolsMain"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
private ZenToolsMain(Package package)
{
if (package == null)
{
throw new ArgumentNullException(nameof(package));
}
this.package = package;
commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
CommandId = 0x0100;
//CommandSet = new Guid("952f5cdf-910a-481c-801c-ba3a5e7077ba"); //GUID for menu Group
// commandService.GlobalInvoke(commandID);
var menuCommandID = new CommandID(CommandSet, 0x0105);
var menuItem = new MenuCommand(this.ToggleBreakpoint, menuCommandID);
commandService.AddCommand(menuItem);
// type = typeof(Microsoft.VisualStudio.VSConstants.VSStd97CmdID);
// commandID = new CommandID(type.GUID, cmdidToggleBreakpoint);
// menuCommandID = new CommandID(CommandSet, CommandId);
menuCommandID = new CommandID(CommandSet, 0x0101);
menuItem = new MenuCommand(this.Clean, menuCommandID);
commandService.AddCommand(menuItem);
menuCommandID = new CommandID(CommandSet, 0x0102);
menuItem = new MenuCommand(this.DisableAllBPs, menuCommandID);
commandService.AddCommand(menuItem);
menuCommandID = new CommandID(CommandSet, 0x0103);
menuItem = new MenuCommand(this.EnableAllBPs, menuCommandID);
commandService.AddCommand(menuItem);
menuCommandID = new CommandID(CommandSet, 0x0104);
menuItem = new MenuCommand(this.Rebuild, menuCommandID);
commandService.AddCommand(menuItem);
//
menuCommandID = new CommandID(CommandSet, 0x0106);
menuItem = new MenuCommand(this.ToggleComments, menuCommandID);
commandService.AddCommand(menuItem);
menuCommandID = new CommandID(CommandSet, 0x0107);
menuItem = new MenuCommand(this.ViewDoc, menuCommandID);
commandService.AddCommand(menuItem);
}
}
示例4: RegisterTo
public void RegisterTo(OleMenuCommandService menuCommandService, SpecFlowCmdSet commandId)
{
CommandID menuCommandID = new CommandID(GuidList.guidSpecFlowCmdSet, (int)(uint)commandId);
OleMenuCommand menuItem = new OleMenuCommand(InvokeHandler, menuCommandID);
menuItem.BeforeQueryStatus += BeforeQueryStatusHandler;
menuCommandService.AddCommand(menuItem);
}
示例5: CreateToolWindows
private void CreateToolWindows(OleMenuCommandService mcs)
{
WindowLauncher launcher = new WindowLauncher(this);
CommandID toolwndCommandID = new CommandID(GuidList.guidLonestarCmdSet, (int)PkgCmdIDList.resultsWindow);
MenuCommand menuToolWin = new MenuCommand(launcher.ShowToolWindow, toolwndCommandID);
mcs.AddCommand( menuToolWin );
}
示例6: AddAttachToCommand
private void AddAttachToCommand(OleMenuCommandService mcs, uint commandId, Func<GeneralOptionsPage, bool> isVisible, params string[] programsToAttach)
{
var menuItemCommand = new OleMenuCommand((sender, args) => Attach(programsToAttach),
new CommandID(GuidList.guidAttachToCmdSet, (int)commandId));
menuItemCommand.BeforeQueryStatus += (s, e) => menuItemCommand.Visible = isVisible((GeneralOptionsPage)GetDialogPage(typeof(GeneralOptionsPage)));
mcs.AddCommand(menuItemCommand);
}
示例7: ClearCache
private ClearCache(OleMenuCommandService commandService, AsyncPackage package)
{
ServiceProvider = package;
var commandID = new CommandID(PackageGuids.guidClearCachePackageCmdSet, PackageIds.ClearCacheId);
var button = new MenuCommand(DeleteCacheFolder, commandID);
commandService.AddCommand(button);
}
示例8: EnableReloadCommand
EnableReloadCommand(Package package, OleMenuCommandService commandService)
{
_package = package;
var id = new CommandID(PackageGuids.guidBrowserReloadCmdSet, PackageIds.EnableReloadCommandId);
var cmd = new OleMenuCommand(Execute, id);
cmd.BeforeQueryStatus += BeforeQueryStatus;
commandService.AddCommand(cmd);
}
示例9: AddCommand
private AddCommand(OleMenuCommandService commandService, DTE2 dte)
{
_dte = dte;
var cmdAddCommand = new CommandID(PackageGuids.guidCommandCmdSet, PackageIds.AddCommandId);
var addCommandItem = new OleMenuCommand(AddCommandToFile, cmdAddCommand);
addCommandItem.BeforeQueryStatus += BeforeQueryStatus;
commandService.AddCommand(addCommandItem);
}
示例10: AddCommand
/// <summary>
/// Add buttons to the toolbar. Specify the target toolbar, which button to place, and
/// the corresponding function call.
/// </summary>
private void AddCommand(OleMenuCommandService mcs, int cmdid, EventHandler handler)
{
// Create the command for the tool window
CommandID commandID = new CommandID(GuidList.guidCommandTargetRGBCmdSet, cmdid);
OleMenuCommand command = new OleMenuCommand(handler, commandID);
command.BeforeQueryStatus += OnBeforeQueryStatus;
mcs.AddCommand(command);
}
示例11: AddMenuCommandHandlers
private void AddMenuCommandHandlers()
{
_mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (null != _mcs)
{
CommandID menuCommandID = new CommandID(GuidList.guidVisualStudio_MenuExtensionCmdSet, (int)PkgCmdIDList.cmdidLinkOpenRiaServicesProject);
MenuCommand menuItem = new OleMenuCommand(LinkRiaProjectCallback, null, BeforeQueryStatusForAddPackageDialog, menuCommandID);
_mcs.AddCommand(menuItem);
}
}
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:10,代码来源:OpenRiaServicesPackage.VisualStudio.Installer.cs
示例12: SetupAttachCommand
private void SetupAttachCommand(OleMenuCommandService menuCommandService)
{
var dynamicItemRootId = new CommandID(GuidList.Commands, (int) CommandIDs.AttachToDynamicStub);
var dynamicMenuCommand = new DynamicMenuCommand(
(sender, e) => {
var invokedCommand = (DynamicMenuCommand)sender;
_controller.HandleAttachTo(invokedCommand.Text);
},
dynamicItemRootId,
index => _controller.GetTargets().ElementAtOrDefault(index)
);
menuCommandService.AddCommand(dynamicMenuCommand);
}
示例13: InstallMenu
private void InstallMenu(OleMenuCommandService mcs)
{
if (mcs != null)
{
var debugLocally = new CommandID(PackageGuids.guidMonoDebugger_VS2013CmdSet, (int)PackageIds.cmdLocalDebugCode);
var localCmd = new OleMenuCommand(DebugLocalClicked, debugLocally);
localCmd.BeforeQueryStatus += cmd_BeforeQueryStatus;
mcs.AddCommand(localCmd);
var menuCommandID = new CommandID(PackageGuids.guidMonoDebugger_VS2013CmdSet,
(int)PackageIds.cmdRemodeDebugCode);
var cmd = new OleMenuCommand(DebugRemoteClicked, menuCommandID);
cmd.BeforeQueryStatus += cmd_BeforeQueryStatus;
mcs.AddCommand(cmd);
var cmdOpenLogFileId = new CommandID(PackageGuids.guidMonoDebugger_VS2013CmdSet,
(int)PackageIds.cmdOpenLogFile);
var openCmd = new OleMenuCommand(OpenLogFile, cmdOpenLogFileId);
openCmd.BeforeQueryStatus += (o, e) => openCmd.Enabled = File.Exists(MonoLogger.LoggerPath);
mcs.AddCommand(openCmd);
}
}
示例14: RegisterCallbacks
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void RegisterCallbacks (OleMenuCommandService menuCommandService)
{
if (menuCommandService != null)
{
foreach (KeyValuePair<uint, EventHandler> keyValue in m_eventCallbacks)
{
CommandID commandId = new CommandID (Guids.guidAndroidPlusPlusCommandSetID, (int)keyValue.Key);
MenuCommand menuCommand = new MenuCommand (keyValue.Value, commandId);
menuCommandService.AddCommand (menuCommand);
}
}
}
示例15: Initialize
protected override void Initialize()
{
base.Initialize();
_statusBar = GetService(typeof (SVsStatusbar)) as IVsStatusbar;
_oleMenuCommandService = GetService(typeof (IMenuCommandService)) as OleMenuCommandService;
_outputWindow = GetService(typeof (SVsOutputWindow)) as IVsOutputWindow;
_sortIcon = (short) Constants.SBAI_General;
if (_oleMenuCommandService != null)
{
var menuCommandId = new CommandID(GuidList.guidErsx_Net_VsixCmdSet, (int) PkgCmdIDList.sortResx);
var menuItem = new OleMenuCommand(MenuItemClick, StatusChanged, BeforeContextMenuOpens, menuCommandId);
_oleMenuCommandService.AddCommand(menuItem);
}
}