Ejemplo n.º 1
0
 /// <summary>
 /// Virtual method for processing the Delete menu status handler.
 /// </summary>
 /// <param name="command">Menu command called from the Visual Studio</param>
 protected override void ProcessOnStatusDeleteCommand(MenuCommand command)
 {
     if (command != null)
     {
         command.Visible = command.Enabled = CanDelete();
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PoorMansTSqlFormatterCommand"/> 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 PoorMansTSqlFormatterCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                _applicationObject = Package.GetGlobalService(typeof(DTE)) as DTE;
                _formattingManager = PoorMansTSqlFormatterPluginShared.Utils.GetFormattingManager(Properties.Settings.Default);
                //Command cmd = _applicationObject.Commands.Item("Tools.FormatTSQLCode", -1);
                //cmd.Bindings = "Text Editor::Ctrl+Shift+D";

                var menuFormatCommandID = new CommandID(CommandSet, FormatCommandId);
                var menuFormatItem = new MenuCommand(this.MenuFormatCallback, menuFormatCommandID);
                commandService.AddCommand(menuFormatItem);

                var menuOptionsCommandID = new CommandID(CommandSet, OptionsCommandId);
                var menuOptionsItem = new MenuCommand(this.MenuOptionsCallback, menuOptionsCommandID);
                commandService.AddCommand(menuOptionsItem);

                _formatCommand = _applicationObject.Commands.Item("Tools.FormatTSQLCode", -1);
                SetFormatHotkey();

            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BuildStartProject"/> 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 BuildStartProject(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            // Add a menu item.
            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);
            }

            // Register as an advisory interface.
            var solutionService = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            if (solutionService != null)
            {
                solutionService.AdviseSolutionEvents(this, out m_EventSinkCookie);
            }
        }
        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);
            }

        }
        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>();
        }
Ejemplo n.º 6
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();

            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);
            }
        }
 protected override void ProcessOnStatusPasteCommand(System.ComponentModel.Design.MenuCommand cmd)
 {
     if (this.CurrentModelingDocView != null && this.CurrentDocData != null)
     {
         base.ProcessOnStatusPasteCommand(cmd);
     }
 }
        /// <summary>
        /// Called when the package is loaded, performs package initialization tasks such as registering the source control provider
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Proffer the source control service implemented by the provider
            sccService = new SccProviderService(this);
            ((IServiceContainer)this).AddService(typeof(SccProviderService), sccService, true);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            MsVsShell.OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as MsVsShell.OleMenuCommandService;
            if (mcs != null)
            {
                CommandID cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommand);
                MenuCommand menuCmd = new MenuCommand(new EventHandler(OnSccCommand), cmd);
                mcs.AddCommand(menuCmd);

                // ToolWindow Command
                cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdViewToolWindow);
                menuCmd = new MenuCommand(new EventHandler(ViewToolWindow), cmd);
                mcs.AddCommand(menuCmd);

                // ToolWindow's ToolBar Command
                cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdToolWindowToolbarCommand);
                menuCmd = new MenuCommand(new EventHandler(ToolWindowToolbarCommand), cmd);
                mcs.AddCommand(menuCmd);
            }

            // Register the provider with the source control manager
            // If the package is to become active, this will also callback on OnActiveStateChange and the menu commands will be enabled
            IVsRegisterScciProvider rscp = (IVsRegisterScciProvider)GetService(typeof(IVsRegisterScciProvider));
            rscp.RegisterSourceControlProvider(GuidList.guidSccProvider);
        }
        /// <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);
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // Overriden 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 initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {            
            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 menuCommandRunCoffeeScript = new CommandID(
                    GuidList.guidCoffeeScriptRunnerVSPackageCmdSet,
                    (int)PkgCmdIDList.cmdIdRunCoffeeScript
                );
                MenuCommand menuItem = new MenuCommand(
                    MenuItemCallback,
                    menuCommandRunCoffeeScript 
                );
                mcs.AddCommand( menuItem );

                CommandID menuCommandRunJavaScript = new CommandID(
                    GuidList.guidCoffeeScriptRunnerVSPackageCmdSet,
                    (int)PkgCmdIDList.cmdIdRunJavaScript
                );
                MenuCommand menuItem2 = new MenuCommand(
                    MenuItemCallback, 
                    menuCommandRunJavaScript 
                );
                mcs.AddCommand( menuItem2 );
            }
            base.dte = (EnvDTE80.DTE2)GetService(typeof(EnvDTE.DTE));
        }
Ejemplo n.º 11
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);
                }
            }
        }
Ejemplo n.º 12
0
        /// <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);
            }
        }
        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);
        }
        /// <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()
        {
            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 tool window
                CommandID toolwndCommandID = new CommandID(GuidList.guidDynamicStartItemExamplePackageCmdSet, PkgCmdIDList.cmdidShowDynamicItemCountEntryWindow);
                MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand( menuToolWin );

                //Add a 'dummy' entry for our menu, this entry has a null EventHandler as it will never be 'executed'
                //(you can't 'execute' a menu), and it doesn't set any properties as the default value of Visible is
                //true and we only want this handler in place so that the command system will find it once our package
                //is loaded and thus cause our main menu item to become visible.
                CommandID menuID = new CommandID(GuidList.guidDynamicStartItemExamplePackageCmdSet, PkgCmdIDList.mnuidMyMenu);
                MenuCommand menu = new MenuCommand(null, menuID);
                mcs.AddCommand(menu);

                //Add the DynamicItemMenuCommand that will be responsible for the expansion of our root item into N items
                //at runtime. Where N is the value the user has entered into our tool window.
                CommandID dynamicItemRootId = new CommandID(GuidList.guidDynamicStartItemExamplePackageCmdSet, PkgCmdIDList.cmdidMyDynamicStartItem);
                DynamicItemMenuCommand dynamicMenuCommand = new DynamicItemMenuCommand(dynamicItemRootId,
                                                                                       IsValidDynamicItem,
                                                                                       OnInvokedDynamicItem,
                                                                                       OnBeforeQueryStatusDynamicItem);

                mcs.AddCommand(dynamicMenuCommand);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LocatorWindowCommand"/> 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 LocatorWindowCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem = new MenuCommand(this.ShowToolWindow, menuCommandID);
                commandService.AddCommand(menuItem);
            }

            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            _locatorWindow = package.FindToolWindow(typeof(LocatorWindow), 0, true) as LocatorWindow;
            if ((null == _locatorWindow) || (null == _locatorWindow.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            _locator = new Locator();
            _solution = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            _solution.AdviseSolutionEvents(_locator, out _cookie);
            _locatorWindow.SetLocator(_locator);
            _locator.StartWorkerThread();
        }
Ejemplo n.º 16
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 initialization code that rely on services provided by VisualStudio.
        /// </summary>
        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 References context menu.
                CommandID menuCommandID = new CommandID(GuidList.guidILSpyAddInCmdSet, (int)PkgCmdIDList.cmdidOpenReferenceInILSpy);
                MenuCommand menuItem = new MenuCommand(OpenReferenceInILSpyCallback, menuCommandID);
                mcs.AddCommand(menuItem);

                // Create the command for the Project context menu, to open the output assembly.
                CommandID menuCommandID2 = new CommandID(GuidList.guidILSpyAddInCmdSet, (int)PkgCmdIDList.cmdidOpenProjectOutputInILSpy);
                MenuCommand menuItem2 = new MenuCommand(OpenProjectOutputInILSpyCallback, menuCommandID2);
                mcs.AddCommand(menuItem2);

                // Create the command for the code window context menu.
                CommandID menuCommandID3 = new CommandID(GuidList.guidILSpyAddInCmdSet, (int)PkgCmdIDList.cmdidOpenCodeItemInILSpy);
                OleMenuCommand menuItem3 = new OleMenuCommand(OpenCodeItemInILSpyCallback, menuCommandID3);
                menuItem3.BeforeQueryStatus += OpenCodeItemInILSpyCallback_BeforeQueryStatus;
                mcs.AddCommand(menuItem3);

                // Create the command for the Tools menu item.
                CommandID menuCommandID4 = new CommandID(GuidList.guidILSpyAddInCmdSet, (int)PkgCmdIDList.cmdidOpenILSpy);
                MenuCommand menuItem4 = new MenuCommand(OpenILSpyCallback, menuCommandID4);
                mcs.AddCommand(menuItem4);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// This method is called by the base class during SetSite. At this point the service provider
        /// for the package is set and all the services are available.
        /// </summary>
        protected override void Initialize()
        {
            // Call the base implementation to finish the initialization of the package.
            base.Initialize();

            // Get the OleMenuCommandService object to add the MenuCommand that will handle the command
            // defined by this package.
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null == mcs)
            {
                // If for some reason we can not get the OleMenuCommandService, then we can not add the handler
                // for the command, so we can exit now.
                Debug.WriteLine("Can not get the OleMenuCommandService from the base class.");
                return;
            }

            // Define the command and add it to the command service.
            CommandID id = new CommandID(GuidsList.guidClientCmdSet, ClientPkgCmdIDList.cmdidClientGetGlobalService);
            MenuCommand command = new MenuCommand(new EventHandler(GetGlobalServiceCallback), id);
            mcs.AddCommand(command);

            // Add the command that will try to get the local server and that is expected to fail.
            id = new CommandID(GuidsList.guidClientCmdSet, ClientPkgCmdIDList.cmdidClientGetLocalService);
            command = new MenuCommand(new EventHandler(GetLocalServiceCallback), id);
            mcs.AddCommand(command);

            // Add the command that will call the local service using the global one.
            id = new CommandID(GuidsList.guidClientCmdSet, ClientPkgCmdIDList.cmdidClientGetLocalUsingGlobal);
            command = new MenuCommand(new EventHandler(GetLocalUsingGlobalCallback), id);
            mcs.AddCommand(command);
        }
        /// <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()
        {
            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.guidZipNShareCmdSet, (int)PkgCmdIDList.cmdidZipNShareOptions);
                MenuCommand menuItem = new MenuCommand(OptionsMenuItemCallback, menuCommandID);

                CommandID menuCommandRunID = new CommandID(menuItem.CommandID.Guid, (int)PkgCmdIDList.cmdidZipNShareRun);
                MenuCommand menuItemRun = new MenuCommand(RunMenuItemCallback, menuCommandRunID);

                mcs.AddCommand(menuItemRun);
                mcs.AddCommand(menuItem);

                // Create the command for the tool window
                CommandID toolwndCommandID = new CommandID(GuidList.guidZipNShareCmdSet, (int)PkgCmdIDList.cmdidZipAndShareToolWindow);
                MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }
        }
Ejemplo n.º 19
0
 private void CreateToolWindows(OleMenuCommandService mcs)
 {
     WindowLauncher launcher = new WindowLauncher(this);
     CommandID toolwndCommandID = new CommandID(GuidList.guidLonestarCmdSet, (int)PkgCmdIDList.resultsWindow);
     MenuCommand menuToolWin = new MenuCommand(launcher.ShowToolWindow, toolwndCommandID);
     mcs.AddCommand( menuToolWin );
 }
Ejemplo n.º 20
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 initialization code that rely on services provided by VisualStudio.
        /// </summary>
        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)
            {
                CommandID waqsServerCommandID = new CommandID(GuidList.guidWAQSProjectCmdSet, (int)PkgCmdIDList.WAQSServerId);
                MenuCommand waqsServerItem = new MenuCommand(WAQSServerCallback, waqsServerCommandID);
                mcs.AddCommand(waqsServerItem);

                CommandID waqsServerMockCommandID = new CommandID(GuidList.guidWAQSProjectCmdSet, (int)PkgCmdIDList.WAQSServerMockId);
                MenuCommand waqsServerMockItem = new MenuCommand(WAQSServerMockCallback, waqsServerMockCommandID);
                mcs.AddCommand(waqsServerMockItem);

                CommandID waqsClientWPFCommandID = new CommandID(GuidList.guidWAQSProjectCmdSet, (int)PkgCmdIDList.WAQSClientWPFId);
                MenuCommand waqsClientWPFItem = new MenuCommand(WAQSClientWPFCallback, waqsClientWPFCommandID);
                mcs.AddCommand(waqsClientWPFItem);

                CommandID waqsClientPCLCommandID = new CommandID(GuidList.guidWAQSProjectCmdSet, (int)PkgCmdIDList.WAQSClientPCLId);
                MenuCommand waqsClientPCLItem = new MenuCommand(WAQSClientPCLCallback, waqsClientPCLCommandID);
                mcs.AddCommand(waqsClientPCLItem);

                CommandID waqsUpdateGeneratedCodeCommandID = new CommandID(GuidList.guidWAQSProjectCmdSet, (int)PkgCmdIDList.WAQSUpdateGeneratedCodeId);
                MenuCommand waqsUpdateGeneratedCodeItem = new MenuCommand(WAQSUpdateGeneratedCodeCallback, waqsUpdateGeneratedCodeCommandID);
                mcs.AddCommand(waqsUpdateGeneratedCodeItem);

                CommandID waqsInitVMCommandID = new CommandID(GuidList.guidWAQSFileCmdSet, (int)PkgCmdIDList.WAQSInitVMId);
                MenuCommand waqsInitVMItem = new MenuCommand(WAQSInitVMCallback, waqsInitVMCommandID);
                mcs.AddCommand(waqsInitVMItem);
            }
        }
Ejemplo n.º 21
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 initialization code that rely on services provided by VisualStudio.
        /// </summary>
        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.guidDuplicateFileCmdSet, (int)PkgCmdIDList.cmdidDuplicateCmd);
                MenuCommand menuItem = new MenuCommand(MenuItemCallbackDuplicate, menuCommandID);
                mcs.AddCommand(menuItem);
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            if (null != mcs)
            {
                // Create the command for the menu item.
                CommandID menuCommandID = new CommandID(GuidList.guidRefreshCmdSet, (int)PkgCmdIDList.cmdidRefreshCmd);
                MenuCommand menuItem = new MenuCommand(MenuItemCallbackRefresh, menuCommandID);
                mcs.AddCommand(menuItem);
            }

            // Override Edit.Delete command
            _applicationObject = (DTE)GetService(typeof(DTE));
            var command = _applicationObject.Commands.Item("Edit.Delete");
            _removeEvent = _applicationObject.Events.CommandEvents[command.Guid, command.ID];
            _removeEvent.BeforeExecute += OnBeforeDeleteCommand;
        }
Ejemplo n.º 22
0
        protected override void ProcessOnStatusDeleteAllCommand(System.ComponentModel.Design.MenuCommand cmd)
        {
            bool bAllowDeletion = true;

            if (this.SelectedElement == null && this.SelectedRole != null)
            {
                if (this.SelectedRole.Id == LibraryModelContextHasClasses.DomainClassDomainRoleId)
                {
                    bAllowDeletion = false;
                }
                else if (this.SelectedRole.Id == LibraryModelContextHasDiagramClasses.DiagramClassDomainRoleId)
                {
                    bAllowDeletion = false;
                }
            }

            if (bAllowDeletion)
            {
                base.ProcessOnStatusDeleteAllCommand(cmd);
            }
            else
            {
                // disable the menu command
                cmd.Enabled = false;
            }
        }
Ejemplo n.º 23
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}", 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 xBuildMenuCommandID = new CommandID(GuidList.GuidMonoHelperCmdSet, (int)PkgCmdIDList.XBuildCommandID);
                MenuCommand xBuildMenuItem = new MenuCommand(XBuildMenuItemCallback, xBuildMenuCommandID);
                mcs.AddCommand(xBuildMenuItem);

                CommandID xRebuildMenuCommandID = new CommandID(GuidList.GuidMonoHelperCmdSet, (int)PkgCmdIDList.XRebuildCommandID);
                MenuCommand xRebuildMenuItem = new MenuCommand(XRebuildMenuItemCallback, xRebuildMenuCommandID);
                mcs.AddCommand(xRebuildMenuItem);

                CommandID startNetMenuCommandID = new CommandID(GuidList.GuidMonoHelperCmdSet, (int)PkgCmdIDList.StartNetCommandID);
                MenuCommand startNetMenuItem = new MenuCommand(StartNetMenuItemCallback, startNetMenuCommandID);
                mcs.AddCommand(startNetMenuItem);

                CommandID startMonoMenuCommandID = new CommandID(GuidList.GuidMonoHelperCmdSet, (int)PkgCmdIDList.StartMonoCommandID);
                MenuCommand startMonoMenuItem = new MenuCommand(StartMonoMenuItemCallback, startMonoMenuCommandID);
                mcs.AddCommand(startMonoMenuItem);

                CommandID debugNetMenuCommandID = new CommandID(GuidList.GuidMonoHelperCmdSet, (int)PkgCmdIDList.DebugNetCommandID);
                MenuCommand debugMenuNetItem = new MenuCommand(DebugNetMenuItemCallback, debugNetMenuCommandID);
                mcs.AddCommand(debugMenuNetItem);
            }
        }
        public PendingChangesToolWindow()
            : base(null)
        {
            // set the window title
            this.Caption = Resources.ResourceManager.GetString("PendingChangesToolWindowCaption");

            //// set the CommandID for the window ToolBar
            this.ToolBar = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.imnuPendingChangesToolWindowToolbarMenu);

            // set the icon for the frame
            this.BitmapResourceID = CommandId.ibmpToolWindowsImages;  // bitmap strip resource ID
            this.BitmapIndex = CommandId.iconSccProviderToolWindow;   // index in the bitmap strip

            control = new PendingChangesView();

            // 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);
        }
Ejemplo n.º 25
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();

            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));
        }
        /////////////////////////////////////////////////////////////////////////////
        // 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;

        }
Ejemplo n.º 27
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();

            // 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.guidReviewPal2010CmdSet, (int)PkgCmdIDList.cmdidReviewPal);
                MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID );
                mcs.AddCommand( menuItem );
                // Create the command for the tool window
                CommandID toolwndCommandID = new CommandID(GuidList.guidReviewPal2010CmdSet, (int)PkgCmdIDList.cmdidReviewWindow);
                MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand( menuToolWin );
            }

            VSIDEHelper.VisualStudioInstance = Package.GetGlobalService(typeof(DTE)) as DTE2;

            solutionEvents = VSIDEHelper.VisualStudioInstance.Events.SolutionEvents;
            solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);
            solutionEvents.BeforeClosing += new _dispSolutionEvents_BeforeClosingEventHandler(solutionEvents_BeforeClosing);

            ToolWindowPane window = this.FindToolWindow(typeof(ReviewToolWindow), 0, true);
            reviewWindow = (ReviewWindow)((ReviewToolWindow)window).Content;

            //initialize the Utility class
            Utils.Initialize();
        }
Ejemplo n.º 28
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();

            //Create Editor Factory. Note that the base Package class will call Dispose on it.
            base.RegisterEditorFactory(new EditorFactory(this));

            // 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.guidVSPackage2CmdSet, (int)PkgCmdIDList.cmdidMyCommand);
                MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID );
                mcs.AddCommand( menuItem );

                // Create project command
                CommandID projectMenuCmd = new CommandID(GuidList.guidVSPackage2CmdSet, (int)PkgCmdIDList.cmdidMyProjectCommand);
                MenuCommand menuProjCmd = new MenuCommand(MenuItemCallback, projectMenuCmd);
                mcs.AddCommand(menuProjCmd);

                // Create the command for the tool window
                CommandID toolwndCommandID = new CommandID(GuidList.guidVSPackage2CmdSet, (int)PkgCmdIDList.cmdidMyTool);
                MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand( menuToolWin );
            }
        }
        protected override void Initialize()
        {
            base.Initialize();

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

            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (mcs == null)
                return;

            //Solution Node
            CommandID solutionMenuCommandId = new CommandID(GuidList.GuidVsPtcCmdSet, (int)PkgCmdIdList.CmdidMyCommandSolution);
            MenuCommand solutionmMenuItem = new MenuCommand(SolutionMenuCallback, solutionMenuCommandId);
            mcs.AddCommand(solutionmMenuItem);

            //Project Node
            CommandID projectMenuCommandId = new CommandID(GuidList.GuidVsPtcCmdSet, (int)PkgCmdIdList.CmdidMyCommandProject);
            MenuCommand projectmMenuItem = new MenuCommand(ProjectMenuCallback, projectMenuCommandId);
            mcs.AddCommand(projectmMenuItem);

            //Project Item Node - File
            CommandID itemFileMenuCommandId = new CommandID(GuidList.GuidVsPtcCmdSet, (int)PkgCmdIdList.CmdidMyCommandItemFile);
            MenuCommand itemFileMenuItem = new MenuCommand(ItemFileMenuCallback, itemFileMenuCommandId);
            mcs.AddCommand(itemFileMenuItem);

            //Project Item Node - Folder
            CommandID itemFolderMenuCommandId = new CommandID(GuidList.GuidVsPtcCmdSet, (int)PkgCmdIdList.CmdidMyCommandItemFolder);
            MenuCommand itemFolderMenuItem = new MenuCommand(ItemFolderMenuCallback, itemFolderMenuCommandId);
            mcs.AddCommand(itemFolderMenuItem);
        }
        protected override void Initialize()
        {
            base.Initialize();

            var mcs = GetService(typeof (IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                var menuCommandID = new CommandID(GuidList.guidSSDTDevPack_VSPackageCmdSet,
                    (int) PkgCmdIDList.SSDTDevPackQuickDeploy);

                var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
                mcs.AddCommand(menuItem);

                var toolwndCommandID = new CommandID(GuidList.guidSSDTDevPack_VSPackageCmdSet,
                    (int) PkgCmdIDList.SSDTDevPackMergeUi);
                var menuToolWin = new MenuCommand(ShowMergeToolWindow, toolwndCommandID);
                mcs.AddCommand(menuToolWin);

                menuCommandID = new CommandID(GuidList.guidSSDTDevPack_VSPackageCmdSet,
                    (int) PkgCmdIDList.SSDTDevPackNameConstraints);
                menuItem = new MenuCommand(NameConstraintsCalled, menuCommandID);
                mcs.AddCommand(menuItem);

            }
        }
Ejemplo n.º 31
0
        /// <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);
            }
        }
Ejemplo n.º 32
0
		/** methods */

		public BatchBuilder()
		{
			// Create the command for the tool window
			var ToolWindowCommandId = new CommandID(GuidList.UnrealVSCmdSet, BatchBuilderToolWindowId);
			var ToolWindowMenuCommand = new MenuCommand(ShowToolWindow, ToolWindowCommandId);
			UnrealVSPackage.Instance.MenuCommandService.AddCommand(ToolWindowMenuCommand);
		}
Ejemplo n.º 33
0
 /// If a command is no longer viable for a designer, it is removed.
 public override void RemoveCommand(System.ComponentModel.Design.MenuCommand command)
 {
     if (commands != null)
     {
         // Hashtable already has nothing happen if the command isn't there.
         commands.Remove(command.CommandID);
     }
 }
Ejemplo n.º 34
0
 /// called to remove a MenuCommand
 public void RemoveCommand(System.ComponentModel.Design.MenuCommand command)
 {
     if (command == null)
     {
         throw new ArgumentException("command");
     }
     commands.Remove(command.CommandID);
 }
Ejemplo n.º 35
0
 // Gestion des selections du contexteMenu
 private void OnMenuClicked(object sender, EventArgs e)
 {
     VelerSoftware.Design.Toolkit.KryptonContextMenuItem menuItem = sender as VelerSoftware.Design.Toolkit.KryptonContextMenuItem;
     if (menuItem != null && menuItem.Tag is System.ComponentModel.Design.MenuCommand)
     {
         System.ComponentModel.Design.MenuCommand command = menuItem.Tag as System.ComponentModel.Design.MenuCommand;
         command.Invoke();
     }
 }
Ejemplo n.º 36
0
        private void OnMenuClicked(object sender, EventArgs args)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;

            if (item != null)
            {
                MenuCommand cmd = item.Tag as MenuCommand;
                cmd.Invoke();
            }
        }
Ejemplo n.º 37
0
 // Ajout de command satndard au service
 public override void AddCommand(System.ComponentModel.Design.MenuCommand command)
 {
     try
     {
         menuCommandService.AddCommand(command);
     }
     catch
     {
     }
 }
Ejemplo n.º 38
0
        // Gestion des selections du contexteMenu
        private void OnMenuClicked(object sender, EventArgs e)
        {
            ToolStripDropDownButton menuItem = sender as ToolStripDropDownButton;

            if (menuItem != null && menuItem.Tag is System.ComponentModel.Design.MenuCommand)
            {
                System.ComponentModel.Design.MenuCommand command = menuItem.Tag as System.ComponentModel.Design.MenuCommand;
                command.Invoke();
            }
        }
Ejemplo n.º 39
0
        //roman//

        #region Implementation of IMenuCommandService

        /// called to add a MenuCommand
        public void AddCommand(System.ComponentModel.Design.MenuCommand command)
        {
            if (command == null)
            {
                throw new ArgumentException("command");
            }
            // don't add commands twice
            if (FindCommand(command.CommandID) == null)
            {
                commands.Add(command.CommandID, command);
            }
        }
Ejemplo n.º 40
0
        /// If a designer supports a MenuCommand, it will add it here.
        public override void AddCommand(System.ComponentModel.Design.MenuCommand command)
        {
            if (commands == null)
            {
                commands = new Hashtable();
            }

            // Only add a command if we haven't already.
            if (FindCommand(command.CommandID) == null)
            {
                commands.Add(command.CommandID, command);
            }
        }
Ejemplo n.º 41
0
        private ToolStripMenuItem[] GetSelectionMenuItems()
        {
            List <ToolStripMenuItem> menuItems = new List <ToolStripMenuItem>();

            ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;

            if (selectionService != null)
            {
                ICollection selectedComps = selectionService.GetSelectedComponents();
                Dictionary <CommandID, string> selectionCommands = new Dictionary <CommandID, string>();
                selectionCommands.Add(StandardCommands.Cut, "Cut");
                selectionCommands.Add(StandardCommands.Copy, "Copy");
                selectionCommands.Add(StandardCommands.Paste, "Paste");
                selectionCommands.Add(StandardCommands.Delete, "Delete");
                selectionCommands.Add(StandardCommands.Undo, "Undo");
                selectionCommands.Add(StandardCommands.Redo, "Redo");

                foreach (CommandID id in selectionCommands.Keys)
                {
                    MenuCommand command = FindCommand(id);
                    if (command != null)
                    {
                        ToolStripMenuItem menuItem = new ToolStripMenuItem(selectionCommands[id], null, new EventHandler(OnMenuClicked));
                        menuItem.Tag = command;
                        menuItems.Add(menuItem);
                    }
                }

                if (selectedComps != null && selectedComps.Count == 1)
                {
                    object[] comps = new object[selectedComps.Count];
                    selectedComps.CopyTo(comps, 0);
                    if (comps[0].GetType() == typeof(TabControl))
                    {
                        foreach (DesignerVerb verb in Verbs)
                        {
                            if (verb != null)
                            {
                                ToolStripMenuItem menuItem = new ToolStripMenuItem(verb.Text, null, new EventHandler(OnMenuClicked));
                                menuItem.Tag = verb;
                                menuItems.Add(menuItem);
                            }
                        }
                    }
                }
            }

            return(menuItems.ToArray());
        }
Ejemplo n.º 42
0
        /// If a designer supports a MenuCommand, it will add it here.
        public void AddCommand(System.ComponentModel.Design.MenuCommand command)
        {
            if (commands == null)
            {
                commands        = new Hashtable();
                defaultCommands = new DefaultMenuCommands(host as IServiceProvider);
                defaultCommands.AddTo(this);
            }

            // Only add a command if we haven't already.
            if (FindCommand(command.CommandID) == null)
            {
                commands.Add(command.CommandID, command);
            }
        }
Ejemplo n.º 43
0
        /// <summary>
        /// Override to stop the "Delete" command appearing for certain elements.
        /// </summary>
        protected override void ProcessOnStatusDeleteCommand(System.ComponentModel.Design.MenuCommand command)
        {
            bool bAllowDeletion = true;

            if (this.SelectedElement is DomainClass)
            {
                if ((this.SelectedElement as DomainClass).IsDomainModel)
                {
                    bAllowDeletion = false;
                }
            }

            if (this.SelectedElement is Validation)
            {
                bAllowDeletion = false;
            }

            if (this.SelectedElement is DiagramClass)
            {
                bAllowDeletion = false;
            }

            if (this.SelectedElement is View || this.SelectedElement is ModelTree)
            {
                bAllowDeletion = false;
            }

            if (this.SelectedElement is MetaModelLibrary)
            {
                command.Enabled = true;
                command.Visible = true;

                //findDependencies.Enabled = true;
                //findDependencies.Visible = true;
                return;
            }

            if (bAllowDeletion)
            {
                base.ProcessOnStatusDeleteCommand(command);
            }
            else
            {
                // disable the menu command
                command.Enabled = false;
            }
        }
Ejemplo n.º 44
0
 private bool IsMenuCommandEnabled(CommandID commandID)
 {
     if (this.designSurface == null)
     {
         return false;
     }
     IMenuCommandService service = (IMenuCommandService) this.designSurface.GetService(typeof(IMenuCommandService));
     if (service == null)
     {
         return false;
     }
     System.ComponentModel.Design.MenuCommand command = service.FindCommand(commandID);
     if (command == null)
     {
         return false;
     }
     return command.Enabled;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="MenuCommand"/> 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 MenuCommand(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 System.ComponentModel.Design.MenuCommand(this.MenuItemCallback, menuCommandID);
                commandService.AddCommand(menuItem);
            }
        }
        /// <summary>
        /// 判断一个命令标识符是否可用
        /// </summary>
        /// <param name="commandID"></param>
        /// <returns></returns>
        public bool IsMenuCommandEnabled(CommandID commandID)
        {
            if (_designSurface == null)
            {
                return(false);
            }

            if (_menuCommandService == null)
            {
                return(false);
            }

            System.ComponentModel.Design.MenuCommand menuCommand = _menuCommandService.FindCommand(commandID);
            if (menuCommand == null)
            {
                return(false);
            }

            //int status = menuCommand.OleStatus;
            return(menuCommand.Enabled);
        }
Ejemplo n.º 47
0
        private bool IsMenuCommandEnabled(CommandID commandID)
        {
            if (designSurface == null)
            {
                return(false);
            }

            IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));

            if (menuCommandService == null)
            {
                return(false);
            }

            System.ComponentModel.Design.MenuCommand menuCommand = menuCommandService.FindCommand(commandID);
            if (menuCommand == null)
            {
                return(false);
            }
            return(menuCommand.Enabled);
        }
Ejemplo n.º 48
0
        private void OnStatusPaste(object sender, System.EventArgs e)
        {
            System.ComponentModel.Design.MenuCommand menuCommand = (System.ComponentModel.Design.MenuCommand)sender;
            if (this.SelectedElement == null && this.SelectedRole == null)
            {
                menuCommand.Enabled = false;
                return;
            }

            try
            {
                System.Windows.IDataObject idataObject = System.Windows.Clipboard.GetDataObject();
                if (idataObject != null)
                {
                    CopyPaste.CopyAndPasteOperations.ProcessMoveMode(idataObject);

                    if (this.SelectedElement != null)
                    {
                        menuCommand.Enabled = CopyPaste.CopyAndPasteOperations.CanExecutePaste(this.SelectedElement, idataObject);
                    }
                    else if (this.SelectedRole != null)
                    {
                        menuCommand.Enabled = CopyPaste.CopyAndPasteOperations.CanExecutePaste(this.CurrentParentElement, idataObject);
                    }
                    else
                    {
                        menuCommand.Enabled = false;
                    }
                }
            }
            catch
            {
                menuCommand.Enabled = false;
            }
            menuCommand.Visible = true;
        }
Ejemplo n.º 49
0
        /*
         * private void OnStatusCut(object sender, System.EventArgs e)
         * {
         *  System.ComponentModel.Design.MenuCommand menuCommand = (System.ComponentModel.Design.MenuCommand)sender;
         *  if (this.SelectedElement == null)
         *  {
         *      menuCommand.Enabled = false;
         *      return;
         *  }
         *
         *  Collection<ModelElement> elements = new Collection<ModelElement>();
         *  elements.Add(this.SelectedElement);
         *
         *  menuCommand.Enabled = CopyPaste.CopyAndPasteOperations.CanExecuteMove(elements);
         *  menuCommand.Visible = true;
         *
         * }
         */
        private void OnStatusCopy(object sender, System.EventArgs e)
        {
            System.ComponentModel.Design.MenuCommand menuCommand = (System.ComponentModel.Design.MenuCommand)sender;
            if (this.SelectedElement == null)
            {
                menuCommand.Enabled = false;
                return;
            }

            if (this.SelectedElement is DomainType || this.SelectedElement is PropertyGridEditor ||
                this.SelectedElement is CreditItem || this.SelectedElement is InformationItem ||
                this.SelectedElement is EnumerationLiteral)
            {
                Collection <ModelElement> elements = new Collection <ModelElement>();
                elements.Add(this.SelectedElement);

                menuCommand.Enabled = CopyPaste.CopyAndPasteOperations.CanExecuteCopy(elements);
            }
            else
            {
                menuCommand.Enabled = false;
            }
            menuCommand.Visible = true;
        }
Ejemplo n.º 50
0
 /// <summary>
 /// Adds the specified standard menu command to the menu.
 /// </summary>
 /// <param name="command">The System.ComponentModel.Design.MenuCommand to add.</param>
 public void AddCommand(System.ComponentModel.Design.MenuCommand command)
 {
     commands.Add(command);
 }
Ejemplo n.º 51
0
 // Retire une command satndard du service
 public override void RemoveCommand(System.ComponentModel.Design.MenuCommand command)
 {
     menuCommandService.RemoveCommand(command);
 }
Ejemplo n.º 52
0
 /// <summary>
 /// Removes the specified standard menu command from the menu.
 /// </summary>
 /// <param name="command">The System.ComponentModel.Design.MenuCommand to remove.</param>
 public void RemoveCommand(System.ComponentModel.Design.MenuCommand command)
 {
     commands.Remove(command);
 }