コード例 #1
0
        protected override void OnCreate()
        {
            _outputWindow = OutputWindowRedirector.GetGeneral(this);
            Debug.Assert(_outputWindow != null);
            _statusBar      = GetService(typeof(SVsStatusbar)) as IVsStatusbar;
            _uiShell        = GetService(typeof(SVsUIShell)) as IVsUIShell;
            _dte            = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
            _infoBarFactory = GetService(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory;

            object control = null;

            if (!CookiecutterClientProvider.IsCompatiblePythonAvailable())
            {
                ReportPrereqsEvent(false);
                control = new MissingDependencies();
            }
            else
            {
                ReportPrereqsEvent(true);
                string feedUrl = CookiecutterPackage.Instance.RecommendedFeed;
                if (string.IsNullOrEmpty(feedUrl))
                {
                    feedUrl = UrlConstants.DefaultRecommendedFeed;
                }

                _cookiecutterControl = new CookiecutterControl(_outputWindow, CookiecutterTelemetry.Current, new Uri(feedUrl), OpenGeneratedFolder, UpdateCommandUI);
                _cookiecutterControl.ContextMenuRequested += OnContextMenuRequested;
                control = _cookiecutterControl;
                _cookiecutterControl.InitializeAsync(CookiecutterPackage.Instance.CheckForTemplateUpdate).HandleAllExceptions(this, GetType()).DoNotWait();
            }

            Content = control;

            RegisterCommands(new Command[] {
                new HomeCommand(this),
                new RunCommand(this),
                new UpdateCommand(this),
                new CheckForUpdatesCommand(this),
                new GitHubCommand(this, PackageIds.cmdidLinkGitHubHome),
                new GitHubCommand(this, PackageIds.cmdidLinkGitHubIssues),
                new GitHubCommand(this, PackageIds.cmdidLinkGitHubWiki),
            }, PackageGuids.guidCookiecutterCmdSet);

            RegisterCommands(new Command[] {
                new DeleteInstalledTemplateCommand(this),
            }, VSConstants.GUID_VSStandardCommandSet97);

            base.OnCreate();

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

            if (CookiecutterPackage.Instance.ShowHelp)
            {
                AddInfoBar();
            }
        }
コード例 #2
0
        protected override void OnCreate()
        {
            _site = (IServiceProvider)this;

            _outputWindow = OutputWindowRedirector.GetGeneral(CookiecutterPackage.Instance);
            Debug.Assert(_outputWindow != null);
            _statusBar      = _site.GetService(typeof(SVsStatusbar)) as IVsStatusbar;
            _uiShell        = _site.GetService(typeof(SVsUIShell)) as IVsUIShell;
            _dte            = _site.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
            _infoBarFactory = _site.GetService(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory;

            object control = null;

            _missingDependencies = CheckDependencies(out _missingGit, out _missingPython, out _missingCookiecutter);
            if (_missingDependencies)
            {
                control = new MissingDependencies();
            }
            else
            {
                string feedUrl = CookiecutterPackage.Instance.RecommendedFeed;
                if (string.IsNullOrEmpty(feedUrl))
                {
                    feedUrl = UrlConstants.DefaultRecommendedFeed;
                }

                _cookiecutterControl = new CookiecutterControl(_outputWindow, new Uri(feedUrl), OpenGeneratedFolder, UpdateCommandUI);
                _cookiecutterControl.ContextMenuRequested += OnContextMenuRequested;
                control = _cookiecutterControl;
            }

            Content = control;

            RegisterCommands(new Command[] {
                new HomeCommand(this),
                new RunCommand(this),
                new GitHubCommand(this, PackageIds.cmdidLinkGitHubHome),
                new GitHubCommand(this, PackageIds.cmdidLinkGitHubIssues),
                new GitHubCommand(this, PackageIds.cmdidLinkGitHubWiki),
            }, PackageGuids.guidCookiecutterCmdSet);

            RegisterCommands(new Command[] {
                new DeleteInstalledTemplateCommand(this),
            }, VSConstants.GUID_VSStandardCommandSet97);

            base.OnCreate();

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

            if (CookiecutterPackage.Instance.ShowHelp || _missingDependencies)
            {
                AddInfoBar();
            }
        }