Пример #1
0
 public Commands(IVsExtensionRepository repo, IVsExtensionManager manager, OleMenuCommandService mcs, IVsOutputWindowPane outputPane)
 {
     _repository = repo;
     _manager = manager;
     _mcs = mcs;
     _outputPane = outputPane;
 }
        public void SetupCommands(OleMenuCommandService commandService)
        {
            if (Package.DocumentManager == null)
            {
                return;
            }

            var guid = typeof(RestoreTabsListCommandIds).GUID;

            var commandId = new CommandID(guid, (int)RestoreTabsListCommandIds.RestoreTabsListPlaceholder);
            var command = new OleMenuCommand(null, commandId);
            command.BeforeQueryStatus += RestoreTabsListPlaceholderCommandOnBeforeQueryStatus;
            commandService.AddCommand(command);

            for (var i = (int)RestoreTabsListCommandIds.RestoreTabsListStart; i <= (int)RestoreTabsListCommandIds.RestoreTabsListEnd; i++)
            {
                commandId = new CommandID(guid, i);
                command = new OleMenuCommand(ExecuteRestoreTabsCommand, commandId);
                command.BeforeQueryStatus += RestoreTabsCommandOnBeforeQueryStatus;
                commandService.AddCommand(command);

                var index = GetGroupIndex(command);
                Package.Environment.SetKeyBindings(command, $"Global::Ctrl+D,{index}", $"Text Editor::Ctrl+D,{index}");
            }
        }
Пример #3
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 );
 }
        public ProjectSettingsMenu(DTE2 dte, OleMenuCommandService mcs)
        {
            _dte = dte;
            _mcs = mcs;

            _dte.Events.SolutionEvents.Opened += SolutionEvents_Opened;
        }
 public CSharpResetInteractiveMenuCommand(
     OleMenuCommandService menuCommandService,
     IVsMonitorSelection monitorSelection,
     IComponentModel componentModel)
     : base(ContentTypeNames.CSharpContentType, menuCommandService, monitorSelection, componentModel)
 {
 }
 public void RegisterTo(OleMenuCommandService menuCommandService, SpecFlowCmdSet commandId)
 {
     CommandID menuCommandID = new CommandID(GuidList.guidSpecFlowCmdSet, (int)(uint)commandId);
     OleMenuCommand menuItem = new OleMenuCommand(InvokeHandler, menuCommandID);
     menuItem.BeforeQueryStatus += BeforeQueryStatusHandler;
     menuCommandService.AddCommand(menuItem);
 }
Пример #7
0
        private void AddAttachToCommand(OleMenuCommandService mcs, uint commandId, Func<GeneralOptionsPage, bool> isVisible, params string[] programsToAttach)
        {
            var menuItemCommand = new OleMenuCommand((sender, args) => Attach(programsToAttach),
                new CommandID(GuidList.guidAttachToCmdSet, (int)commandId));

            menuItemCommand.BeforeQueryStatus += (s, e) => menuItemCommand.Visible = isVisible((GeneralOptionsPage)GetDialogPage(typeof(GeneralOptionsPage)));
            mcs.AddCommand(menuItemCommand);
        }
        private ClearCache(OleMenuCommandService commandService, AsyncPackage package)
        {
            ServiceProvider = package;

            var commandID = new CommandID(PackageGuids.guidClearCachePackageCmdSet, PackageIds.ClearCacheId);
            var button = new MenuCommand(DeleteCacheFolder, commandID);
            commandService.AddCommand(button);
        }
Пример #9
0
 public HubsT4Menu(DTE2 dte, OleMenuCommandService mcs)
 {
     _dte = dte;
     _mcs = mcs;
     _dependencies = new List<string>();
     _dependencies.Add(@"\typings\jquery\jquery.d.ts");
     _dependencies.Add(@"\typings\signalr\signalr.d.ts");
 }
        //Todo: See if this can be refactored with better IoC
        private void SetDependencies()
        {
            var dte = ((DTE)GetService(typeof(DTE)));
            var solution = dte != null ? dte.Solution : null;

            _commandService = (OleMenuCommandService) GetService(typeof (IMenuCommandService));
            _tortoiseGitLauncherService = (ITortoiseGitLauncherService) GetService(typeof (TortoiseGitLauncherService))
                ?? new TortoiseGitLauncherService(new ProcessManagerService(), solution);
        }
        EnableReloadCommand(Package package, OleMenuCommandService commandService)
        {
            _package = package;

            var id = new CommandID(PackageGuids.guidBrowserReloadCmdSet, PackageIds.EnableReloadCommandId);
            var cmd = new OleMenuCommand(Execute, id);
            cmd.BeforeQueryStatus += BeforeQueryStatus;
            commandService.AddCommand(cmd);
        }
Пример #12
0
        public MarkdownMenu(DTE2 dte, OleMenuCommandService mcs)
        {
            Mef.SatisfyImportsOnce(this);
            _contentType = ContentTypes.GetContentType("Markdown");
            _extensions = FileExtensionRegistry.GetFileExtensionSet(_contentType);

            _dte = dte;
            _mcs = mcs;
        }
Пример #13
0
        private AddCommand(OleMenuCommandService commandService, DTE2 dte)
        {
            _dte = dte;

            var cmdAddCommand = new CommandID(PackageGuids.guidCommandCmdSet, PackageIds.AddCommandId);
            var addCommandItem = new OleMenuCommand(AddCommandToFile, cmdAddCommand);
            addCommandItem.BeforeQueryStatus += BeforeQueryStatus;
            commandService.AddCommand(addCommandItem);
        }
        /// <summary>
        /// Add buttons to the toolbar. Specify the target toolbar, which button to place, and 
        /// the corresponding function call.
        /// </summary>
        private void AddCommand(OleMenuCommandService mcs, int cmdid, EventHandler handler)
        {
            // Create the command for the tool window
            CommandID commandID    = new CommandID(GuidList.guidCommandTargetRGBCmdSet, cmdid);
            OleMenuCommand command = new OleMenuCommand(handler, commandID);
            command.BeforeQueryStatus += OnBeforeQueryStatus;

            mcs.AddCommand(command);
        }
 private void AddMenuCommandHandlers()
 {
     _mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
     if (null != _mcs)
     {
         CommandID menuCommandID = new CommandID(GuidList.guidVisualStudio_MenuExtensionCmdSet, (int)PkgCmdIDList.cmdidLinkOpenRiaServicesProject);
         MenuCommand menuItem = new OleMenuCommand(LinkRiaProjectCallback, null, BeforeQueryStatusForAddPackageDialog, menuCommandID);
         _mcs.AddCommand(menuItem);
     }
 }
Пример #16
0
        private void CreateMenuCommands(OleMenuCommandService mcs)
        {
            CommandID runLonestarOnActiveViewMenuCommandID = new CommandID(GuidList.guidLonestarCmdSet, (int)PkgCmdIDList.runLonestarOnActiveView);
            CommandID runLonestarOnSolutionMenuCommandID = new CommandID(GuidList.guidLonestarCmdSet, (int)PkgCmdIDList.runLonestarOnSolution);
            MenuCommandController controller = new MenuCommandController(this);
            MenuCommand menuItem = new MenuCommand(controller.RunLonestarOnActiveView, runLonestarOnActiveViewMenuCommandID);
            mcs.AddCommand(menuItem);

            MenuCommand runOnSolution = new MenuCommand(controller.RunLonestarOnSolution, runLonestarOnSolutionMenuCommandID);
            mcs.AddCommand(runOnSolution);
        }
Пример #17
0
        public HandlebarsMenu(DTE2 dte, OleMenuCommandService mcs)
        {
            Mef.SatisfyImportsOnce(this);
            _contentType = ContentTypes.GetContentType("Handlebars");

            if (_contentType != null)
                _extensions = FileExtensionRegistry.GetFileExtensionSet(_contentType);

            _dte = dte;
            _mcs = mcs;
        }
 private void AddCommand(OleMenuCommandService mcs, uint commandId)
 {
     OleMenuCommand menuItemCommand = new OleMenuCommand(
         delegate(object sender, EventArgs e)
         {
             RefreshAppPoolMenu(mcs);
         },
         new CommandID(GuidList.guidNielsV_AttachToAppPoolCmdSet, (int)commandId));
     //menuItemCommand.BeforeQueryStatus += (s, e) => menuItemCommand.Visible = isVisible((GeneralOptionsPage)this.GetDialogPage(typeof(GeneralOptionsPage)));
     mcs.AddCommand(menuItemCommand);
 }
        protected GitStatusBarManager(Guid commandSetGuid, int branchMenuCmId, int branchCommandMenuCmId, int repositoryCommandMenuCmId,  IServiceContainer serviceProvider, IStatusBarService statusBarService)
        {
            BranchMenuCmId = branchMenuCmId;
            BranchCommandMenuCmId = branchCommandMenuCmId;
            RepositoryCommandMenuCmId = repositoryCommandMenuCmId;
            StatusBarService = statusBarService;
            CommandSetGuid = commandSetGuid;
            _menuCommandService = serviceProvider.GetService(typeof(IMenuCommandService)) as MsVsShell.OleMenuCommandService;
            _serviceProvider = serviceProvider;
            _branchCommandMenuCommands = new List<Tuple<string, MenuCommand>>();

        }
Пример #20
0
        public Plugin(DTE2 application, IVsProfferCommands3 profferCommands, ImageList icons, OleMenuCommandService oleMenuCommandService, string panelName, string connectPath, object options)
        {
            // TODO: This can be figured out from traversing the assembly and locating the Connect class...
            m_connectPath = connectPath;

            m_application = application;
            m_panelName = panelName;
            m_profferCommands = profferCommands;
            m_oleMenuCommandService = oleMenuCommandService;
            mOptions = options;
            m_icons = icons;
        }
 private void SetupAttachCommand(OleMenuCommandService menuCommandService)
 {
     var dynamicItemRootId = new CommandID(GuidList.Commands, (int) CommandIDs.AttachToDynamicStub);
     var dynamicMenuCommand = new DynamicMenuCommand(
         (sender, e) => {
             var invokedCommand = (DynamicMenuCommand)sender;
             _controller.HandleAttachTo(invokedCommand.Text);
         },
         dynamicItemRootId,
         index => _controller.GetTargets().ElementAtOrDefault(index)
     );
     menuCommandService.AddCommand(dynamicMenuCommand);
 }
Пример #22
0
        public void Install(TinyIoCContainer container)
        {
            serviceProvider = container.Resolve<IServiceProvider>();

            menuCommandService = serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (menuCommandService == null) return;
            pluginConfiguration = container.Resolve<IPluginConfiguration>();
            pluginConfiguration.PropertyChanged += SetButtonState;
            solutionEvents = container.Resolve<ISolutionEventsListener>();
            solutionEvents.AfterSolutionLoaded += SolutionLoaded;
            solutionEvents.BeforeSolutionClosed += SolutionClosed;
            var vs = container.Resolve<IVisualStudioService>();
            InstallMenuCommands(vs.IsSolutionOpen);
        }
Пример #23
0
        public void Initialize(IVsUIShell uiShell, DTE2 dte, OleMenuCommandService mcs)
        {
            if (!this.initialized)
            {
                this.UIShell = uiShell;
                this.DTE = dte;
                this.MenuCommandService = mcs;
                this.VSSolution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;

                InitOutputPane();

                this.initialized = true;
            }
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public void RegisterCallbacks (OleMenuCommandService menuCommandService)
    {
      if (menuCommandService != null)
      {
        foreach (KeyValuePair<uint, EventHandler> keyValue in m_eventCallbacks)
        {
          CommandID commandId = new CommandID (Guids.guidAndroidPlusPlusCommandSetID, (int)keyValue.Key);

          MenuCommand menuCommand = new MenuCommand (keyValue.Value, commandId);

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

            this.package = package;

            commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                CommandId = 0x0100;
                //CommandSet = new Guid("952f5cdf-910a-481c-801c-ba3a5e7077ba");  //GUID for menu Group

                //                commandService.GlobalInvoke(commandID);
                var menuCommandID = new CommandID(CommandSet, 0x0105);
                var menuItem = new MenuCommand(this.ToggleBreakpoint, menuCommandID);
                commandService.AddCommand(menuItem);

                //   type = typeof(Microsoft.VisualStudio.VSConstants.VSStd97CmdID);
                //   commandID = new CommandID(type.GUID, cmdidToggleBreakpoint);
                //   menuCommandID = new CommandID(CommandSet, CommandId);
                menuCommandID = new CommandID(CommandSet, 0x0101);
                menuItem = new MenuCommand(this.Clean, menuCommandID);
                commandService.AddCommand(menuItem);

                menuCommandID = new CommandID(CommandSet, 0x0102);
                menuItem = new MenuCommand(this.DisableAllBPs, menuCommandID);
                commandService.AddCommand(menuItem);

                menuCommandID = new CommandID(CommandSet, 0x0103);
                menuItem = new MenuCommand(this.EnableAllBPs, menuCommandID);
                commandService.AddCommand(menuItem);

                menuCommandID = new CommandID(CommandSet, 0x0104);
                menuItem = new MenuCommand(this.Rebuild, menuCommandID);
                commandService.AddCommand(menuItem);

                //
                menuCommandID = new CommandID(CommandSet, 0x0106);

                menuItem = new MenuCommand(this.ToggleComments, menuCommandID);
                commandService.AddCommand(menuItem);

                menuCommandID = new CommandID(CommandSet, 0x0107);
                menuItem = new MenuCommand(this.ViewDoc, menuCommandID);
                commandService.AddCommand(menuItem);
            }
        }
Пример #26
0
 public void BuildMenuItems( OleMenuCommandService mcs )
 {
     if ( OptionsPage.Attachables == null ) {
         Debug.WriteLine ( "ATA: No Attachables found." );
         throw new ArgumentNullException ( "attachables" );
     }
     var items = OptionsPage.Attachables.Where ( f => f.Enabled );
     if ( items != null ) {
         var count = items.Count ( );
         for ( var i = 0; i < count; ++i ) {
             int id = baseAttactListId + i;
             AddAttachCommand ( mcs, id, x => x.Attachables[i] );
         }
     }
 }
 public AbstractResetInteractiveMenuCommand(
     string contentType,
     OleMenuCommandService menuCommandService,
     IVsMonitorSelection monitorSelection,
     IComponentModel componentModel)
 {
     _contentType = contentType;
     _menuCommandService = menuCommandService;
     _monitorSelection = monitorSelection;
     _componentModel = componentModel;
     _resetInteractiveCommand = _componentModel.DefaultExportProvider
         .GetExports<IResetInteractiveCommand, ContentTypeMetadata>()
         .Where(resetInteractiveService => resetInteractiveService.Metadata.ContentTypes.Contains(_contentType))
         .SingleOrDefault();
 }
Пример #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GitExtCommands"/> 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 GitExtCommands(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            _package = package;
            _application = (DTE2)ServiceProvider.GetService(typeof(DTE));
            _commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            try
            {
                //RegisterCommand("Difftool_Selection", new ToolbarCommand<OpenWithDiftool>(runForSelection: true));
                RegisterCommand("Difftool", new ToolbarCommand<OpenWithDiftool>(), gitExtDiffCommand);
                //RegisterCommand("ShowFileHistory_Selection", new ToolbarCommand<FileHistory>(runForSelection: true));
                RegisterCommand("ShowFileHistory", new ToolbarCommand<FileHistory>(), gitExtHistoryCommand);
                //RegisterCommand("ResetChanges_Selection", new ToolbarCommand<Revert>(runForSelection: true));
                RegisterCommand("ResetChanges", new ToolbarCommand<Revert>(), gitExtResetFileCommand);
                RegisterCommand("Browse", new ToolbarCommand<Browse>(), gitExtBrowseCommand);
                RegisterCommand("Clone", new ToolbarCommand<Clone>(), gitExtCloneCommand);
                RegisterCommand("CreateNewRepository", new ToolbarCommand<Init>(), gitExtNewCommand);
                RegisterCommand("Commit", new ToolbarCommand<Commit>(), gitExtCommitCommand);
                RegisterCommand("Pull", new ToolbarCommand<Pull>(), gitExtPullCommand);
                RegisterCommand("Push", new ToolbarCommand<Push>(), gitExtPushCommand);
                RegisterCommand("Stash", new ToolbarCommand<Stash>(), gitExtStashCommand);
                RegisterCommand("Remotes", new ToolbarCommand<Remotes>(), gitExtRemotesCommand);
                RegisterCommand("GitIgnore", new ToolbarCommand<GitIgnore>(), gitExtGitIgnoreCommand);
                RegisterCommand("ApplyPatch", new ToolbarCommand<ApplyPatch>(), gitExtApplyPatchCommand);
                RegisterCommand("FormatPatch", new ToolbarCommand<FormatPatch>(), gitExtFormatPatchCommand);
                RegisterCommand("ViewChanges", new ToolbarCommand<ViewChanges>(), gitExtViewChangesCommand);
                RegisterCommand("FindFile", new ToolbarCommand<FindFile>(), gitExtFindFileCommand);
                RegisterCommand("SwitchBranch", new ToolbarCommand<SwitchBranch>(), gitExtCheckoutCommand);
                RegisterCommand("CreateBranch", new ToolbarCommand<CreateBranch>(), gitExtCreateBranchCommand);
                RegisterCommand("Merge", new ToolbarCommand<Merge>(), gitExtMergeCommand);
                RegisterCommand("Rebase", new ToolbarCommand<Rebase>(), gitExtRebaseCommand);
                RegisterCommand("SolveMergeConflicts", new ToolbarCommand<SolveMergeConflicts>(), gitExtSolveConflictsCommand);
                RegisterCommand("CherryPick", new ToolbarCommand<Cherry>(), gitExtCherryPickCommand);
                RegisterCommand("Bash", new ToolbarCommand<Bash>(), gitExtBashCommand);
                RegisterCommand("Settings", new ToolbarCommand<Settings>(), gitExtSettingsCommand);
                RegisterCommand("About", new ToolbarCommand<About>(), gitExtAboutCommand);
            }
            catch (Exception ex)
            {
                if (OutputPane != null)
                    OutputPane.OutputString("Error adding commands: " + ex);
            }
        }
Пример #29
0
        protected override void Initialize()
        {
            base.Initialize();

            _statusBar = GetService(typeof (SVsStatusbar)) as IVsStatusbar;
            _oleMenuCommandService = GetService(typeof (IMenuCommandService)) as OleMenuCommandService;
            _outputWindow = GetService(typeof (SVsOutputWindow)) as IVsOutputWindow;
            _sortIcon = (short) Constants.SBAI_General;

            if (_oleMenuCommandService != null)
            {
                var menuCommandId = new CommandID(GuidList.guidErsx_Net_VsixCmdSet, (int) PkgCmdIDList.sortResx);
                var menuItem = new OleMenuCommand(MenuItemClick, StatusChanged, BeforeContextMenuOpens, menuCommandId);
                _oleMenuCommandService.AddCommand(menuItem);
            }
        }
Пример #30
0
 private void AddAttachToCommand(OleMenuCommandService mcs, uint commandId, Func<GeneralOptionsPage, bool> isVisible, params string[] programsToAttach)
 {
     OleMenuCommand menuItemCommand = new OleMenuCommand(
         delegate(object sender, EventArgs e)
         {
             DTE dte = (DTE)this.GetService(typeof(DTE));
             foreach (Process process in dte.Debugger.LocalProcesses)
             {
                 if (programsToAttach.Any(p => process.Name.EndsWith(p)))
                 {
                     process.Attach();
                 }
             }
         },
         new CommandID(GuidList.guidAttachToCmdSet, (int)commandId));
     menuItemCommand.BeforeQueryStatus += (s, e) => menuItemCommand.Visible = isVisible((GeneralOptionsPage)this.GetDialogPage(typeof(GeneralOptionsPage)));
     mcs.AddCommand(menuItemCommand);
 }
Пример #31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConvertVBToCSCommand"/> 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="codeConversion"></param>
        /// <param name="commandService"></param>
        /// <remarks>Must be called on the UI thread due to VS 2017's implementation of AddCommand which calls GetService</remarks>
        private ConvertVBToCSCommand(CodeConverterPackage package, CodeConversion codeConversion, OleMenuCommandService commandService)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            this._package   = package ?? throw new ArgumentNullException(nameof(package));
            _codeConversion = codeConversion;

            if (commandService != null)
            {
                // Command in main menu
                var menuCommandId = new CommandID(CommandSet, MainMenuCommandId);
                var menuItem      = package.CreateCommand(CodeEditorMenuItemCallbackAsync, menuCommandId);
                menuItem.BeforeQueryStatus += MainEditMenuItem_BeforeQueryStatusAsync;
                commandService.AddCommand(menuItem);

                // Command in code editor's context menu
                var ctxMenuCommandId = new CommandID(CommandSet, CtxMenuCommandId);
                var ctxMenuItem      = package.CreateCommand(CodeEditorMenuItemCallbackAsync, ctxMenuCommandId);
                ctxMenuItem.BeforeQueryStatus += CodeEditorMenuItem_BeforeQueryStatusAsync;
                commandService.AddCommand(ctxMenuItem);

                // Command in project item context menu
                var projectItemCtxMenuCommandId = new CommandID(CommandSet, ProjectItemCtxMenuCommandId);
                var projectItemCtxMenuItem      = package.CreateCommand(ProjectItemMenuItemCallbackAsync, projectItemCtxMenuCommandId);
                projectItemCtxMenuItem.BeforeQueryStatus += ProjectItemMenuItem_BeforeQueryStatusAsync;
                commandService.AddCommand(projectItemCtxMenuItem);

                // Command in project context menu
                var projectCtxMenuCommandId = new CommandID(CommandSet, ProjectCtxMenuCommandId);
                var projectCtxMenuItem      = package.CreateCommand(SolutionOrProjectMenuItemCallbackAsync, projectCtxMenuCommandId);
                projectCtxMenuItem.BeforeQueryStatus += SolutionOrProjectMenuItem_BeforeQueryStatusAsync;
                commandService.AddCommand(projectCtxMenuItem);

                // Command in project context menu
                var solutionCtxMenuCommandId = new CommandID(CommandSet, SolutionCtxMenuCommandId);
                var solutionCtxMenuItem      = package.CreateCommand(SolutionOrProjectMenuItemCallbackAsync, solutionCtxMenuCommandId);
                solutionCtxMenuItem.BeforeQueryStatus += SolutionOrProjectMenuItem_BeforeQueryStatusAsync;
                commandService.AddCommand(solutionCtxMenuItem);
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // BasicSccProvider Package Implementation
        #region Package Members

        protected override void Initialize()
        {
            Trace.WriteLine(String.Format(CultureInfo.CurrentUICulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            //projects = new List<GitFileStatusTracker>();
            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.icmdSccCommandRefresh);
                var       menu = new MenuCommand(new EventHandler(OnRefreshCommand), cmd);
                mcs.AddCommand(menu);

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

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

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

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

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


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

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

                cmd  = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommandGitTortoise);
                menu = new MenuCommand(new EventHandler(OnTortoiseGitCommand), cmd);

                mcs.AddCommand(menu);
                for (int i = 0; i < GitToolCommands.GitExtCommands.Count; i++)
                {
                    cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdGitExtCommand1 + i);
                    var mc = new MenuCommand(new EventHandler(OnGitExtCommandExec), cmd);
                    mcs.AddCommand(mc);
                }

                for (int i = 0; i < GitToolCommands.GitTorCommands.Count; i++)
                {
                    cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdGitTorCommand1 + i);
                    var mc = new MenuCommand(new EventHandler(OnGitTorCommandExec), cmd);
                    mcs.AddCommand(mc);
                }

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

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

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

                cmd  = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdPendingChangesCommit);
                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.icmdPendingChangesSettings);
                menu = new MenuCommand(new EventHandler(OnSettings), cmd);
                mcs.AddCommand(menu);
            }



            ThreadHelper.ThrowIfNotOnUIThread();
            // 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);

            _OnIdleEvent.RegisterForIdleTimeCallbacks(GetGlobalService(typeof(SOleComponentManager)) as IOleComponentManager);
            //_OnIdleEvent.OnIdleEvent += new OnIdleEvent(sccService.UpdateNodesGlyphs);
            SetupStatusMenu();
        }
Пример #33
0
 /// <remarks>
 /// Must be called from UI thread
 /// </remarks>
 public static void Initialize(CodeConverterPackage package, OleMenuCommandService menuCommandService, CodeConversion codeConversion)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     Instance = new ConvertVBToCSCommand(package, codeConversion, menuCommandService);
 }