예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Command2"/> 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 Command2(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("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 MenuCommand(this.MenuItemCallback, menuCommandID);
                //commandService.AddCommand(menuItem);

                OleMenuCommand myOleCommand = new OleMenuCommand(this.MenuItemCallback, menuCommandID);
                buttonMenuCommand = myOleCommand;
                if (!Command1Package.CommandShouldShowText())
                {
                    myOleCommand.Text = " ";
                }
                commandService.AddCommand(myOleCommand);
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Command3"/> 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 Command3(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("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 MenuCommand(this.MenuItemCallback, menuCommandID);
                // commandService.AddCommand(menuItem);

                myOleCommand = new OleMenuCommand(this.MenuItemCallback, menuCommandID);
                if (!Command1Package.CommandShouldShowText())
                {
                    myOleCommand.Text = " ";
                }

                //Microsoft.VisualStudio.Shell.ServiceProvider serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider(((EnvDTE.DTE)Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE))) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);
                //IVsUIShell uiShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;
                //uiShell.UpdateCommandUI(0);

                commandService.AddCommand(myOleCommand);
            }
        }
예제 #3
0
 public void SetStartupCommandTextState()
 {
     if (!Command1Package.CommandShouldShowText())
     {
         buttonMenuCommand.Text = " ";
     }
     else
     {
         buttonMenuCommand.Text = commandText;
     }
 }