當前位置: 首頁>>代碼示例>>C#>>正文


C# Shell.OleMenuCommand類代碼示例

本文整理匯總了C#中Microsoft.VisualStudio.Shell.OleMenuCommand的典型用法代碼示例。如果您正苦於以下問題:C# OleMenuCommand類的具體用法?C# OleMenuCommand怎麽用?C# OleMenuCommand使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OleMenuCommand類屬於Microsoft.VisualStudio.Shell命名空間,在下文中一共展示了OleMenuCommand類的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: SetupCommands

 public void SetupCommands()
 {
     CommandID commandId = new CommandID(CommandGuids.guidDiffCmdSet, (int)CommandId.RunDiff);
     OleMenuCommand menuCommand = new OleMenuCommand((s, e) => PerformDiff(), commandId);
     menuCommand.BeforeQueryStatus += BeforeQueryStatus;
     _mcs.AddCommand(menuCommand);
 }
開發者ID:GProulx,項目名稱:WebEssentials2013,代碼行數:7,代碼來源:Diff.cs

示例3: RegisterCommand

 private void RegisterCommand(ToolbarCommand id, EventHandler callback)
 {
     var menuCommandID = new CommandID(PackageConstants.GuidTortoiseGitToolbarCmdSet, (int)id);
     var menuItem = new OleMenuCommand(callback, menuCommandID);
     menuItem.Visible = false;
     _commandService.AddCommand(menuItem);
 }
開發者ID:duncansmart,項目名稱:TortoiseGitToolbar,代碼行數:7,代碼來源:TortoiseGitToolbarPackage.cs

示例4: Initialize

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {

            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs != null)
            {
                // Create the command to generate the missing steps skeleton
                CommandID menuCommandID = new CommandID(GuidList.guidSpecFlowGenerateOption,
                                                        (int)PkgCmdIDList.cmdidGenerate);

                //Create a menu item corresponding to that command
                IFileHandler fileHandler = new FileHandler();
                StepFileGenerator stepFileGen = new StepFileGenerator(fileHandler);
                OleMenuCommand menuItem = new OleMenuCommand(stepFileGen.GenerateStepFileMenuItemCallback, menuCommandID);

                //Add an event handler to the menu item
                menuItem.BeforeQueryStatus += stepFileGen.QueryStatusMenuCommandBeforeQueryStatus;
                mcs.AddCommand(menuItem);

            }
        }
開發者ID:pmchugh,項目名稱:SpecFlow,代碼行數:29,代碼來源:SpecFlowPackage.cs

示例5: Register

 public static void Register(DTE2 dte, MenuCommandService mcs)
 {
     _dte = dte;
     CommandID nestAllId = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdRunNesting);
     OleMenuCommand menuNestAll = new OleMenuCommand(NestAll, nestAllId);
     mcs.AddCommand(menuNestAll);
 }
開發者ID:vandro,項目名稱:FileNesting,代碼行數:7,代碼來源:RunAutoNestingButton.cs

示例6: SetupCommands

 public void SetupCommands()
 {
     CommandID cmd = new CommandID(CommandGuids.guidImageCmdSet, (int)CommandId.CompressImage);
     OleMenuCommand menuCmd = new OleMenuCommand((s, e) => StartCompress(), cmd);
     menuCmd.BeforeQueryStatus += BeforeQueryStatus;
     _mcs.AddCommand(menuCmd);
 }
開發者ID:EdsonF,項目名稱:WebEssentials2013,代碼行數:7,代碼來源:CompressImage.cs

示例7: Initialize

 protected void Initialize(Guid menuGroup, int commandId)
 {
     var cmdId = new CommandID(menuGroup, commandId);
       Command = new OleMenuCommand(this.OnInvoke, cmdId);
       Command.BeforeQueryStatus += OnBeforeQueryStatus;
       CommandService.AddCommand(Command);
 }
開發者ID:bayulabster,項目名稱:viasfora,代碼行數:7,代碼來源:VsCommand.cs

示例8: InsertGuidCommand

 private InsertGuidCommand()
 {
     // Instance initialization
     _commandID = new CommandID(new Guid("3020eb2e-3b3d-4e0c-b165-5b8bd559a3cb"), 0x0100);
     _menuCommand = new OleMenuCommand(Execute, null, BeforeQueryStatus, _commandID);
     _visible = true;
 }
開發者ID:fschneidereit,項目名稱:VSEssentials,代碼行數:7,代碼來源:InsertGuidCommand.cs

示例9: CreateConfigCommand

 void CreateConfigCommand()
 {
     var configureCommandId = new CommandID(cmdSet, 1);
     configureCommand = new OleMenuCommand(delegate { configureMenuCallback.ConfigureCallback(); }, configureCommandId);
     configureCommand.BeforeQueryStatus += delegate { menuStatusChecker.ConfigureCommandStatusCheck(configureCommand); };
     menuCommandService.AddCommand(configureCommand);
 }
開發者ID:paulcbetts,項目名稱:Fody,代碼行數:7,代碼來源:MenuConfigure.cs

示例10: Initialize

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

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs) {
                var id = new CommandID(GuidList.GuidCmdSet, (int)PkgCmdIDList.FormatDocumentCommand);
                _formatDocMenuCommand = new OleMenuCommand(FormatDocumentCallback, id);
                mcs.AddCommand(_formatDocMenuCommand);
                _formatDocMenuCommand.BeforeQueryStatus += OnBeforeQueryStatus;

                id = new CommandID(GuidList.GuidCmdSet, (int)PkgCmdIDList.FormatSelectionCommand);
                _formatSelMenuCommand = new OleMenuCommand(FormatSelectionCallback, id);
                mcs.AddCommand(_formatSelMenuCommand);
                _formatSelMenuCommand.BeforeQueryStatus += OnBeforeQueryStatus;
            }

            _dte = (DTE)GetService(typeof(DTE));

            _documentEventListener = new DocumentEventListener(this);
            _documentEventListener.BeforeSave += OnBeforeDocumentSave;

            if (_dte.RegistryRoot.Contains("VisualStudio")) {
                _isCSharpEnabled = true;
            }

            _props = _dte.Properties["AStyle Formatter", "General"];
            _props.Item("IsCSarpEnabled").Value = _isCSharpEnabled;
        }
開發者ID:nelabidi,項目名稱:astyle-extension,代碼行數:29,代碼來源:AStyleExtensionPackage.cs

示例11: QueryStatusInternal

        protected override void QueryStatusInternal(OleMenuCommand command)
        {
            command.Enabled = false;
            command.Visible = false;
            if (this.propertyManager == null)
            {
                return;
            }

            IList<Project> projects = this.propertyManager
                                          .GetSelectedProjects()
                                          .ToList();

            if (projects.Any() && projects.All(x => Language.ForProject(x).IsSupported))
            {
                IList<bool?> properties = projects.Select(x =>
                    this.propertyManager.GetBooleanProperty(x, PropertyName)).ToList();

                command.Enabled = true;
                command.Visible = true;
                // Checked if all projects have the same value, and that value is
                // the same as the value this instance is responsible for.
                command.Checked = properties.AllEqual() && (properties.First() == this.commandPropertyValue);
            }
        }
開發者ID:SonarSource-VisualStudio,項目名稱:sonarlint-visualstudio,代碼行數:25,代碼來源:ProjectTestPropertySetCommand.cs

示例12: NuGetSearchTask

        public NuGetSearchTask(NuGetSearchProvider provider, uint cookie, IVsSearchQuery searchQuery, IVsSearchProviderCallback searchCallback, OleMenuCommand managePackageDialogCommand, OleMenuCommand managePackageForSolutionDialogCommand)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (searchQuery == null)
            {
                throw new ArgumentNullException("searchQuery");
            }
            if (searchCallback == null)
            {
                throw new ArgumentNullException("searchCallback");
            }
            if (managePackageDialogCommand == null)
            {
                throw new ArgumentNullException("managePackageDialogCommand");
            }
            if (managePackageForSolutionDialogCommand == null)
            {
                throw new ArgumentNullException("managePackageForSolutionDialogCommand");
            }
            _provider = provider;
            _searchCallback = searchCallback;
            _managePackageDialogCommand = managePackageDialogCommand;
            _managePackageForSolutionDialogCommand = managePackageForSolutionDialogCommand;

            SearchQuery = searchQuery;
            Id = cookie;
            ErrorCode = 0;

            SetStatus(VsSearchTaskStatus.Created);
        }
開發者ID:njannink,項目名稱:sonarlint-vs,代碼行數:33,代碼來源:NugetSearchTask.cs

示例13: Initialize

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                // Create the command for the menu items.
                CommandID pluginMenuCommandId1 = new CommandID(GuidList.guidMenuCommandsCmdSet, (int)PkgCmdIDList.cmdidAddItem1);
                OleMenuCommand pluginMenuItem1 = new OleMenuCommand(MenuItem1Callback, pluginMenuCommandId1);
                pluginMenuItem1.BeforeQueryStatus += menuItem1_BeforeQueryStatus;
                mcs.AddCommand(pluginMenuItem1);

                CommandID pluginMenuCommandId2 = new CommandID(GuidList.guidMenuCommandsCmdSet, (int)PkgCmdIDList.cmdidAddItem2);
                OleMenuCommand pluginMenuItem2 = new OleMenuCommand(MenuItem2Callback, pluginMenuCommandId2);
                pluginMenuItem2.BeforeQueryStatus += menuItem2_BeforeQueryStatus;
                mcs.AddCommand(pluginMenuItem2);

                CommandID pluginMenuCommandId3 = new CommandID(GuidList.guidMenuCommandsCmdSet, (int)PkgCmdIDList.cmdidAddItem3);
                OleMenuCommand pluginMenuItem3 = new OleMenuCommand(MenuItem3Callback, pluginMenuCommandId3);
                pluginMenuItem3.BeforeQueryStatus += menuItem3_BeforeQueryStatus;
                mcs.AddCommand(pluginMenuItem3);
            }
        }
開發者ID:kwechsler,項目名稱:CRMDeveloperExtensions,代碼行數:29,代碼來源:TemplateMenuCommandsPackage.cs

示例14: SetupCommands

 public void SetupCommands()
 {
     CommandID commandId = new CommandID(GuidList.guidEditorExtensionsCmdSet, (int)PkgCmdIDList.ReferenceJs);
     OleMenuCommand menuCommand = new OleMenuCommand((s, e) => Execute(), commandId);
     menuCommand.BeforeQueryStatus += menuCommand_BeforeQueryStatus;
     _mcs.AddCommand(menuCommand);
 }
開發者ID:Russe11,項目名稱:WebEssentials2013,代碼行數:7,代碼來源:ReferenceJs.cs

示例15: AddInheritDocCommand

		private AddInheritDocCommand(Package package)
		{
			this.package = package;

			OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
			if (commandService != null)
			{
				var menuCommandId = new CommandID(CommandSet, CommandId);
				var menuItem = new OleMenuCommand(MenuItemCallback, menuCommandId);
				commandService.AddCommand(menuItem);

				menuItem.BeforeQueryStatus += (sender, e) =>
					{
						bool visible = false;
						var dte = (DTE)Package.GetGlobalService(typeof(SDTE));
						var classElem = SearchService.FindClass(dte);
						if (classElem != null)
						{
							List<CodeElement> codeElements = SearchService.FindCodeElements(dte);
							if (classElem.ImplementedInterfaces.Count > 0)
							{
								visible = true;
							}
							else
							{
								visible = codeElements.Any(elem => elem.IsInherited() || elem.OverridesSomething());
							}
						}
						((OleMenuCommand)sender).Visible = visible;
					};
			}
		}
開發者ID:mmahulea,項目名稱:FactonExtensionPackage,代碼行數:32,代碼來源:AddInheritDocCommand.cs


注:本文中的Microsoft.VisualStudio.Shell.OleMenuCommand類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。