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


C# IMenuCommandService类代码示例

本文整理汇总了C#中IMenuCommandService的典型用法代码示例。如果您正苦于以下问题:C# IMenuCommandService类的具体用法?C# IMenuCommandService怎么用?C# IMenuCommandService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IMenuCommandService类属于命名空间,在下文中一共展示了IMenuCommandService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        /// <summary>
        /// Hook up the context menu handlers.
        /// </summary>
        public void Initialize(IMenuCommandService menuCommandService)
        {
            if (menuCommandService != null)
            {
                _addMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.AddAnalyzer, AddAnalyzerHandler);
                _projectAddMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.ProjectAddAnalyzer, AddAnalyzerHandler);
                _projectContextAddMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.ProjectContextAddAnalyzer, AddAnalyzerHandler);
                _referencesContextAddMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.ReferencesContextAddAnalyzer, AddAnalyzerHandler);

                _removeMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.RemoveAnalyzer, RemoveAnalyzerHandler);

                _openRuleSetMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.OpenRuleSet, OpenRuleSetHandler);

                _setSeverityErrorMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityError, SetSeverityHandler);
                _setSeverityWarningMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityWarning, SetSeverityHandler);
                _setSeverityInfoMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityInfo, SetSeverityHandler);
                _setSeverityHiddenMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityHidden, SetSeverityHandler);
                _setSeverityNoneMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityNone, SetSeverityHandler);

                UpdateMenuItemVisibility();
                UpdateMenuItemsChecked();

                if (_tracker != null)
                {
                    _tracker.SelectedHierarchyChanged += SelectedHierarchyChangedHandler;
                    _tracker.SelectedDiagnosticItemsChanged += SelectedDiagnosticItemsChangedHandler;
                    _tracker.SelectedItemIdChanged += SelectedItemIdChangedHandler;
                }

                var buildManager = (IVsSolutionBuildManager)_serviceProvider.GetService(typeof(SVsSolutionBuildManager));
                uint cookie;
                buildManager.AdviseUpdateSolutionEvents(this, out cookie);
            }
        }
开发者ID:JinGuoGe,项目名称:roslyn,代码行数:37,代码来源:AnalyzersCommandHandler.cs

示例2: InitializeCommands

        private void InitializeCommands(XmlRepository repository, IConfiguration configuration, IMenuCommandService commandService)
        {
            var activeDocument = new ActiveDocument();

            var subMenu = CreateSubMenu(activeDocument);
            commandService.AddCommand(subMenu);

            var copyGenericXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyGenericXPath, repository, activeDocument, () => new XPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes)}), new CommandTextFormatter());
            commandService.AddCommand(copyGenericXPathCommand);

            var copyAbsoluteXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyAbsoluteXPath, repository, activeDocument, () => new AbsoluteXPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes)}), new CommandTextFormatter());
            commandService.AddCommand(copyAbsoluteXPathCommand);

            var copyDistinctXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyDistinctXPath, repository, activeDocument, () => new XPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes), new DistinctAttributeFilter(configuration.PreferredAttributeCandidates)}), new CommandTextFormatter());
            commandService.AddCommand(copyDistinctXPathCommand);

            var copySimplifiedXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopySimplifiedXPath, repository, activeDocument, () => new SimplifiedXPathWriter(new[] { new AttributeFilter(configuration.AlwaysDisplayedAttributes) }), new TrimCommandTextFormatter());
            commandService.AddCommand(copySimplifiedXPathCommand);

            var showXPathWorkbenchCommand = new ShowXPathWorkbenchCommand(this, commandService, Symbols.CommandIDs.ShowXPathWorkbench, repository, activeDocument);
            commandService.AddCommand(showXPathWorkbenchCommand.Command);

            var copyXmlStructureCommand = new CopyXmlStructureCommand(Symbols.CommandIDs.CopyXmlStructure, repository, activeDocument, () => new XmlStructureWriter(), new CommandTextFormatter());
            commandService.AddCommand(copyXmlStructureCommand);
        }
开发者ID:uli-weltersbach,项目名称:XPathInformation,代码行数:25,代码来源:XPathInformationPackage.cs

示例3: AddSuppressionsCommandHandlers

 private void AddSuppressionsCommandHandlers(IMenuCommandService menuCommandService)
 {
     AddCommand(menuCommandService, ID.RoslynCommands.AddSuppressions, delegate { }, OnAddSuppressionsStatus);
     AddCommand(menuCommandService, ID.RoslynCommands.AddSuppressionsInSource, OnAddSuppressionsInSource, OnAddSuppressionsInSourceStatus);
     AddCommand(menuCommandService, ID.RoslynCommands.AddSuppressionsInSuppressionFile, OnAddSuppressionsInSuppressionFile, OnAddSuppressionsInSuppressionFileStatus);
     AddCommand(menuCommandService, ID.RoslynCommands.RemoveSuppressions, OnRemoveSuppressions, OnRemoveSuppressionsStatus);
 }
开发者ID:jkotas,项目名称:roslyn,代码行数:7,代码来源:VisualStudioDiagnosticListTableCommandHandler.cs

示例4: CommandSet

 public CommandSet(ISite site)
 {
     this.site = site;
     this.eventService = (IEventHandlerService) site.GetService(typeof(IEventHandlerService));
     this.eventService.EventHandlerChanged += new EventHandler(this.OnEventHandlerChanged);
     IDesignerHost host = (IDesignerHost) site.GetService(typeof(IDesignerHost));
     if (host != null)
     {
         host.Activated += new EventHandler(this.UpdateClipboardItems);
     }
     this.statusCommandUI = new StatusCommandUI(site);
     IUIService uiService = site.GetService(typeof(IUIService)) as IUIService;
     this.commandSet = new CommandSetItem[] {
         new CommandSetItem(this, new EventHandler(this.OnStatusDelete), new EventHandler(this.OnMenuDelete), StandardCommands.Delete, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusCopy), new EventHandler(this.OnMenuCopy), StandardCommands.Copy, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusCut), new EventHandler(this.OnMenuCut), StandardCommands.Cut, uiService), new ImmediateCommandSetItem(this, new EventHandler(this.OnStatusPaste), new EventHandler(this.OnMenuPaste), StandardCommands.Paste, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusSelectAll), new EventHandler(this.OnMenuSelectAll), StandardCommands.SelectAll, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuDesignerProperties), MenuCommands.DesignerProperties, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyReverseCancel, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusPrimarySelection), new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveUp, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveDown, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveLeft, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveRight, true), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeUp, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeDown, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeLeft, true, uiService),
         new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeRight, true, uiService)
      };
     this.selectionService = (ISelectionService) site.GetService(typeof(ISelectionService));
     if (this.selectionService != null)
     {
         this.selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     this.menuService = (IMenuCommandService) site.GetService(typeof(IMenuCommandService));
     if (this.menuService != null)
     {
         for (int i = 0; i < this.commandSet.Length; i++)
         {
             this.menuService.AddCommand(this.commandSet[i]);
         }
     }
     IDictionaryService service = site.GetService(typeof(IDictionaryService)) as IDictionaryService;
     if (service != null)
     {
         service.SetValue(typeof(CommandID), new CommandID(new Guid("BA09E2AF-9DF2-4068-B2F0-4C7E5CC19E2F"), 0));
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:35,代码来源:CommandSet.cs

示例5: 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);
 }
开发者ID:hhahh2011,项目名称:CH.EasyCode,代码行数:7,代码来源:AbstractCommand.cs

示例6: ShowContextMenu

        public static void ShowContextMenu(IMenuCommandService service, Control owner, int x, int y)
        {
            var menu = new ContextMenuStrip();
            menu.Items.AddRange(GetMenuItems(service.Verbs));
            menu.Show(owner, x, y);

        }
开发者ID:die-Deutsche-Orthopaedie,项目名称:LiteDevelop,代码行数:7,代码来源:MenuService.cs

示例7: MenuConfigure

 public MenuConfigure(ConfigureMenuCallback configureMenuCallback, DisableMenuConfigure disableMenuConfigure, IMenuCommandService menuCommandService, MenuStatusChecker menuStatusChecker)
 {
     this.configureMenuCallback = configureMenuCallback;
     this.disableMenuConfigure = disableMenuConfigure;
     this.menuCommandService = menuCommandService;
     this.menuStatusChecker = menuStatusChecker;
 }
开发者ID:paulcbetts,项目名称:Fody,代码行数:7,代码来源:MenuConfigure.cs

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

示例9: 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;
 }
开发者ID:modulexcite,项目名称:tfsproductivitypack,代码行数:8,代码来源:AbstractCommand.cs

示例10: MenuConfigure

 public MenuConfigure(CurrentProjectFinder currentProjectFinder, ExceptionDialog exceptionDialog, ConfigureMenuCallback configureMenuCallback, DisableMenuConfigure disableMenuConfigure, IMenuCommandService menuCommandService)
 {
     this.exceptionDialog = exceptionDialog;
     this.configureMenuCallback = configureMenuCallback;
     this.disableMenuConfigure = disableMenuConfigure;
     this.menuCommandService = menuCommandService;
     this.currentProjectFinder = currentProjectFinder;
 }
开发者ID:sachhi,项目名称:costura,代码行数:8,代码来源:MenuConfigure.cs

示例11: ORMModelBrowserCommandSet

			public ORMModelBrowserCommandSet(IServiceProvider provider, IMenuCommandService menuService)
			{
				myServiceProvider = provider;
				myMenuService = menuService;
				#region command array
				myCommands = new MenuCommand[]{
					new DynamicStatusMenuCommand(
					new EventHandler(OnStatusDelete),
					new EventHandler(OnMenuDelete),
					StandardCommands.Delete)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusEditLabel),
					new EventHandler(OnMenuEditLabel),
					EditLabelCommandID)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusExclusiveOrDecoupler),
					new EventHandler(OnMenuExclusiveOrDecoupler),
					ORMDesignerDocView.ORMDesignerCommandIds.ExclusiveOrDecoupler)
					,new DynamicDiagramCommand(
					new EventHandler(OnStatusDiagramList),
					new EventHandler(OnMenuDiagramList),
					ORMDesignerDocView.ORMDesignerCommandIds.DiagramList)
					,new DynamicDiagramCommand(
					new EventHandler(OnStatusDiagramList),
					new EventHandler(OnMenuDiagramSpyDiagramList),
					ORMDesignerDocView.ORMDesignerCommandIds.DiagramSpyDiagramList)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusSelectShapeInDocumentWindow),
					new EventHandler(OnMenuSelectShapeInDocumentWindow),
					ORMDesignerDocView.ORMDesignerCommandIds.SelectInDocumentWindow)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusSelectShapeInDiagramSpy),
					new EventHandler(OnMenuSelectShapeInDiagramSpy),
					ORMDesignerDocView.ORMDesignerCommandIds.SelectInDiagramSpy)
					,new DynamicFreeFormCommand(
					new EventHandler(OnStatusFreeFormCommand),
					new EventHandler(OnMenuFreeFormCommand),
					ORMDesignerDocView.ORMDesignerCommandIds.FreeFormCommandList)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusIncludeInGroup),
					new EventHandler(OnMenuIncludeInGroup),
					ORMDesignerDocView.ORMDesignerCommandIds.IncludeInGroup)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusIncludeInNewGroup),
					new EventHandler(OnMenuIncludeInNewGroup),
					ORMDesignerDocView.ORMDesignerCommandIds.IncludeInNewGroup)
					,new DynamicIncludeInGroupCommand(
					new EventHandler(OnStatusIncludeInGroupList),
					new EventHandler(OnMenuIncludeInGroupList),
					ORMDesignerDocView.ORMDesignerCommandIds.IncludeInGroupList)
					,new DynamicDeleteFromGroupCommand(
					new EventHandler(OnStatusDeleteFromGroupList),
					new EventHandler(OnMenuDeleteFromGroupList),
					ORMDesignerDocView.ORMDesignerCommandIds.DeleteFromGroupList)
				};
				#endregion //command array
				AddCommands(myCommands);
			}
开发者ID:cjheath,项目名称:NORMA,代码行数:58,代码来源:ORMModelBrowserCommandSet.cs

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

示例13: DesignerActionKeyboardBehavior

 public DesignerActionKeyboardBehavior(DesignerActionPanel panel, IServiceProvider serviceProvider, BehaviorService behaviorService) : base(true, behaviorService)
 {
     this.panel = panel;
     if (serviceProvider != null)
     {
         this.menuService = serviceProvider.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
         this.daUISvc = serviceProvider.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:DesignerActionKeyboardBehavior.cs

示例14: Initialize

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

            _menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            _uiShell = GetService(typeof(SVsUIShell)) as IVsUIShell;

            AddMenuCommand(CommandIds.TotalCommander, HandleTotalCommanderMenuCommand, options => true);
        }
开发者ID:deus-amd,项目名称:VisualStudioExtensions,代码行数:9,代码来源:TotalCommanderLauncherPackage.cs

示例15: 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;
 }
开发者ID:jkotas,项目名称:roslyn,代码行数:14,代码来源:VisualStudioDiagnosticListTableCommandHandler.cs


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