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


C# IMenuCommandService.AddCommand方法代码示例

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

示例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);
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:15,代码来源:ModelExplorer.cs

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

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

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

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

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

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

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

示例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;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:8,代码来源:AnalyzersCommandHandler.cs

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

示例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;
        }
开发者ID:philippbeckmann,项目名称:aliasbegone,代码行数:10,代码来源:AliasBeGonePackage.cs

示例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");
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:67,代码来源:TreeViewDesigner.cs

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

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


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