Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NapackCommands"/> 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 NapackCommands(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            commandService?.AddCommand(new MenuCommand(this.FindCallback, new CommandID(CommandSet, 0x0100)));
            commandService?.AddCommand(new MenuCommand(this.CreateCallback, new CommandID(CommandSet, 0x0101)));
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RunProfilerCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="serviceProvider">Owner package, not null.</param>
        private RunProfilerCommand(IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            OleMenuCommandService commandService = serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            commandService?.AddCommand(new MenuCommand(MenuItemCallback, new CommandID(GeneralProperties.CommandSet, CommandId)));
        }
Пример #3
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            this.options = new SolutionOptions();
            this.AddOptionKey(Constants.SolutionOptionKey);

            this.telemetry = new Telemetry(this.options);
            this.telemetry.TrackEvent(Constants.EventInitializePackage);

            // Add a command handler for showing the tool window
            CommandID             menuCommandID  = new CommandID(Constants.GuidCommandSet, Constants.BindingToolWindowCommandId);
            MenuCommand           menuItem       = new MenuCommand((s, a) => this.ShowBindingPane(), menuCommandID);
            OleMenuCommandService commandService = await this.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            commandService?.AddCommand(menuItem);
        }
Пример #4
0
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            _solutionService = GetService(typeof(SVsSolution)) as IVsSolution;
            if (_solutionService != null)
            {
                Common.Instance.Package  = this;
                Common.Instance.Solution = _solutionService;
            }

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

            if (null != mcs)
            {
                // Create the command for the tool window
                CommandID   toolwndCommandID = new CommandID(GuidList.guidSolutionEventsMonitorCmdSet, (int)PkgCmdIDList.cmdidMyTool);
                MenuCommand menuToolWin      = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }
        }
        private SolutionUnityBuildControl(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                for (int i = 0; i < 2; ++i)
                {
                    CommandID      menuCommandID = new CommandID(CommandSet, CommandId + i);
                    OleMenuCommand menuItem      = new OleMenuCommand(this.Execute, menuCommandID);
                    menuItem.BeforeQueryStatus += OnBeforeQueryStatus;
                    commandService.AddCommand(menuItem);
                }
            }
        }
Пример #6
0
        /////////////////////////////////////////////////////////////////////////////
        // 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() {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            var langService = new DjangoLanguageInfo(this);
            ((IServiceContainer)this).AddService(langService.GetType(), langService, true);

#if DJANGO_HTML_EDITOR
            //Create Editor Factory. Note that the base Package class will call Dispose on it.
            RegisterEditorFactory(new DjangoEditorFactory(this));
#endif
            RegisterProjectFactory(new DjangoProjectFactory(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.guidDjangoCmdSet, (int)PkgCmdIDList.cmdidGotoTemplateSource);
                MenuCommand menuItem = new MenuCommand(GotoTemplateSourceCode, menuCommandID);
                mcs.AddCommand(menuItem);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NewbeCommand"/> 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 NewbeCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService =
                this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                foreach (var commandId in CommandIds)
                {
                    var menuCommandID = new CommandID(CommandSet, commandId);
                    var menuItem      = new MenuCommand(this.MenuItemCallback, menuCommandID);
                    commandService.AddCommand(menuItem);
                }
            }
        }
Пример #8
0
        private void CreateList(OleMenuCommandService mcs)
        {
            var files = Directory.GetFiles(PackageEnvironment.ScriptDirectoryFullPath, "*.tt");

            for (int index = 0; index < files.Length; index++)
            {
                string file = files[index];
                try
                {
                    var id      = new CommandID(GuidList.guidMenuAndCommandsCmdSet, _slots[index]);
                    var command = new DynamicScriptCommand(id, file, GetCurrentClassFileName, OutputCommandString)
                    {
                        Visible = true
                    };
                    mcs.AddCommand(command);
                }
                catch (Exception exception)
                {
                    OutputCommandString(string.Format("Can't add t4 file {0}. Exception: {1}", file, exception.GetType()));
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Initialization of the package; this is the place where you can put all the initialization
        /// code that relies on services provided by Visual Studio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Now get the OleCommandService object provided by the MPF; this object is the one
            // responsible for handling the collection of commands implemented by the package.
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // Now create one object derived from MenuCommand for each command defined in
                // the VSCT file and add it to the command service.

                // For each command we have to define its id that is a unique Guid/integer pair.
                CommandID id = new CommandID(GuidsList.guidMenuAndCommandsCmdSet, PkgCmdIDList.cmdidMyCommand);
                // Now create the OleMenuCommand object for this command. The EventHandler object is the
                // function that will be called when the user will select the command.
                OleMenuCommand command = new OleMenuCommand(new EventHandler(MenuCommandCallback), id);
                // Add the command to the command service.
                mcs.AddCommand(command);
            }
        }
        public BaseCommand(Package package, int commandId, bool isDynamic = true)
        {
            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 OleMenuCommand(this.MenuItemCallback, menuCommandID);
                if (isDynamic)
                {
                    menuItem.BeforeQueryStatus += MenuItem_BeforeQueryStatus;
                }
                commandService.AddCommand(menuItem);
            }
        }
Пример #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BuildDemangledOutput"/> 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 BuildDemangledOutput(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(this.BuildDemangledOutputCommandHandler, menuCommandID);
                commandService.AddCommand(menuItem);
            }

            buildEvents = new BuildEvents();
            buildEvents.BuildStartedEvent  += OnBuildStarted;
            buildEvents.BuildFinishedEvent += OnBuildFinished;
        }
Пример #12
0
        protected AbstractOutputWindowDynamicCommand(
            OleMenuCommandService commandService
            , Guid commandGroupId
            , int baseIdStart
            , int commandsCount
            )
        {
            this._baseIdStart = baseIdStart;

            for (int i = 0; i < commandsCount; i++)
            {
                var menuCommandID = new CommandID(commandGroupId, _baseIdStart + i);

                var menuCommand = new OleMenuCommand(this.menuItemCallback, menuCommandID);

                menuCommand.Enabled = menuCommand.Visible = false;

                menuCommand.BeforeQueryStatus += menuItem_BeforeQueryStatus;

                commandService.AddCommand(menuCommand);
            }
        }
Пример #13
0
        /////////////////////////////////////////////////////////////////////////////
        // 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()
        {
            Debug.Print(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            var window = this.CreateToolWindow(typeof(QuickOpenFileToolWindow), 0) as QuickOpenFileToolWindow;

            window.SetPackage(this);
            //window.InitControl();

            // 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(Guids.CmdSetGuid, (int)PkgCmdIDList.cmdidAOToolWindow);
                MenuCommand menuToolWin      = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }
            Instance = this;
        }
Пример #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Command2"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="commandService">Command service to add command to, not null.</param>
        private Command2(AsyncPackage package, OleMenuCommandService commandService)
        {
            this.package   = package ?? throw new ArgumentNullException(nameof(package));
            commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));

            var menuCommandID = new CommandID(CommandSet, CommandId);
            var menuItem      = new MenuCommand(new EventHandler(this.ExecuteAsync), menuCommandID);

            commandService.AddCommand(menuItem);

            try
            {
                ConnectionInfoStore connectionInfoStore = new ConnectionInfoStore();
                connectionInfoStore.Load();
                if (connectionInfoStore.Connections.Count > 0)
                {
                    remoteSystem = new RemoteSystem((ConnectionInfo)connectionInfoStore.Connections[0]);
                    directory    = remoteSystem.FileSystem.GetDirectory(SpecialDirectory.Home);
                }
            }
            catch { }
        }
Пример #15
0
        private OleMenuCommand RegisterCommandPrivate(CommandBase commandHandler, bool toolbarOnly)
        {
            OleMenuCommand vscommand = null;
            uint           cmdId     = 0;

            try
            {
                Command existingCmd = mPlugin.Commands.Item(commandHandler.CanonicalName, -1);
                cmdId = (uint)existingCmd.ID;
            }
            catch (System.ArgumentException)
            {
            }

            if (cmdId == 0)
            {
                Log.Info("Registering the command {0} from scratch", commandHandler.Name);
                int result = mPlugin.ProfferCommands.AddNamedCommand(mPackageGuid, mCmdGroupGuid, commandHandler.CanonicalName, out cmdId, commandHandler.CanonicalName, commandHandler.CanonicalName, commandHandler.Tooltip, null, 0, (uint)commandHandler.IconIndex, 0, 0, null);
            }

            if (cmdId != 0)
            {
                OleMenuCommandService menuCommandService = mPlugin.MenuCommandService;
                CommandID             commandID          = new CommandID(mCmdGroupGuid, (int)cmdId);

                vscommand = new OleMenuCommand(OleMenuCommandCallback, commandID);
                vscommand.BeforeQueryStatus += this.OleMenuCommandBeforeQueryStatus;
                menuCommandService.AddCommand(vscommand);
                mCommandsById[cmdId] = commandHandler;
            }
            // Register the graphics controls for this command as well.
            // First let the command itself have a stab at register whatever it needs.
            // Then by default we always register ourselves in the main toolbar of the application.
            if (!commandHandler.RegisterGUI(vscommand, mCommandBar, toolbarOnly))
            {
            }

            return(vscommand);
        }
Пример #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NugetPublish"/> 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 NugetPublish(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);
                // AND REPLACE IT WITH A DIFFERENT TYPE
                var menuItem = new OleMenuCommand(MenuItemCallback, menuCommandId);
                //                menuItem.BeforeQueryStatus += menuCommand_BeforeQueryStatus;

                commandService.AddCommand(menuItem);
            }
        }
Пример #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateWebResources"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="commandId">Command ID, not null.</param>
        public BaseCommand(AsyncPackage package, int commandId, params Guid[] commandSets)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package       = package;
            this.projectHelper = new ProjectHelper(package);

            OleMenuCommandService commandService = this.ServiceProvider.GetServiceAsync(typeof(IMenuCommandService)).Result as OleMenuCommandService;

            if (commandService != null)
            {
                foreach (var commandSet in commandSets)
                {
                    var menuCommandID = new CommandID(commandSet, commandId);
                    var menuItem      = new MenuCommand(this.MenuItemCallback, menuCommandID);
                    commandService.AddCommand(menuItem);
                }
            }
        }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileContext"/> 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 FileContext(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            m_SelectedItemUtil = new SelectedItemUtil();
            m_SqlClipboard     = new SqlClipboard();

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var            menuCommandID = new CommandID(CommandSet, CommandId);
                OleMenuCommand menuItem      = new OleMenuCommand(this.MenuItemCallback, menuCommandID);
                menuItem.BeforeQueryStatus += MenuItem_BeforeQueryStatus;
                commandService.AddCommand(menuItem);
            }
        }
Пример #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QuickMethodCommand"/> 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 QuickMethodCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(this.ShowToolWindow, menuCommandID);
                commandService.AddCommand(menuItem);
            }

            window = new QuickMethodToolWindow(false,
                                               Data.SymbolData.ESymbolType.Method |
                                               Data.SymbolData.ESymbolType.MethodPrototype);
        }
        /////////////////////////////////////////////////////////////////////////////
        // 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 tool window
                CommandID   toolwndCommandID = new CommandID(GuidsList.guidRdtEventExplorerCmdSet, (int)PkgCmdIDList.cmdidMyTool);
                MenuCommand menuToolWin      = new MenuCommand(new EventHandler(ShowToolWindow), toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }

            //// Add a global service to provide a single set of options.
            //((IServiceContainer)this).AddService(typeof(SMyOptionsService), this, true);

            //// Now that we have the service, we can use it to initialize options.
            //// At this point options is null, so we will initialize it from the registry.
            //GetRdtEventOptions();
        }
Пример #21
0
        internal void RegisterCommands(IEnumerable <Command> commands, Guid cmdSet)
        {
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                lock (_commandsLock) {
                    foreach (var command in commands)
                    {
                        var            beforeQueryStatus = command.BeforeQueryStatus;
                        CommandID      toolwndCommandID  = new CommandID(cmdSet, command.CommandId);
                        OleMenuCommand menuToolWin       = new OleMenuCommand(command.DoCommand, toolwndCommandID);
                        if (beforeQueryStatus != null)
                        {
                            menuToolWin.BeforeQueryStatus += beforeQueryStatus;
                        }
                        mcs.AddCommand(menuToolWin);
                        _commands[command] = menuToolWin;
                    }
                }
            }
        }
Пример #22
0
        private PostHasteCommand(Package package, TextSelector textSelector)
        {
            if (package == null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            this.url          = Properties.Settings.Default.HasteBinUrl;
            this.package      = package;
            this.textSelector = textSelector;

            OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandId = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(MenuItemCallback, menuCommandId);
                commandService.AddCommand(menuItem);
            }

            statusBar = ServiceProvider.GetService(typeof(SVsStatusbar)) as IVsStatusbar;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigCommand"/> 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 ConfigCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;
            if (ServiceProviderForWindow == null)
            {
                ServiceProviderForWindow = package;
            }

            OleMenuCommandService commandService = this.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);
            }
        }
Пример #24
0
        private ForceContinue(AsyncPackage package, OleMenuCommandService commandService)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            this.package   = package ?? throw new ArgumentNullException(nameof(package));
            commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));

            var menuCommandID = new CommandID(CommandSet, CommandId);
            var menuItem      = new OleMenuCommand(this.Execute, menuCommandID);

            var dte = UtilityMethods.GetDTE(package);

            m_debuggerEvents = dte.Events.DebuggerEvents;
            m_debuggerEvents.OnEnterBreakMode += OnEnterBreakMode;

            menuItem.BeforeQueryStatus += OnBeforeQueryStatus;

            m_Command = menuItem;


            commandService.AddCommand(menuItem);
        }
        /////////////////////////////////////////////////////////////////////////////
        // 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()
        {
            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   iTTCommandID = new CommandID(GuidList.guidTechnologicatorCmdSet, (int)PkgCmdIDList.cmdidTechnologicatorOpenITT);
                MenuCommand itt          = new MenuCommand(IssueTrackingWebCallback, iTTCommandID);
                mcs.AddCommand(itt);

                CommandID chooseCommandID = new CommandID(GuidList.guidTechnologicatorCmdSet, (int)PkgCmdIDList.cmdidTechnologicatorChoose);
                _chooseCommandItem = new OleMenuCommand(ChooseTechCallback, chooseCommandID);
                _chooseCommandItem.BeforeQueryStatus += new EventHandler(ChooseBeforeStatusQueryCallback);
                mcs.AddCommand(_chooseCommandItem);

                CommandID      addCommandID = new CommandID(GuidList.guidTechnologicatorCmdSet, (int)PkgCmdIDList.cmdidTechnologicatorAdd);
                OleMenuCommand addItem      = new OleMenuCommand(AddTechCallback, addCommandID);
                mcs.AddCommand(addItem);

                CommandID      changeCommandID = new CommandID(GuidList.guidTechnologicatorCmdSet, (int)PkgCmdIDList.cmdidTechnologicatorChange);
                OleMenuCommand changeItem      = new OleMenuCommand(ChangeTechCallback, changeCommandID);
                mcs.AddCommand(changeItem);

                CommandID      removeCommandID = new CommandID(GuidList.guidTechnologicatorCmdSet, (int)PkgCmdIDList.cmdidTechnologicatorRemove);
                OleMenuCommand removeItem      = new OleMenuCommand(RemoveTechCallback, removeCommandID);
                mcs.AddCommand(removeItem);

                CommandID      endifCommandID = new CommandID(GuidList.guidTechnologicatorCmdSet, (int)PkgCmdIDList.cmdidTechnologicatorEndif);
                OleMenuCommand endifItem      = new OleMenuCommand(EndIfCallback, endifCommandID);
                endifItem.BeforeQueryStatus += new EventHandler(EndifBeforeStatusQueryCallback);
                mcs.AddCommand(endifItem);
            }

            _dte         = (DTE)GetService(typeof(DTE));
            _textManager = GetService(typeof(VsTextManagerClass)) as IVsTextManager;

            var componentModel = (IComponentModel)GetService(typeof(SComponentModel));

            _adapters = componentModel.GetService <IVsEditorAdaptersFactoryService>();
        }
        /////////////////////////////////////////////////////////////////////////////
        // 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()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            InternalInitialize();

            #region PlanWorkItemController

            PlanWorkItemController planWorkItemController = new PlanWorkItemController();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = this.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                // Create the command for the menu item.
                CommandID   menuCommandID = new CommandID(GuidList.guidTFSScrumExtensionsCmdSet, (int)PkgCmdIDList.cmdPlanWorkItem);
                MenuCommand menuItem      = new MenuCommand(planWorkItemController.OnPlanWorkItem, menuCommandID);
                mcs.AddCommand(menuItem);
            }

            #endregion
        }
Пример #27
0
        protected override void Initialize()
        {
            base.Initialize();

            expressionGraph = new ExpressionGraph();

            applicationObject = (DTE2)GetService(typeof(DTE));

            debuggerEvents = applicationObject.Events.DebuggerEvents;
            debuggerEvents.OnEnterBreakMode  += DebuggerEvents_OnEnterBreakMode;
            debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;

            // 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.guidCommandTargetRGBCmdSet, (int)PkgCmdIDList.cmdidShowToolWindow);
                MenuCommand menuToolWin      = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }
        }
Пример #28
0
        public static async Task InitializeAsync(AsyncPackage package)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

            OleMenuCommandService commandService = await package.GetServiceAsync <IMenuCommandService, OleMenuCommandService>();

            Assumes.Present(commandService);

            IVsUIShell shell = await package.GetServiceAsync <SVsUIShell, IVsUIShell>();

            Assumes.Present(shell);

            DTE2 dte = await package.GetServiceAsync <DTE, DTE2>();

            Assumes.Present(dte);

            var cmdId    = new CommandID(PackageGuids.guidCommands, PackageIds.LanguageSetting);
            var menuItem = new OleMenuCommand((s, e) => Execute(shell, dte), cmdId);

            menuItem.BeforeQueryStatus += (s, e) => OnBeforeQueryStatus(menuItem, dte);

            commandService.AddCommand(menuItem);
        }
Пример #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SolutionMenuContext"/> 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 SolutionMenuContext(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package          = package;
            m_SelectedItemUtil    = new SelectedItemUtil();
            m_RegistryMap         = new RegistryMap();
            m_BeyondCompareRunner = new BeyondCompareRunner();

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var            menuCommandID = new CommandID(CommandSet, CommandId);
                OleMenuCommand menuItem      = new OleMenuCommand(this.MenuItemCallback, menuCommandID);
                menuItem.BeforeQueryStatus += MenuItem_BeforeQueryStatus;

                commandService.AddCommand(menuItem);
            }
        }
Пример #30
0
        private GoToCodeCmd(Package package, DTE dte)
        {
            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 OleMenuCommand(
                    this.MenuItemCallback,
                    null,
                    this.BeforeQueryStatus,
                    menuCommandID);
                commandService.AddCommand(menuItem);
                this.dte = dte;
            }
        }