コード例 #1
0
        private IntegrationTestServiceCommands(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            _package = package;

            var commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                var startServiceMenuCmdId = new CommandID(GrpIdIntegrationTestServiceCommands, CmdIdStartIntegrationTestService);
                _startServiceMenuCmd = new MenuCommand(StartServiceCallback, startServiceMenuCmdId) {
                    Enabled = true,
                    Supported = true,
                    Visible = true
                };
                commandService.AddCommand(_startServiceMenuCmd);

                var stopServiceMenuCmdId = new CommandID(GrpIdIntegrationTestServiceCommands, CmdIdStopIntegrationTestService);
                _stopServiceMenuCmd = new MenuCommand(StopServiceCallback, stopServiceMenuCmdId) {
                    Enabled = false,
                    Supported = true,
                    Visible = false
                };
                commandService.AddCommand(_stopServiceMenuCmd);
            }

        }
コード例 #2
0
 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);
 }
コード例 #3
0
 public override void ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y)
 {
     //if (this.Verbs != null)
     {
         ContextMenu cm = new ContextMenu();
         //foreach (DesignerVerb verb in this.Verbs)
         //{
         MenuItem menuItem = new MenuItem("Delete");
         menuItem.Click += new EventHandler(menuItem_Click);
         menuItem.Tag    = StandardCommands.Delete;
         cm.MenuItems.Add(menuItem);
         //}
         //
         menuItem        = new MenuItem("Undo");
         menuItem.Click += new EventHandler(menuItem_Click);
         menuItem.Tag    = StandardCommands.Undo;
         cm.MenuItems.Add(menuItem);
         //
         if (cm.MenuItems.Count > 0)
         {
             IDesignerHost     host = (IDesignerHost)this.GetService(typeof(IDesignerHost));
             ISelectionService ss   = host.GetService(typeof(ISelectionService)) as ISelectionService;
             Control           ps   = ss.PrimarySelection as Control;
             Point             s    = ps.PointToScreen(new Point(0, 0));
             cm.Show(ps, new Point(x - s.X, y - s.Y));
         }
     }
 }
コード例 #4
0
 public void SetupCommands()
 {
     CommandID commandSol = new CommandID(GuidList.guidDiffCmdSet, (int)PkgCmdIDList.cmdSolutionColors);
     OleMenuCommand menuCommandSol = new OleMenuCommand((s, e) => ApplySolutionSettings(), commandSol);
     menuCommandSol.BeforeQueryStatus += SolutionBeforeQueryStatus;
     _mcs.AddCommand(menuCommandSol);
 }
コード例 #5
0
ファイル: SpecFlowPackage.cs プロジェクト: pmchugh/SpecFlow
        /// <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);

            }
        }
コード例 #6
0
        /*
         * private void InitializeGlobalCommands()
         * {
         *      //Most commands like Delete, Cut, Copy and paste are all added to the MenuCommandService
         *      // by the other services like the DesignerHost.  Commands like ViewCode and ShowProperties
         *      // need to be added by the IDE because only the IDE would know how to perform those actions.
         *      // This allows people to call MenuCommandSerice.GlobalInvoke( StandardCommands.ViewCode );
         *      // from designers and what not.  .Net Control Designers like the TableLayoutPanelDesigner
         *      // build up their own context menus instead of letting the MenuCommandService build it.
         *      // The context menus they build up are in the format that Visual studio expects and invokes
         *      // the ViewCode and Properties commands by using GlobalInvoke.
         *
         * //			AbstractFormsDesignerCommand viewCodeCommand = new ViewCode();
         * //			AbstractFormsDesignerCommand propertiesCodeCommand = new ShowProperties();
         * //			this.AddCommand( new MenuCommand(viewCodeCommand.CommandCallBack, viewCodeCommand.CommandID));
         * //			this.AddCommand( new MenuCommand(propertiesCodeCommand.CommandCallBack, propertiesCodeCommand.CommandID));
         * }
         */
        public override void ShowContextMenu(CommandID menuID, int x, int y)
        {
            string            contextMenuPath = "/SharpDevelop/ReportDesigner/ContextMenus/";
            ISelectionService sp = (ISelectionService)base.GetService(typeof(ISelectionService));

            if (sp != null)
            {
                if (menuID == MenuCommands.TraySelectionMenu)
                {
                    contextMenuPath += "TraySelectionMenu";
                }
                else if (sp.PrimarySelection is RootReportModel)
                {
                    System.Console.WriteLine("found Root");
                    contextMenuPath += "ContainerMenu";
                }
                else if (sp.PrimarySelection is BaseSection)
                {
                    System.Console.WriteLine("found baseSection");
                    contextMenuPath += "ContainerMenu";
                }
                else
                {
                    contextMenuPath += "SelectionMenu";
                }

                Point p = panel.PointToClient(new Point(x, y));
                MenuService.ShowContextMenu(this, contextMenuPath, panel, p.X, p.Y);
            }
        }
コード例 #7
0
 public void SetupCommands()
 {
     CommandID cmd = new CommandID(CommandGuids.guidImageCmdSet, (int)CommandId.SpriteImage);
     OleMenuCommand menuCmd = new OleMenuCommand(async (s, e) => await MakeSpriteAsync(), cmd);
     menuCmd.BeforeQueryStatus += BeforeQueryStatus;
     _mcs.AddCommand(menuCmd);
 }
コード例 #8
0
        protected override void Initialize()
        {
            base.Initialize();

            _logger = new Logger();

            _dte = GetGlobalService(typeof(DTE)) as DTE;
            if (_dte == null)
                return;

            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (mcs != null)
            {
                CommandID publishCommandId = new CommandID(GuidList.GuidItemMenuCommandsCmdSet, (int)PkgCmdIdList.CmdidWebResourceDeployerPublish);
                OleMenuCommand publishMenuItem = new OleMenuCommand(PublishItemCallback, publishCommandId);
                publishMenuItem.BeforeQueryStatus += PublishItem_BeforeQueryStatus;
                publishMenuItem.Visible = false;
                mcs.AddCommand(publishMenuItem);

                CommandID editorPublishCommandId = new CommandID(GuidList.GuidEditorCommandsCmdSet, (int)PkgCmdIdList.CmdidWebResourceEditorPublish);
                OleMenuCommand editorPublishMenuItem = new OleMenuCommand(PublishItemCallback, editorPublishCommandId);
                editorPublishMenuItem.BeforeQueryStatus += PublishItem_BeforeQueryStatus;
                editorPublishMenuItem.Visible = false;
                mcs.AddCommand(editorPublishMenuItem);
            }
        }
コード例 #9
0
		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;
					};
			}
		}
コード例 #10
0
ファイル: AliaserCommand.cs プロジェクト: jiriKuba/Aliaser
        /// <summary>
        /// Initializes a new instance of the <see cref="AliaserCommand"/> 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 AliaserCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;
            this.MainService = new AliaserService();

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                CommandID menuToAliasCommandID = new CommandID(MenuGroup, ALIASER_TO_ALIAS_COMMAND_ID);
                CommandID menuToInstanceCommandID = new CommandID(MenuGroup, ALIASER_TO_INSTANCE_COMMAND_ID);

                EventHandler transformAliasToInstace = this.TransformAliasToInstace;
                EventHandler transformInstaceToAlias = this.TransformInstaceToAlias;

                MenuCommand menuItemToInstace = new MenuCommand(transformAliasToInstace, menuToInstanceCommandID);
                MenuCommand menuItemToAlias = new MenuCommand(transformInstaceToAlias, menuToAliasCommandID);

                commandService.AddCommand(menuItemToInstace);
                commandService.AddCommand(menuItemToAlias);
            }
        }
コード例 #11
0
        protected override void Initialize()
        {
            base.Initialize();

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

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

            CommandID cmdCustom = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenCommandLine);
            OleMenuCommand customItem = new OleMenuCommand(OpenCustom, cmdCustom);
            customItem.BeforeQueryStatus += BeforeQueryStatus;
            mcs.AddCommand(customItem);

            CommandID cmdCmd = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenCmd);
            MenuCommand cmdItem = new MenuCommand(OpenCmd, cmdCmd);
            mcs.AddCommand(cmdItem);

            CommandID cmdPowershell = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenPowershell);
            MenuCommand powershellItem = new MenuCommand(OpenPowershell, cmdPowershell);
            mcs.AddCommand(powershellItem);

            CommandID cmdOptions = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenOptions);
            MenuCommand optionsItem = new MenuCommand((s, e) => { ShowOptionPage(typeof(Options)); }, cmdOptions);
            mcs.AddCommand(optionsItem);

            CommandID cmdExe = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdExecuteCmd);
            OleMenuCommand exeItem = new OleMenuCommand(ExecuteFile, cmdExe);
            exeItem.BeforeQueryStatus += BeforeExeQuery;
            mcs.AddCommand(exeItem);
        }
コード例 #12
0
ファイル: MyToolWindow.cs プロジェクト: niaher/Crool
        /// <summary>
        /// Standard constructor for the tool window.
        /// </summary>
        public MyToolWindow()
            : base(null)
        {
            // Set the window title reading it from the resources.
            this.Caption = Resources.ToolWindowTitle;

            // Set the image that will appear on the tab of the window frame
            // when docked with an other window
            // The resource ID correspond to the one defined in the resx file
            // while the Index is the offset in the bitmap strip. Each image in
            // the strip being 16x16.
            this.BitmapResourceID = 301;
            this.BitmapIndex = 1;

            // Create the toolbar.
            this.ToolBar = new CommandID(GuidList.GuidCroolPackageCmdSet, PkgCmdIDList.ToolbarID);
            this.ToolBarLocation = (int)VSTWT_LOCATION.VSTWT_TOP;

            // Create the handlers for the toolbar commands.
            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                // Command for the combo's list
                var comboListCmdID = new CommandID(GuidList.GuidCroolPackageCmdSet, PkgCmdIDList.CmdidWindowsMediaFilenameGetList);
                var comboMenuList = new OleMenuCommand(new EventHandler(this.ComboListHandler), comboListCmdID);
                mcs.AddCommand(comboMenuList);
            }

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
            // the object returned by the Content property.
            this.Content = new MyControl();
        }
コード例 #13
0
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            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 item.
                CommandID menuCommandID = new CommandID(GuidList.guidVSScriptsCmdSet, (int)PkgCmdIDList.cmdidConfigureScripts);
                MenuCommand menuItem = new MenuCommand(HandleScriptsCmd, menuCommandID);
                mcs.AddCommand(menuItem);

                LoadScriptsList();

                for (int i = 0; i < PkgCmdIDList.numScripts; ++i)
                {
                    var cmdID = new CommandID(GuidList.guidVSScriptsCmdSet, PkgCmdIDList.cmdidScript0 + i);
                    var cmd = new OleMenuCommand(new EventHandler(HandleScriptMenuItem), cmdID);
                    cmd.BeforeQueryStatus += new EventHandler(HandleScriptBeforeQueryStatus);
                    cmd.Visible = true;

                    mcs.AddCommand(cmd);
                }
            }
        }
コード例 #14
0
        // This function is called by the IVsSccProvider service implementation when the active state of the provider changes
        // The package needs to show or hide the scc-specific commands
        public virtual void OnActiveStateChange()
        {
            MsVsShell.OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as MsVsShell.OleMenuCommandService;
            if (mcs != null)
            {
                CommandID cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommand);
                MenuCommand menuCmd = mcs.FindCommand(cmd);
                menuCmd.Supported = true;
                menuCmd.Enabled = sccService.Active;
                menuCmd.Visible = sccService.Active;

                cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdViewToolWindow);
                menuCmd = mcs.FindCommand(cmd);
                menuCmd.Supported = true;
                menuCmd.Enabled = sccService.Active;
                menuCmd.Visible = sccService.Active;

                cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdToolWindowToolbarCommand);
                menuCmd = mcs.FindCommand(cmd);
                menuCmd.Supported = true;
                menuCmd.Enabled = sccService.Active;
                menuCmd.Visible = sccService.Active;
            }

            ShowSccProviderToolWindow();
        }
コード例 #15
0
ファイル: ChoreoPackage.cs プロジェクト: saaadhu/choreo
        /// <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 ( null != mcs )
            {
                // Create the command for the menu item.
                CommandID menuCommandID = new CommandID(GuidList.guidChoreoCmdSet, (int)PkgCmdIDList.cmdidMyCommand);
                MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID );
                mcs.AddCommand( menuItem );
                //// Create the command for the tool window
                //CommandID toolwndCommandID = new CommandID(GuidList.guidChoreoCmdSet, (int)PkgCmdIDList.cmdidMyTool);
                //MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
                //mcs.AddCommand( menuToolWin );
            }

            MacroManager.Initialize(this);
            MacroManager.LoadMacros();

            var registerPriorityCommandTarget = (IVsRegisterPriorityCommandTarget) GetService(typeof(SVsRegisterPriorityCommandTarget));

            uint pdwCookie;
            ErrorHandler.ThrowOnFailure(registerPriorityCommandTarget.RegisterPriorityCommandTarget(0, new MacroCommandTarget(), out pdwCookie));
        }
コード例 #16
0
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <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() {
            ((IServiceContainer)this).AddService(typeof(NpgsqlProviderObjectFactory), new NpgsqlProviderObjectFactory(), true);
            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 item.
                {
                    CommandID menuCommandID = new CommandID(GuidList.guidNpgsqlDdexProviderCmdSetToolsMenu, (int)PkgCmdIDList.cmdidSetupNpgsql);
                    MenuCommand menuItem = new MenuCommand(MenuItemSetupNpgsqlDdexProvider, menuCommandID);
                    mcs.AddCommand(menuItem);
                }
                {
                    CommandID menuCommandID = new CommandID(GuidList.guidNpgsqlDdexProviderCmdSetToolsMenu, (int)PkgCmdIDList.cmdidUninstNpgsql);
                    MenuCommand menuItem = new MenuCommand(MenuItemUninstNpgsqlDdexProvider, menuCommandID);
                    mcs.AddCommand(menuItem);
                }
                {
                    CommandID menuCommandID = new CommandID(GuidList.guidNpgsqlDdexProviderCmdSetProjMenu, (int)PkgCmdIDList.cmdidCheckNpgsql);
                    MenuCommand menuItem = new MenuCommand(MenuItemCheckNpgsqlDdexProvider, menuCommandID);
                    mcs.AddCommand(menuItem);
                }
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

        }
コード例 #17
0
 public void SetupCommands()
 {
     CommandID commandId = new CommandID(GuidList.guidDiffCmdSet, (int)PkgCmdIDList.cmdDiff);
     OleMenuCommand menuCommand = new OleMenuCommand((s, e) => Sort(), commandId);
     menuCommand.BeforeQueryStatus += menuCommand_BeforeQueryStatus;
     _mcs.AddCommand(menuCommand);
 }
コード例 #18
0
        private CompilerOutputCmds(DevUtilsPackage package)
        {
            this.package = package;

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = serviceProvider.GetService(typeof (IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                // Create the command for the menu item.
                CommandID menuCommandID = new CommandID(guidDevUtilsCmdSet, cmdShowAssembly);
                var cmd = new OleMenuCommand((s, e) => showCppOutput(1), changeHandler, beforeQueryStatus, menuCommandID);
                cmd.Properties["lang"] = "C/C++";
                mcs.AddCommand(cmd);

                menuCommandID = new CommandID(guidDevUtilsCmdSet, cmdShowPreprocessed);
                cmd = new OleMenuCommand((s, e) => showCppOutput(2), changeHandler, beforeQueryStatus, menuCommandID);
                cmd.Properties["lang"] = "C/C++";
                mcs.AddCommand(cmd);

                menuCommandID = new CommandID(guidDevUtilsCmdSet, cmdShowDecompiledCSharp);
                cmd = new OleMenuCommand((s, e) => showDecompiledCSharp(), changeHandler, beforeQueryStatus, menuCommandID);
                cmd.Properties["lang"] = "CSharp";
                mcs.AddCommand(cmd);
            }
        }
コード例 #19
0
ファイル: SuctionPackage.cs プロジェクト: Mozketo/Suction
        /// <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();

            var core = Infrastructure.Core.Instance; // Init the core.

            // 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 item.
                CommandID menuCommandID = new CommandID(GuidList.guidSuctionCmdSet, (int)PkgCmdIDList.cmdidSuctionSolution);
                MenuCommand menuItem = new MenuCommand(MenuItemCallback_Solution, menuCommandID);
                mcs.AddCommand(menuItem);

                menuCommandID = new CommandID(GuidList.guidSuctionCmdProjectSet, (int)PkgCmdIDList.cmdidSuctionProject);
                menuItem = new MenuCommand(MenuItemCallback_Project, menuCommandID);
                mcs.AddCommand(menuItem);

                menuCommandID = new CommandID(GuidList.guidSuctionCmdItemSet, (int)PkgCmdIDList.cmdidSuctionItem);
                menuItem = new MenuCommand(MenuItemCallback_Item, menuCommandID);
                mcs.AddCommand(menuItem);
            }
        }
コード例 #20
0
ファイル: BaseCommand.cs プロジェクト: adontz/codemaid
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseCommand" /> class.
        /// </summary>
        /// <param name="package">The hosting package.</param>
        /// <param name="id">The id for the command.</param>
        protected BaseCommand(CodeMaidPackage package, CommandID id)
            : base(BaseCommand_Execute, id)
        {
            Package = package;

            BeforeQueryStatus += BaseCommand_BeforeQueryStatus;
        }
コード例 #21
0
ファイル: Diff.cs プロジェクト: GProulx/WebEssentials2013
 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);
 }
コード例 #22
0
 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);
 }
コード例 #23
0
ファイル: VsCommand.cs プロジェクト: bayulabster/viasfora
 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);
 }
コード例 #24
0
 public void SetupCommands()
 {
     CommandID cid = new CommandID(CommandGuids.guidEditorExtensionsCmdSet, (int)CommandId.AddGrunt);
     OleMenuCommand cmd = new OleMenuCommand((s, e) => Execute(), cid);
     cmd.BeforeQueryStatus += BeforeQueryStatus;
     _mcs.AddCommand(cmd);
 }
コード例 #25
0
 public static void Register(MenuCommandService mcs)
 {
     var cmdId = new CommandID(VSCommandTable.PackageGuids.VSPackageCmdSetGuid, VSCommandTable.CommandIds.CreateServiceCode);
     var menu = new OleMenuCommand(MenuItemCallbackHandler, cmdId);
     menu.BeforeQueryStatus += BeforeQueryStatus;
     mcs.AddCommand(menu);
 }
コード例 #26
0
        public override void ShowContextMenu(CommandID menuID, int x, int y)
        {
            ContextMenuStripCodon contextMenuStripCodon = null;

            if (menuID == MenuCommands.ComponentTrayMenu)
            {
            }
            else if (menuID == MenuCommands.ContainerMenu)
            {
                contextMenuStripCodon = new ContainerMenu(this);
            }
            else if (menuID == MenuCommands.SelectionMenu)
            {
                contextMenuStripCodon = new SelectionMenu(this);
            }
            else if (menuID == MenuCommands.TraySelectionMenu)
            {
            }
            else
            {
                throw new Exception("ShowContextMenu Error");
            }
            if (contextMenuStripCodon != null)
            {
                contextMenuStripCodon.View.Renderer = ToolStripRenders.Default;
                contextMenuStripCodon.View.Show(x, y);
            }
        }
コード例 #27
0
 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);
 }
コード例 #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpadeToolWindow" /> class.
        /// </summary>
        public SpadeToolWindow()
            : base(null)
        {
            // Set the tool window caption.
            Caption = "CodeMaid Spade";

            // Set the tool window image from resources.
            BitmapResourceID = 508;
            BitmapIndex = 0;

            // Create the toolbar for the tool window.
            ToolBar = new CommandID(GuidList.GuidCodeMaidToolbarSpadeBaseGroup, PkgCmdIDList.ToolbarIDCodeMaidToolbarSpade);

            // Setup the associated classes.
            _viewModel = new SpadeViewModel();

            // Register for view model requests to be refreshed.
            _viewModel.RequestingRefresh += (sender, args) => Refresh();

            // Create and set the view.
            base.Content = new SpadeView { DataContext = _viewModel };

            // Register for changes to settings.
            Settings.Default.SettingsSaving += (sender, args) => Refresh();
        }
コード例 #29
0
        protected override void Initialize()
        {
            base.Initialize();
            control = new PendingChangesView(this);

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
            // the object returned by the Content property.
            base.Content = control;

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

            var cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdPendingChangesCommit);
            var menu = new MenuCommand(new EventHandler(OnCommitCommand), cmd);
            mcs.AddCommand(menu);

            cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdPendingChangesAmend);
            menu = new MenuCommand(new EventHandler(OnAmendCommitCommand), cmd);
            mcs.AddCommand(menu);

            cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdPendingChangesRefresh);
            menu = new MenuCommand(new EventHandler(OnRefreshCommand), cmd);
            mcs.AddCommand(menu);

            sccProviderService = BasicSccProvider.GetServiceEx<SccProviderService>();
        }
コード例 #30
0
        /*
        private void InitializeGlobalCommands()
        {
            //Most commands like Delete, Cut, Copy and paste are all added to the MenuCommandService
            // by the other services like the DesignerHost.  Commands like ViewCode and ShowProperties
            // need to be added by the IDE because only the IDE would know how to perform those actions.
            // This allows people to call MenuCommandSerice.GlobalInvoke( StandardCommands.ViewCode );
            // from designers and what not.  .Net Control Designers like the TableLayoutPanelDesigner
            // build up their own context menus instead of letting the MenuCommandService build it.
            // The context menus they build up are in the format that Visual studio expects and invokes
            // the ViewCode and Properties commands by using GlobalInvoke.

        //			AbstractFormsDesignerCommand viewCodeCommand = new ViewCode();
        //			AbstractFormsDesignerCommand propertiesCodeCommand = new ShowProperties();
        //			this.AddCommand( new MenuCommand(viewCodeCommand.CommandCallBack, viewCodeCommand.CommandID));
        //			this.AddCommand( new MenuCommand(propertiesCodeCommand.CommandCallBack, propertiesCodeCommand.CommandID));
        }
        */
        public override void ShowContextMenu(CommandID menuID, int x, int y)
        {
            string contextMenuPath = "/SharpDevelop/ReportDesigner/ContextMenus/";
            var selectionService = (ISelectionService)base.GetService(typeof(ISelectionService));

            if (selectionService != null) {
                if (menuID == MenuCommands.TraySelectionMenu) {
                    contextMenuPath += "TraySelectionMenu";
                }
                else if (selectionService.PrimarySelection is RootReportModel) {
                    System.Console.WriteLine("found Root");
                    contextMenuPath += "ContainerMenu";
                }
                else if (selectionService.PrimarySelection is BaseSection) {
                    System.Console.WriteLine("found baseSection");
                    contextMenuPath += "ContainerMenu";
                }
                else {
                    contextMenuPath += "SelectionMenu";
                }

                Point p = panel.PointToClient(new Point(x, y));
                MenuService.ShowContextMenu(this, contextMenuPath, panel, p.X, p.Y);
            }
        }
コード例 #31
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            CommandID cd = new CommandID(pguidCmdGroup, unchecked((int)nCmdID));

            List<CommandData> items;

            if (!_data.TryGetValue(cd, out items))
                return (int)Constants.OLECMDERR_E_NOTSUPPORTED;

            foreach (CommandData d in items)
            {
                if (!d.Control.ContainsFocus)
                    continue;

                CommandEventArgs ce = new CommandEventArgs((VisualGitCommand)cd.ID, GetService<VisualGitContext>());
                if (d.UpdateHandler != null)
                {
                    CommandUpdateEventArgs ud = new CommandUpdateEventArgs(ce.Command, ce.Context);

                    d.UpdateHandler(d.Control, ud);

                    if (!ud.Enabled)
                        return (int)Constants.OLECMDERR_E_DISABLED;
                }

                d.Handler(d.Control, ce);

                return VSConstants.S_OK;
            }

            return (int)Constants.OLECMDERR_E_NOTSUPPORTED;
        }
コード例 #32
0
 public static void Register(MenuCommandService mcs)
 {
     CommandID nestId = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdNest);
     OleMenuCommand menuNest = new OleMenuCommand(Nest, nestId);
     mcs.AddCommand(menuNest);
     menuNest.BeforeQueryStatus += BeforeNest;
 }
コード例 #33
0
        /// <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();

            Dte = Package.GetGlobalService(typeof(EnvDTE.DTE)) as DTE2;

            // Add our command handlers for menu (commands must exist in the .vsct file)
            _attachToIIS = new AttachToIIS(Dte);
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if ( null != mcs )
            {
                // Create the command for the menu item.
                CommandID menuCommandID = new CommandID(GuidList.guidAlkampferVsix2010CmdSet, (int)PkgCmdIDList.cmdidAttachToIIS);
                MenuCommand menuItem = new MenuCommand(_attachToIIS.MenuItemCallback, menuCommandID);
                mcs.AddCommand( menuItem );
            }

            //Stop at first error command.
            _stopBuildAtFirstErrorCommand = new StopBuildAtFirstError(Dte);
            mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                // Create the command for the menu item.
                CommandID menuCommandID = new CommandID(GuidList.guidAlkampferVsix2010CmdSet, (int)PkgCmdIDList.stopBuildAtFirstError);
                MenuCommand menuItem = new MenuCommand(_stopBuildAtFirstErrorCommand.MenuItemCallback, menuCommandID);
                _stopBuildAtFirstErrorCommand.ManageMenuItem(menuItem);
                mcs.AddCommand(menuItem);
            }
        }
コード例 #34
0
        public override void ShowContextMenu(CommandID menuID, int x, int y)
        {
            //ISelectionService

            if (menuID == MenuCommands.SelectionMenu || menuID == MenuCommands.ContainerMenu)
            {
                ContextMenuStrip    contextMenu = new ContextMenuStrip();
                ToolStripMenuItem[] menuItems   = GetSelectionMenuItems();

                if (menuItems.Length > 0)
                {
                    contextMenu.Items.Add(new ToolStripSeparator());
                    foreach (ToolStripMenuItem item in menuItems)
                    {
                        if (item.Text == "Add Tab")
                        {
                            contextMenu.Items.Add(new ToolStripSeparator());
                        }

                        contextMenu.Items.Add(item);
                    }
                }

                contextMenu.Show(panel, panel.PointToClient(new Point(x, y)));
            }
            else
            {
                throw new Exception();
            }
            //Point p = panel.PointToClient(new Point(x, y));


            //MenuService.ShowContextMenu(this, contextMenuPath, panel, p.X, p.Y);
            //ISelectionService selectionService = (ISelectionService)(this.GetService(typeof(ISelectionService)));
            //ICollection selectedComponents = selectionService.GetSelectedComponents();
            //PropertyGrid propertyGrid = (PropertyGrid)this.GetService(typeof(PropertyGrid));

            //if (selectedComponents.Count != 1)
            //    return;

            //Editor ed = new Editor();
            //if (ed.ShowDialog() == DialogResult.OK)
            //{
            //    object[] comps = new object[selectedComponents.Count];
            //    int i = 0;

            //    foreach (Object o in selectedComponents)
            //    {
            //        comps[i] = o;
            //        i++;
            //    }
            //    if (comps[0].GetType() == typeof(System.Windows.Forms.Button))
            //    {
            //        Button btn = comps[0] as Button;
            //        btn.Text = ed.Name;
            //        propertyGrid.SelectedObject = btn;
            //    }
            //}
        }
コード例 #35
0
        public bool PostExecCommand(System.ComponentModel.Design.CommandID command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            return(PostExecCommand(command, null));
        }
コード例 #36
0
 /// <summary>
 /// Shows the specified shortcut menu at the specified location.
 /// </summary>
 /// <remarks>
 /// Calling this method invokes the <see cref="OnShowContextMenu"/> event.
 /// </remarks>
 /// <seealso cref="System.ComponentModel.Design.CommandID"/>
 /// <param name="menuID">The System.ComponentModel.Design.CommandID for the shortcut menu to show.</param>
 /// <param name="x">The x-coordinate at which to display the menu, in screen coordinates.</param>
 /// <param name="y">The y-coordinate at which to display the menu, in screen coordinates.</param>
 public void ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y)
 {
     if (OnShowContextMenu != null)
     {
         System.Web.UI.Control element = null;
         element = this.editor.GenericElementFactory.CreateElement(GetPrimaryElement());
         OnShowContextMenu(this, new ShowContextMenuEventArgs(new System.Drawing.Point(x, y), false, 0, element));
     }
 }
コード例 #37
0
        /// This is called whenever the user right-clicks on a designer. It removes any local verbs
        /// added by a previous, different selection and adds the local verbs for the current (primary)
        /// selection. Then it displays the ContextMenu.
        public void ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y)
        {
            ISelectionService ss = host.GetService(typeof(ISelectionService)) as ISelectionService;

            // If this is the same component as was last right-clicked on, then we don't need to
            // make any changes to our collection of local verbs.
            //
            if ((lastSelection != null) && (lastSelection != ss.PrimarySelection))
            {
                IDesigner d = host.GetDesigner(lastSelection);
                if (d != null)
                {
                    foreach (DesignerVerb verb in d.Verbs)
                    {
                        RemoveLocalVerb(verb);
                    }
                }
            }

            // Update the local verbs for the new selection, if it is indeed new.
            if (lastSelection != ss.PrimarySelection)
            {
                IDesigner d = host.GetDesigner(ss.PrimarySelection as IComponent);
                if (d.Verbs.Count == 0)
                {
                    FillVerbs(ss.PrimarySelection as IComponent, d);
                }
                foreach (DesignerVerb verb in d.Verbs)
                {
                    AddLocalVerb(verb);
                }
            }

            // Display our ContextMenu! Note that the coordinate parameters to this method
            // are in screen coordinates, so we've got to translate them into client coordinates.
            //
            //if (cm != null)
            {
                Control ps = ss.PrimarySelection as Control;
                if (ps == null)
                {
                    ps = VisualPascalABC.Form1.Form1_object;
                }
                Point s = ps.PointToScreen(new Point(0, 0));
                VisualPascalABC.Form1.Form1_object.cm_Designer.Show(ps, new Point(x - s.X, y - s.Y));
                //VisualPascalABC.Form1.Form1_object.cm_Designer.Show(ps, Cursor.Position);
            }

            // ss.PrimarySelection might be old news by the next right-click. We need to
            // be able to remove its verbs if we get a different selection next time
            // this method is called. We can't remove them right now because we aren't sure
            // if the MenuItem click events have finished yet (and removing verbs kills
            // their MenuItem mapping). So we save the selection and do it next time if necessary.
            //
            lastSelection = ss.PrimarySelection as IComponent;
        }
コード例 #38
0
ファイル: ProjectBrowserService.cs プロジェクト: mmyydd/reko
        public bool Execute(System.ComponentModel.Design.CommandID cmdId)
        {
            var des = GetSelectedDesigner();

            if (des == null)
            {
                return(false);
            }
            return(des.Execute(cmdId));
        }
コード例 #39
0
        /// We only invoke commands that have been added.
        public override bool GlobalInvoke(System.ComponentModel.Design.CommandID commandID)
        {
            MenuCommand command = FindCommand(commandID);

            if (command != null)
            {
                command.Invoke();
                return(true);
            }
            return(false);
        }
コード例 #40
0
 /// <summary>
 /// Searches for the specified command ID and returns the menu command associated
 /// with it.
 /// </summary>
 /// <param name="commandID">The System.ComponentModel.Design.CommandID to search for.</param>
 /// <returns>The System.ComponentModel.Design.MenuCommand associated with the command
 /// ID, or <c>null</c> if no command is found.</returns>
 public System.ComponentModel.Design.MenuCommand FindCommand(System.ComponentModel.Design.CommandID commandID)
 {
     foreach (MenuCommand command in commands)
     {
         if (command.CommandID == commandID)
         {
             return(command);
         }
     }
     return(null);
 }
コード例 #41
0
        public bool PostExecCommand(System.ComponentModel.Design.CommandID command)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

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

            return(PostExecCommand(command, null));
        }
コード例 #42
0
 /// <summary>
 /// Invokes a menu or designer verb command matching the specified command ID.
 /// </summary>
 /// <remarks>
 /// This is widely used by plug-ins to add commands to the base control.
 /// </remarks>
 /// <seealso cref="System.ComponentModel.Design.CommandID"/>
 /// <param name="commandID">The System.ComponentModel.Design.CommandID of the command to search for and execute.</param>
 /// <returns><c>True</c> if the command was found and invoked successfully; otherwise, <c>false</c>.</returns>
 public bool GlobalInvoke(System.ComponentModel.Design.CommandID commandID)
 {
     foreach (MenuCommand command in commands)
     {
         if (command.CommandID.Equals(commandID))
         {
             command.Invoke();
             return(true);
         }
     }
     return(false);
 }
コード例 #43
0
        /// called to invoke a command
        public bool GlobalInvoke(System.ComponentModel.Design.CommandID commandID)
        {
            bool        result  = false;
            MenuCommand command = FindCommand(commandID);

            if (command != null)
            {
                command.Invoke();
                result = true;
            }
            return(result);
        }
コード例 #44
0
 /// Find a command based on its CommandID.
 public System.ComponentModel.Design.MenuCommand FindCommand(System.ComponentModel.Design.CommandID commandID)
 {
     if (commands != null)
     {
         MenuCommand command = commands[commandID] as MenuCommand;
         if (command != null)
         {
             return(command);
         }
     }
     return(null);
 }
コード例 #45
0
        public bool GlobalInvoke(System.ComponentModel.Design.CommandID commandID)
        {
            foreach (MenuCommand command in menuCommands)
            {
                if (command.CommandID == commandID)
                {
                    command.Invoke();
                    break;
                }
            }

            return(false);
        }
コード例 #46
0
        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);
        }
コード例 #47
0
ファイル: ProjectBrowserService.cs プロジェクト: xor2003/reko
        public bool Execute(System.ComponentModel.Design.CommandID cmdId)
        {
            var des = GetSelectedDesigner();

            if (des != null)
            {
                if (des.Execute(cmdId))
                {
                    return(true);
                }
            }
            if (cmdId.Guid == CmdSets.GuidReko)
            {
                switch (cmdId.ID)
                {
                case CmdIds.CollapseAllNodes: tree.CollapseAll(); break;
                }
            }
            return(false);
        }
コード例 #48
0
ファイル: MenuCommandService.cs プロジェクト: iamwsx05/hms
        /// <summary>
        /// 弹出右键菜单
        /// </summary>
        /// <param name="menuID"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public override void ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y)
        {
            ISelectionService selection = GetService(typeof(ISelectionService)) as ISelectionService;
            IDesignerHost     idh       = GetService(typeof(IDesignerHost)) as IDesignerHost;

            //if (selection.PrimarySelection != idh.RootComponent)
            //{
            ContextMenuStrip cm = new ContextMenuStrip();

            cm.Items.AddRange(BuildMenuItems());
            ISelectionService ss = GetService(typeof(ISelectionService)) as ISelectionService;

            Control ps = ss.PrimarySelection as Control;

            if (ps != null)
            {
                Point s = ps.PointToScreen(new Point(0, 0));
                cm.Show(ps, new Point(x - s.X, y - s.Y));
            }
            //}
        }
コード例 #49
0
        /// called to show the context menu for the selected component.
        public void ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y)
        {
            ISelectionService selectionService = host.GetService(typeof(ISelectionService)) as ISelectionService;
            // get the primary component
            IComponent primarySelection = selectionService.PrimarySelection as IComponent;

            // if the he clicked on the same component again then just show the context
            // menu. otherwise, we have to throw away the previous
            // set of local menu items and create new ones for the newly
            // selected component
            if (lastSelectedComponent != primarySelection)
            {
                // remove all non-global menu items from the context menu
                ResetContextMenu();
                // get the designer
                IDesigner designer = host.GetDesigner(primarySelection);
                // not all controls need a desinger
                if (designer != null)
                {
                    // get designer's verbs
                    DesignerVerbCollection verbs = designer.Verbs;
                    foreach (DesignerVerb verb in verbs)
                    {
                        // add new menu items to the context menu
                        CreateAndAddLocalVerb(verb);
                    }
                }
            }
            // we only show designer context menus for controls
            if (primarySelection is Control)
            {
                Control comp = primarySelection as Control;
                Point   pt   = comp.PointToScreen(new Point(0, 0));
                contextMenu.Show(comp, new Point(x - pt.X, y - pt.Y));
            }
            // keep the selected component for next time
            lastSelectedComponent = primarySelection;
        }
コード例 #50
0
 /// <summary>
 ///  Searches for the given command ID and returns the MenuCommand
 ///  associated with it.
 /// </summary>
 public MenuCommand FindCommand(CommandID commandID)
 {
     return(FindCommand(commandID.Guid, commandID.ID));
 }
コード例 #51
0
        static StandardCommands()
        {
            Guid menuGroup  = new Guid("5efc7975-14bc-11cf-9b2b-00aa00573819");
            Guid menuGroup2 = new Guid("74d21313-2aee-11d1-8bfb-00a0c90f26f7");

            StandardCommands.AlignBottom            = new CommandID(menuGroup, 1);
            StandardCommands.AlignHorizontalCenters = new CommandID(menuGroup, 2);
            StandardCommands.AlignLeft            = new CommandID(menuGroup, 3);
            StandardCommands.AlignRight           = new CommandID(menuGroup, 4);
            StandardCommands.AlignToGrid          = new CommandID(menuGroup, 5);
            StandardCommands.AlignTop             = new CommandID(menuGroup, 6);
            StandardCommands.AlignVerticalCenters = new CommandID(menuGroup, 7);
            StandardCommands.ArrangeBottom        = new CommandID(menuGroup, 8);
            StandardCommands.ArrangeIcons         = new CommandID(menuGroup2, 12298);
            StandardCommands.ArrangeRight         = new CommandID(menuGroup, 9);
            StandardCommands.BringForward         = new CommandID(menuGroup, 10);
            StandardCommands.BringToFront         = new CommandID(menuGroup, 11);
            StandardCommands.CenterHorizontally   = new CommandID(menuGroup, 12);
            StandardCommands.CenterVertically     = new CommandID(menuGroup, 13);
            StandardCommands.Copy   = new CommandID(menuGroup, 15);
            StandardCommands.Cut    = new CommandID(menuGroup, 16);
            StandardCommands.Delete = new CommandID(menuGroup, 17);
            StandardCommands.F1Help = new CommandID(menuGroup, 377);
            StandardCommands.Group  = new CommandID(menuGroup, 20);
            StandardCommands.HorizSpaceConcatenate = new CommandID(menuGroup, 21);
            StandardCommands.HorizSpaceDecrease    = new CommandID(menuGroup, 22);
            StandardCommands.HorizSpaceIncrease    = new CommandID(menuGroup, 23);
            StandardCommands.HorizSpaceMakeEqual   = new CommandID(menuGroup, 24);
            StandardCommands.LineupIcons           = new CommandID(menuGroup2, 12299);
            StandardCommands.LockControls          = new CommandID(menuGroup, 369);
            StandardCommands.MultiLevelRedo        = new CommandID(menuGroup, 30);
            StandardCommands.MultiLevelUndo        = new CommandID(menuGroup, 44);
            StandardCommands.Paste                = new CommandID(menuGroup, 26);
            StandardCommands.Properties           = new CommandID(menuGroup, 28);
            StandardCommands.PropertiesWindow     = new CommandID(menuGroup, 235);
            StandardCommands.Redo                 = new CommandID(menuGroup, 29);
            StandardCommands.Replace              = new CommandID(menuGroup, 230);
            StandardCommands.SelectAll            = new CommandID(menuGroup, 31);
            StandardCommands.SendBackward         = new CommandID(menuGroup, 32);
            StandardCommands.SendToBack           = new CommandID(menuGroup, 33);
            StandardCommands.ShowGrid             = new CommandID(menuGroup, 103);
            StandardCommands.ShowLargeIcons       = new CommandID(menuGroup2, 12300);
            StandardCommands.SizeToControl        = new CommandID(menuGroup, 35);
            StandardCommands.SizeToControlHeight  = new CommandID(menuGroup, 36);
            StandardCommands.SizeToControlWidth   = new CommandID(menuGroup, 37);
            StandardCommands.SizeToFit            = new CommandID(menuGroup, 38);
            StandardCommands.SizeToGrid           = new CommandID(menuGroup, 39);
            StandardCommands.SnapToGrid           = new CommandID(menuGroup, 40);
            StandardCommands.TabOrder             = new CommandID(menuGroup, 41);
            StandardCommands.Undo                 = new CommandID(menuGroup, 43);
            StandardCommands.Ungroup              = new CommandID(menuGroup, 45);
            StandardCommands.VerbFirst            = new CommandID(menuGroup2, 8192);
            StandardCommands.VerbLast             = new CommandID(menuGroup2, 8448);
            StandardCommands.VertSpaceConcatenate = new CommandID(menuGroup, 46);
            StandardCommands.VertSpaceDecrease    = new CommandID(menuGroup, 47);
            StandardCommands.VertSpaceIncrease    = new CommandID(menuGroup, 48);
            StandardCommands.VertSpaceMakeEqual   = new CommandID(menuGroup, 49);
            StandardCommands.ViewGrid             = new CommandID(menuGroup, 125);
            StandardCommands.DocumentOutline      = new CommandID(menuGroup, 239);
            StandardCommands.ViewCode             = new CommandID(menuGroup, 333);
        }
コード例 #52
0
 public DesignerVerb(string text, EventHandler handler, CommandID startCommandID) : base(handler, startCommandID)
 {
     this.Properties["Text"] = (text == null) ? null : Regex.Replace(text, @"\(\&.\)", "");
 }
コード例 #53
0
ファイル: DesignerVerb.cs プロジェクト: raj581/Marvin
 public DesignerVerb(string text, EventHandler handler, CommandID startCommandID)
     : base(handler, startCommandID)
 {
     this.text = text;
 }
コード例 #54
0
 public bool PostExecCommand(System.ComponentModel.Design.CommandID command, object args)
 {
     return(PostExecCommand(command, args, CommandPrompt.DoDefault));
 }
コード例 #55
0
 public CommandResult ExecCommand(System.ComponentModel.Design.CommandID command)
 {
     return(ExecCommand(command, true));
 }
コード例 #56
0
 public CommandResult ExecCommand(System.ComponentModel.Design.CommandID command, bool verifyEnabled)
 {
     return(ExecCommand(command, verifyEnabled, null));
 }
コード例 #57
0
        public CommandResult ExecCommand(System.ComponentModel.Design.CommandID command, bool verifyEnabled, object argument)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            // TODO: Assert that we are in the UI thread

            IOleCommandTarget dispatcher = CommandDispatcher;

            if (dispatcher == null)
            {
                return(new CommandResult(false));
            }

            Guid g = command.Guid;

            if (verifyEnabled)
            {
                OLECMD[] cmd = new OLECMD[1];
                cmd[0].cmdID = unchecked ((uint)command.ID);

                if (VSErr.S_OK != dispatcher.QueryStatus(ref g, 1, cmd, IntPtr.Zero))
                {
                    return(new CommandResult(false));
                }

                OLECMDF flags = (OLECMDF)cmd[0].cmdf;

                if ((flags & OLECMDF.OLECMDF_SUPPORTED) == (OLECMDF)0)
                {
                    return(new CommandResult(false)); // Not supported
                }
                if ((flags & OLECMDF.OLECMDF_ENABLED) == (OLECMDF)0)
                {
                    return(new CommandResult(false)); // Not enabled
                }
            }

            IntPtr vIn  = IntPtr.Zero;
            IntPtr vOut = IntPtr.Zero;

            try
            {
                vOut = Marshal.AllocCoTaskMem(128);
                NativeMethods.VariantInit(vOut);

                if (argument != null)
                {
                    vIn = Marshal.AllocCoTaskMem(128);
                    Marshal.GetNativeVariantForObject(argument, vIn);
                }

                bool ok = VSErr.Succeeded(dispatcher.Exec(ref g,
                                                          unchecked ((uint)command.ID), (uint)OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, IntPtr.Zero, IntPtr.Zero));

                return(new CommandResult(ok, Marshal.GetObjectForNativeVariant(vOut)));
            }
            finally
            {
                if (vIn != IntPtr.Zero)
                {
                    NativeMethods.VariantClear(vIn);
                    Marshal.FreeCoTaskMem(vIn);
                }
                if (vOut != IntPtr.Zero)
                {
                    NativeMethods.VariantClear(vOut);
                    Marshal.FreeCoTaskMem(vOut);
                }
            }
        }
コード例 #58
0
        private const int SUPPORTED = 0x01; // tagOLECMDF.OLECMDF_SUPPORTED

        /// <summary>
        /// Initializes a new instance of <see cref='System.ComponentModel.Design.MenuCommand'/>.
        /// </summary>
        public MenuCommand(EventHandler handler, CommandID command)
        {
            _execHandler = handler;
            CommandID    = command;
            _status      = SUPPORTED | ENABLED;
        }
コード例 #59
0
        /// <summary>
        ///  Locates the requested command. This will throw an appropriate
        ///  ComFailException if the command couldn't be found.
        /// </summary>
        protected MenuCommand FindCommand(Guid guid, int id)
        {
            Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "MCS Searching for command: " + guid.ToString() + " : " + id.ToString(CultureInfo.CurrentCulture));

            // Search in the list of commands only if the command group is known
            ArrayList commands;

            lock (_commandGroupsLock)
            {
                _commandGroups.TryGetValue(guid, out commands);
            }

            if (commands != null)
            {
                Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "\t...MCS Found group");
                foreach (MenuCommand command in commands)
                {
                    if (command.CommandID.ID == id)
                    {
                        Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "\t... MCS Found Command");
                        return(command);
                    }
                }
            }

            // Next, search the verb list as well.
            //
            EnsureVerbs();
            if (_currentVerbs != null)
            {
                int currentID = StandardCommands.VerbFirst.ID;
                foreach (DesignerVerb verb in _currentVerbs)
                {
                    CommandID cid = verb.CommandID;

                    if (cid.ID == id)
                    {
                        Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "\t...MCS Found verb");

                        if (cid.Guid.Equals(guid))
                        {
                            Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "\t...MCS Found group");
                            return(verb);
                        }
                    }

                    // We assign virtual sequential IDs to verbs we get from the component. This allows users
                    // to not worry about assigning these IDs themselves.
                    //
                    if (currentID == id)
                    {
                        Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "\t...MCS Found verb");

                        if (cid.Guid.Equals(guid))
                        {
                            Debug.WriteLineIf(MENUSERVICE.TraceVerbose, "\t...MCS Found group");
                            return(verb);
                        }
                    }

                    if (cid.Equals(StandardCommands.VerbFirst))
                    {
                        currentID++;
                    }
                }
            }

            return(null);
        }
コード例 #60
0
 /// <summary>
 ///  Shows the context menu with the given command ID at the given
 ///  location.
 /// </summary>
 public virtual void ShowContextMenu(CommandID menuID, int x, int y)
 {
 }