Esempio n. 1
0
        async Task InitializeMenus()
        {
            if (!ExportForVisualStudioProcessAttribute.IsVisualStudioProcess())
            {
                log.Warning("Don't initialize menus for non-Visual Studio process");
                return;
            }

            var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));

            Assumes.Present(componentModel);

            var exports  = componentModel.DefaultExportProvider;
            var commands = new IVsCommandBase[]
            {
                exports.GetExportedValue <INextInlineCommentCommand>(),
                exports.GetExportedValue <IPreviousInlineCommentCommand>(),
                exports.GetExportedValue <IToggleInlineCommentMarginCommand>()
            };

            await JoinableTaskFactory.SwitchToMainThreadAsync();

            var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));

            Assumes.Present(menuService);

            menuService.AddCommands(commands);
        }
        protected override void OnActivate(CancelEventArgs e)
        {
            if (!ExportForVisualStudioProcessAttribute.IsVisualStudioProcess())
            {
                log.Warning("Don't activate options for non-Visual Studio process");
                return;
            }

            base.OnActivate(e);
            packageSettings = Services.DefaultExportProvider.GetExportedValue <IPackageSettings>();
            LoadSettings();
        }
        protected override void OnApply(PageApplyEventArgs args)
        {
            if (!ExportForVisualStudioProcessAttribute.IsVisualStudioProcess())
            {
                log.Warning("Don't apply options for non-Visual Studio process");
                return;
            }

            if (args.ApplyBehavior == ApplyKind.Apply)
            {
                SaveSettings();
            }

            base.OnApply(args);
        }
Esempio n. 4
0
        async Task InitializeMenus()
        {
            IVsCommandBase[] commands;
            if (ExportForVisualStudioProcessAttribute.IsVisualStudioProcess())
            {
                var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
                Assumes.Present(componentModel);

                var exports = componentModel.DefaultExportProvider;
                commands = new IVsCommandBase[]
                {
                    exports.GetExportedValue <IAddConnectionCommand>(),
                    exports.GetExportedValue <IBlameLinkCommand>(),
                    exports.GetExportedValue <ICopyLinkCommand>(),
                    exports.GetExportedValue <ICreateGistCommand>(),
                    exports.GetExportedValue <ICreateGistEnterpriseCommand>(),
                    exports.GetExportedValue <IOpenLinkCommand>(),
                    exports.GetExportedValue <IOpenPullRequestsCommand>(),
                    exports.GetExportedValue <IShowCurrentPullRequestCommand>(),
                    exports.GetExportedValue <IShowGitHubPaneCommand>(),
                    exports.GetExportedValue <IGoToSolutionOrPullRequestFileCommand>(),
                    exports.GetExportedValue <ISyncSubmodulesCommand>(),
                    exports.GetExportedValue <IOpenFromUrlCommand>(),
                    exports.GetExportedValue <IOpenFromClipboardCommand>()
                };
            }
            else
            {
                // Show info message box when executed in non-Visual Studio process
                var message = Resources.BlendDialogText;
                commands = new IVsCommandBase[]
                {
                    new ShowMessageBoxCommand(AddConnectionCommand.CommandSet, AddConnectionCommand.CommandId, this, message),
                    new ShowMessageBoxCommand(ShowGitHubPaneCommand.CommandSet, ShowGitHubPaneCommand.CommandId, this, message)
                };
            }

            await JoinableTaskFactory.SwitchToMainThreadAsync();

            var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));

            Assumes.Present(menuService);

            menuService.AddCommands(commands);
        }
Esempio n. 5
0
        protected async override Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            if (!ExportForVisualStudioProcessAttribute.IsVisualStudioProcess())
            {
                // Don't activate 'UIContext_Git' for non-Visual Studio process
                return;
            }

            var gitExt = (IVSGitExt) await GetServiceAsync(typeof(IVSGitExt));

            var context = UIContext.FromUIContextGuid(new Guid(Guids.UIContext_Git));

            RefreshContext(context, gitExt);
            gitExt.ActiveRepositoriesChanged += () =>
            {
                RefreshContext(context, gitExt);
            };
        }