当前位置: 首页>>代码示例>>C#>>正文


C# OleMenuCommandService.AddCommand方法代码示例

本文整理汇总了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}");
            }
        }
开发者ID:k4gdw,项目名称:SaveAllTheTabs,代码行数:25,代码来源:RestoreTabsListCommands.cs

示例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);
        }
开发者ID:BenHall,项目名称:lonestar,代码行数:11,代码来源:LonestarPackage.cs

示例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);
            }
        }
开发者ID:SonicZentropy,项目名称:MiscProjects,代码行数:55,代码来源:ZenToolsMain.cs

示例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);
 }
开发者ID:paulroho,项目名称:SpecFlow.VisualStudio,代码行数:7,代码来源:MenuCommandHandler.cs

示例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 );
 }
开发者ID:BenHall,项目名称:lonestar,代码行数:7,代码来源:LonestarPackage.cs

示例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);
        }
开发者ID:dziedrius,项目名称:AttachTo,代码行数:8,代码来源:AttachToPackage.cs

示例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);
        }
开发者ID:madskristensen,项目名称:ClearComponentCache,代码行数:8,代码来源:ClearCache.cs

示例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);
        }
开发者ID:madskristensen,项目名称:BrowserReloadOnSave,代码行数:9,代码来源:EnableReloadCommand.cs

示例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);
        }
开发者ID:madskristensen,项目名称:CommandTaskRunner,代码行数:9,代码来源:AddCommand.cs

示例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);
        }
开发者ID:Sunzhuokai,项目名称:VSSDK-Extensibility-Samples,代码行数:13,代码来源:RGBToolWindow.cs

示例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);
 }
开发者ID:ashmind,项目名称:AttachToAnything,代码行数:13,代码来源:AttachToAnythingPackage.cs

示例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);
            }
        }
开发者ID:techl,项目名称:MonoRemoteDebugger,代码行数:23,代码来源:VSPackage.cs

示例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);
        }
      }
    }
开发者ID:ashumeow,项目名称:android-plus-plus,代码行数:18,代码来源:UiCommandEventListener.cs

示例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);
            }
        }
开发者ID:deadmann,项目名称:Ersx.Net,代码行数:16,代码来源:Ersx.Net.VsixPackage.cs


注:本文中的Microsoft.VisualStudio.Shell.OleMenuCommandService.AddCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。