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


C# Command.AddControl方法代码示例

本文整理汇总了C#中Command.AddControl方法的典型用法代码示例。如果您正苦于以下问题:C# Command.AddControl方法的具体用法?C# Command.AddControl怎么用?C# Command.AddControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Command的用法示例。


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

示例1: _RegisterGuiContext

		protected void _RegisterGuiContext(Command vsCommand, string name)
		{
			CommandBar b = ((CommandBars)Plugin.App.CommandBars)[name];
			if(null != b)
			{
				CommandBarControl control = (CommandBarControl)vsCommand.AddControl(b, b.Controls.Count + 1);
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:_To-Do-unreal-3D-niftyplugins-ben-marsh,代码行数:8,代码来源:CommandBase.cs

示例2: RegisterGUI

		public virtual bool RegisterGUI(Command vsCommand, CommandBar vsCommandbar, bool toolBarOnly)
		{
			// The default command is registered in the toolbar.
			if(IconIndex >= 0 && toolBarOnly)
				vsCommand.AddControl(vsCommandbar, vsCommandbar.Controls.Count + 1);

			return true;
		}
开发者ID:transformersprimeabcxyz,项目名称:_To-Do-unreal-3D-niftyplugins-ben-marsh,代码行数:8,代码来源:CommandBase.cs

示例3: OnConnection

        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        /// <param term='application'>Root object of the host application.</param>
        /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param term='addInInst'>Object representing this Add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;

            Commands2 commands = (Commands2)_applicationObject.Commands;

            try
            {
                _command = _applicationObject.Commands.Item(_addInInstance.ProgID + "." + COMMAND_NAME, -1);
            }
            catch
            {
            }
            // Add the command if it does not exist
            if (_command == null)
            {
                object[] contextUIGuids = new object[] { };
                _command = commands.AddNamedCommand(_addInInstance, COMMAND_NAME, "Dump references", "Dump the references of all projects", true, 59, ref contextUIGuids,
                                                (int)(vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled));

                CommandBar standardToolBar = ((CommandBars)_applicationObject.CommandBars)["Solution"];
                CommandBarButton dumpRefsBtn = (CommandBarButton)_command.AddControl(standardToolBar, standardToolBar.Controls.Count);

                // Change some button properties
                dumpRefsBtn.Caption = "Dump References";
                dumpRefsBtn.Style = MsoButtonStyle.msoButtonIcon;
                dumpRefsBtn.BeginGroup = true;
                dumpRefsBtn.Visible = true;
            }
        }
开发者ID:CoherentLabs,项目名称:DumpReferencesAddIn,代码行数:36,代码来源:Connect.cs

示例4: CreateAddInMenu

		/*
		 * CreateAddInMenu
		 */

		/// <summary>
		/// </summary>
		/// <param name="menuCommand"></param>
		/// <param name="commandBarToAddMenuTo"></param>
		/// <param name="menuPosition"></param>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="menuCommand"/> is <see langword="null"/>.
		/// </para>
		/// -or-
		/// <para>
		///		<paramref name="commandBarToAddMenuTo"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public static CommandBarControl CreateAddInMenu(
			Command menuCommand,
			CommandBar commandBarToAddMenuTo,
			int menuPosition
			)
		{
			if (menuCommand == null)
			{
				throw new ArgumentNullException("menuCommand");
			}

			if (commandBarToAddMenuTo == null)
			{
				throw new ArgumentNullException("commandBarToAddMenuTo");
			}

			CommandBarControl menuItem = null;

			try
			{
				menuItem = (CommandBarControl)menuCommand.AddControl(commandBarToAddMenuTo, menuPosition);
			}
			catch (Exception e)
			{
				if (_errorEnabled)
				{
					Trace.TraceError(e.Message);
				}

				throw;
			}
			finally
			{
				if (menuItem != null)
				{
					menuItem.Visible = true;
				}
			}

			return menuItem;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:59,代码来源:NuGenExtensibility.cs

示例5: LoadPluginFunction

        private void LoadPluginFunction()
        {
            object[] contextGUIDS = new object[] { };
            Commands2 commands = (Commands2)_applicationObject.Commands;

            //将此命令置于“工具”菜单上。
            //查找 MenuBar 命令栏,该命令栏是容纳所有主菜单项的顶级命令栏:
            Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];

            //在 MenuBar 命令栏上查找“工具”命令栏:
            CommandBarControl toolsControl = menuBarCommandBar.Controls["工具"];
            CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;

            //如果希望添加多个由您的外接程序处理的命令,可以重复此 try/catch 块,
            //  只需确保更新 QueryStatus/Exec 方法,使其包含新的命令名。
            try
            {
                //将一个命令添加到 Commands 集合:
                MenubarCommand = commands.AddNamedCommand2(_addInInstance, "FileModifyRecorder", "文件修改记录...", "显示文件修改记录", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);

                //将对应于该命令的控件添加到“工具”菜单:
                if ((MenubarCommand != null) && (toolsPopup != null))
                {
                    MenubarCommand.AddControl(toolsPopup.CommandBar, 1);
                }
            }
            catch (System.ArgumentException)
            {
                //如果出现此异常,原因很可能是由于具有该名称的命令
                //  已存在。如果确实如此,则无需重新创建此命令,并且
                //  可以放心忽略此异常。
            }

            docEvents = (EnvDTE.DocumentEvents)_applicationObject.Events.get_DocumentEvents(null);
            docEvents.DocumentSaved -= saveHandler;
            docEvents.DocumentSaved += saveHandler;
            Loaded = true;
            OutPutLogToStatusBar(" 文件记录模块加载完毕",true);
        }
开发者ID:Ember213021,项目名称:VS8Plugin,代码行数:39,代码来源:Connect.cs

示例6: AddCommandToWindow

        private void AddCommandToWindow(Command copyCommand, string windowType)
        {
            var commandBars = (CommandBars)Application.CommandBars;
            var codeWindowCommandBar = commandBars[windowType];

            _featureCopy = (CommandBarPopup) codeWindowCommandBar.Controls.Add(MsoControlType.msoControlPopup,
                                                                               Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            _featureCopy.Caption = "Feature";

            var copyButton = (CommandBarControl)copyCommand.AddControl(_featureCopy.CommandBar,
                                                                       _featureCopy.Controls.Count + 1);

            copyButton.Caption = "Copy";
            copyButton.TooltipText = "Copy's all feature resources to main application";

            Logger.Log("Menu has been initailized");
        }
开发者ID:jhollingworth,项目名称:FeatureMirror,代码行数:17,代码来源:Connect.cs

示例7: GetOrCreateCommandBarButton

        private CommandBarButton GetOrCreateCommandBarButton(CommandBar commandBar, Command command, Commands2 commands)
        {
            foreach (CommandBarControl control in commandBar.Controls)
            {
                CommandBarButton button = control as CommandBarButton;
                if (button != null)
                {
                    string guid;
                    int id;
                    commands.CommandInfo(control, out guid, out id);

                    if (command.Guid == guid)
                        return button;
                }
            }

            return (CommandBarButton)command.AddControl(commandBar, 1);
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:18,代码来源:DefaultCommandManager.cs

示例8: OnSolutionOpened

        void OnSolutionOpened()
        {
            object[] contextGUIDS = new object[] { };
            Commands2 commands = (Commands2)_applicationObject.Commands;
            string debugMenuName = "Debug";

            //Place the command on the debug menu.
            //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
            Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];

            //Find the Debug command bar on the MenuBar command bar:
            CommandBarControl debugControl = menuBarCommandBar.Controls[debugMenuName];
            CommandBarPopup debugPopup = (CommandBarPopup)debugControl;

            //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in,
            //  just make sure you also update the QueryStatus/Exec method to include the new command names.
            try
            {
                //Add a command to the Commands collection:
                _commandBreakAll = commands.AddNamedCommand2(_addInInstance, "BreakAll", "Set Class Breakpoint", "Sets a breakpoint for each member of each class in the current file", true, Type.Missing, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
                _commandBreakNone = commands.AddNamedCommand2(_addInInstance, "BreakNone", "Delete All Breakpoints In File", "Deletes all breakpoints in the current file", true, Type.Missing, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);

                int position = 1;
                foreach (CommandBarControl command in debugPopup.CommandBar.Controls)
                {
                    position++;
                    if (command.accName.ToLower().Contains("disable all breakpoints"))
                    {
                        break;
                    }
                }

                //Add a control for the command to the tools menu:
                if ((_commandBreakAll != null) && (_commandBreakNone != null) && (debugPopup != null))
                {
                    _commandBreakAll.AddControl(debugPopup.CommandBar, position);
                    _commandBreakNone.AddControl(debugPopup.CommandBar, position);
                }

                _commandBreakAll.Bindings = "Text Editor::ctrl+d, z";
                _commandBreakNone.Bindings = "Text Editor::ctrl+d, x";
            }
            catch (System.ArgumentException)
            {
                //If we are here, then the exception is probably because a command with that name
                //  already exists. If so there is no need to recreate the command and we can
                //  safely ignore the exception.
            }
        }
开发者ID:Kuntal-Mehta,项目名称:vs-breakall,代码行数:49,代码来源:Connect.cs

示例9: CreateButton

        private CommandBarButton CreateButton(Command iCommand, CommandBar iCommandBar, string iCaption, bool iBeginGroup = false, int iPosition = -1)
        {
            int position = (iPosition == -1) ? iCommandBar.Controls.Count + 1 : iPosition;

              CommandBarButton button = (CommandBarButton)iCommand.AddControl(iCommandBar, position);

              button.Caption = iCaption;
              button.BeginGroup = iBeginGroup;

              return button;
        }
开发者ID:noizefloor,项目名称:cppcheck-vs-add-in,代码行数:11,代码来源:UIHandler.cs

示例10: IsEnabled

		public abstract bool IsEnabled();	// is the command active?

		protected void _RegisterGUIBar(Command vsCommand, CommandBar vsCommandbar)
		{
			CommandBarControl control = (CommandBarControl)vsCommand.AddControl(vsCommandbar, vsCommandbar.Controls.Count + 1);
		}
开发者ID:transformersprimeabcxyz,项目名称:_To-Do-unreal-3D-niftyplugins-ben-marsh,代码行数:6,代码来源:CommandBase.cs


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