private IVsThreadedWaitDialog3 CreateDialog(IVsThreadedWaitDialogFactory dialogFactory)
        {
            Marshal.ThrowExceptionForHR(dialogFactory.CreateInstance(out IVsThreadedWaitDialog2 dialog2));
            if (dialog2 == null)
            {
                throw new ArgumentNullException(nameof(dialog2));
            }

            var dialog3  = (IVsThreadedWaitDialog3)dialog2;
            var callback = new Callback(this);

            dialog3.StartWaitDialogWithCallback(
                szWaitCaption: _title,
                szWaitMessage: _message,
                szProgressText: null,
                varStatusBmpAnim: null,
                szStatusBarText: null,
                fIsCancelable: _allowCancel,
                iDelayToShowDialog: DelayToShowDialogSecs,
                fShowProgress: false,
                iTotalSteps: 0,
                iCurrentStep: 0,
                pCallback: callback);

            return(dialog3);
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public override async TPL.Task Execute(Project project)
        {
            if (await this.HasUserAcceptedWarningMessage(Resources.Resources.NugetUpdate_Title, Resources.Resources.NugetUpdate_Text))
            {
                // Creates dialog informing the user to wait for the installation to finish
                IVsThreadedWaitDialogFactory twdFactory = await this.Package.GetServiceAsync(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory;

                IVsThreadedWaitDialog2 dialog = null;
                twdFactory?.CreateInstance(out dialog);

                string title = Resources.Resources.NugetUpdate_WaitTitle;
                string text  = Resources.Resources.NugetUpdate_WaitText;
                dialog?.StartWaitDialog(title, text, null, null, null, 0, false, true);

                try
                {
                    await this.Successor.Execute(project);
                }
                finally
                {
                    // Closes the wait dialog. If the dialog failed, does nothing
                    dialog?.EndWaitDialog(out int canceled);
                }
            }
        }
Ejemplo n.º 3
0
 internal PackageRestoreManager(
     DTE dte,
     ISolutionManager solutionManager,
     IFileSystemProvider fileSystemProvider,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     IVsPackageInstallerEvents packageInstallerEvents,
     IPackageRepository localCacheRepository,
     IVsThreadedWaitDialogFactory waitDialogFactory,
     ISettings settings)
 {
     Debug.Assert(solutionManager != null);
     _dte = dte;
     _fileSystemProvider       = fileSystemProvider;
     _solutionManager          = solutionManager;
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider    = packageSourceProvider;
     _waitDialogFactory        = waitDialogFactory;
     _packageManagerFactory    = packageManagerFactory;
     _localCacheRepository     = localCacheRepository;
     _settings = settings;
     _solutionManager.ProjectAdded   += OnProjectAdded;
     _solutionManager.SolutionOpened += OnSolutionOpenedOrClosed;
     _solutionManager.SolutionClosed += OnSolutionOpenedOrClosed;
     packageInstallerEvents.PackageReferenceAdded += OnPackageReferenceAdded;
 }
 internal PackageRestoreManager(
     DTE dte,
     ISolutionManager solutionManager,
     IFileSystemProvider fileSystemProvider,
     IPackageRepositoryFactory packageRepositoryFactory,
     IVsPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     IVsPackageInstallerEvents packageInstallerEvents,
     IPackageRepository localCacheRepository,
     IVsThreadedWaitDialogFactory waitDialogFactory,
     ISettings settings)
 {
     Debug.Assert(solutionManager != null);
     _dte = dte;
     _fileSystemProvider = fileSystemProvider;
     _solutionManager = solutionManager;
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider = packageSourceProvider;
     _waitDialogFactory = waitDialogFactory;
     _packageManagerFactory = packageManagerFactory;
     _localCacheRepository = localCacheRepository;
     _settings = settings;
     _solutionManager.ProjectAdded += OnProjectAdded;
     _solutionManager.SolutionOpened += OnSolutionOpenedOrClosed;
     _solutionManager.SolutionClosed += OnSolutionOpenedOrClosed;
     packageInstallerEvents.PackageReferenceAdded += OnPackageReferenceAdded;
 }
Ejemplo n.º 5
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>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            // Query service asynchronously from the UI thread


            //var dte = await GetServiceAsync(typeof(EnvDTE.DTE)) as EnvDTE.DTE;

            ITextTemplating textTemplating = null;

            EnvDTE80.DTE2 dte2 = null;
            IVsThreadedWaitDialogFactory dialogFactory = null;

            dte2 = await GetServiceAsync(typeof(SDTE)) as EnvDTE80.DTE2;

            textTemplating = await GetServiceAsync(typeof(STextTemplating)) as ITextTemplating;

            dialogFactory = await GetServiceAsync(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory;


            await CS2REACTJS.Commands.CrtDbContextCommand.InitializeAsync(this, dte2, textTemplating, dialogFactory);

            await CS2REACTJS.Commands.CrtViewModelCommand.InitializeAsync(this, dte2, textTemplating, dialogFactory);

            await CS2REACTJS.Commands.CrtWebApiServiceCommand.InitializeAsync(this, dte2, textTemplating, dialogFactory);

            await CS2REACTJS.Commands.CrtJavaScriptsCommand.InitializeAsync(this, dte2, textTemplating, dialogFactory);

            await CS2REACTJS.Commands.CrtFeatureScriptsCommand.InitializeAsync(this, dte2, textTemplating, dialogFactory);
        }
Ejemplo n.º 6
0
        static WaitDialog Create()
        {
            if (factory == null)
            {
                factory = (IVsThreadedWaitDialogFactory)Package
                          .GetGlobalService(typeof(SVsThreadedWaitDialogFactory));
                if (factory == null)
                {
                    return(null);
                }
            }

            IVsThreadedWaitDialog2 vsWaitDialog = null;

            factory.CreateInstance(out vsWaitDialog);
            if (vsWaitDialog == null)
            {
                return(null);
            }

            return(new WaitDialog
            {
                VsWaitDialog = vsWaitDialog,
                Running = true,
            });
        }
Ejemplo n.º 7
0
        IVsThreadedWaitDialog3 CreateDialog(IVsThreadedWaitDialogFactory dialogFactory)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Marshal.ThrowExceptionForHR(dialogFactory.CreateInstance(out var dialog2));

            var dialog3 = (IVsThreadedWaitDialog3)dialog2;

            var callback = new Callback(this);

            dialog3.StartWaitDialogWithCallback(
                szWaitCaption: _title,
                szWaitMessage: _message,
                szProgressText: null,
                varStatusBmpAnim: null,
                szStatusBarText: null,
                fIsCancelable: _allowCancel,
                iDelayToShowDialog: DelayToShowDialogSecs,
                fShowProgress: false,
                iTotalSteps: 0,
                iCurrentStep: 0,
                pCallback: callback);

            return(dialog3);
        }
Ejemplo n.º 8
0
        private IVsThreadedWaitDialog3 CreateDialog(
            IVsThreadedWaitDialogFactory dialogFactory, bool showProgress)
        {
            Marshal.ThrowExceptionForHR(dialogFactory.CreateInstance(out var dialog2));
            Contract.ThrowIfNull(dialog2);

            var dialog3 = (IVsThreadedWaitDialog3)dialog2;

            var callback = new Callback(this);

            dialog3.StartWaitDialogWithCallback(
                szWaitCaption: _title,
                szWaitMessage: _message,
                szProgressText: null,
                varStatusBmpAnim: null,
                szStatusBarText: null,
                fIsCancelable: _allowCancel,
                iDelayToShowDialog: DelayToShowDialogSecs,
                fShowProgress: showProgress,
                iTotalSteps: this.ProgressTracker.TotalItems,
                iCurrentStep: this.ProgressTracker.CompletedItems,
                pCallback: callback);

            return dialog3;
        }
Ejemplo n.º 9
0
        private async Task <bool> DownloadIWYUWithProgressBar(string executablePath, IVsThreadedWaitDialogFactory dialogFactory)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsThreadedWaitDialog2 progressDialog;

            dialogFactory.CreateInstance(out progressDialog);
            if (progressDialog == null)
            {
                Output.Instance.WriteLine("Failed to get create wait dialog.");
                return(false);
            }

            progressDialog.StartWaitDialogWithPercentageProgress(
                szWaitCaption: "Include Toolbox - Downloading include-what-you-use",
                szWaitMessage: "", // comes in later.
                szProgressText: null,
                varStatusBmpAnim: null,
                szStatusBarText: "Downloading include-what-you-use",
                fIsCancelable: true,
                iDelayToShowDialog: 0,
                iTotalSteps: 100,
                iCurrentStep: 0);

            var cancellationToken = new System.Threading.CancellationTokenSource();

            try
            {
                await IWYUDownload.DownloadIWYU(executablePath, delegate(string section, string status, float percentage)
                {
                    ThreadHelper.ThrowIfNotOnUIThread();

                    bool canceled;
                    progressDialog.UpdateProgress(
                        szUpdatedWaitMessage: section,
                        szProgressText: status,
                        szStatusBarText: $"Downloading include-what-you-use - {section} - {status}",
                        iCurrentStep: (int)(percentage * 100),
                        iTotalSteps: 100,
                        fDisableCancel: true,
                        pfCanceled: out canceled);
                    if (canceled)
                    {
                        cancellationToken.Cancel();
                    }
                }, cancellationToken.Token);
            }
            catch (Exception e)
            {
                await Output.Instance.ErrorMsg("Failed to download include-what-you-use: {0}", e);

                return(false);
            }
            finally
            {
                progressDialog.EndWaitDialog();
            }

            return(true);
        }
Ejemplo n.º 10
0
        public static WaitDialog Start(
            string caption,
            string message,
            string progressText      = null,
            string statusBarText     = null,
            int delay                = 0,
            bool isCancelable        = false,
            bool showMarqueeProgress = true,
            IVsThreadedWaitDialogFactory dialogFactory = null)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var dialog = Create(dialogFactory);

            if (dialog == null)
            {
                return(null);
            }

            var res = dialog.VsWaitDialog.StartWaitDialog(caption, message, progressText,
                                                          null, statusBarText, delay, isCancelable, showMarqueeProgress);

            if (res != VSConstants.S_OK)
            {
                return(null);
            }

            return(dialog);
        }
Ejemplo n.º 11
0
        public bool InstallDebugPackage(IVsOutputWindowPane outputPane, IVsThreadedWaitDialogFactory dlgFactory /*uint debugTargetTypeId,*/)
        {
            bool   isInstalled;
            string source;
            string destination;
            string ondemandPath = ToolsPathInfo.OndemandFolderPath;

            this.outputPane = outputPane;
            if (this.outputPane != null)
            {
                this.outputPane.Activate();
            }

            // Check the lldb package was installed in previous or not.
            GetPkgInstalledStatus(out isInstalled);
            if (!isInstalled)
            {
                source      = ondemandPath + @"\" + GetLldbPkgName();
                destination = GetLldbDestPath();
                if (!PushDebuggerPackage(source, destination))
                {
                    ErrorMessage = "Failed : Debugger Push from " + source + " to " + destination + ".\n";
                }

                // Install Debug package

                if (!DeployDebuggerPackage(destination))
                {
                    ErrorMessage = "Failed : Debugger Installation on " + destination + " .\n";
                }
            }

            ErrorMessage = string.Empty;
            return(true);
        }
Ejemplo n.º 12
0
        static WaitDialog Create(IVsThreadedWaitDialogFactory dialogFactory)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (factory == null)
            {
                factory = dialogFactory ?? VsServiceProvider
                          .GetService <SVsThreadedWaitDialogFactory, IVsThreadedWaitDialogFactory>();
                if (factory == null)
                {
                    return(null);
                }
            }

            factory.CreateInstance(out IVsThreadedWaitDialog2 vsWaitDialog);
            if (vsWaitDialog == null)
            {
                return(null);
            }

            return(new WaitDialog
            {
                VsWaitDialog = vsWaitDialog,
                Running = true,
            });
        }
Ejemplo n.º 13
0
        public static WaitDialog StartWithProgress(
            string caption,
            string message,
            int totalSteps,
            int currentStep      = 0,
            string progressText  = null,
            string statusBarText = null,
            int delay            = 0,
            bool isCancelable    = false,
            IVsThreadedWaitDialogFactory dialogFactory = null)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var dialog = Create(dialogFactory);

            if (dialog == null)
            {
                return(null);
            }

            var res = dialog.VsWaitDialog.StartWaitDialogWithPercentageProgress(
                caption, message, progressText, null, statusBarText,
                isCancelable, delay, totalSteps, currentStep);

            if (res != VSConstants.S_OK)
            {
                return(null);
            }

            return(dialog);
        }
Ejemplo n.º 14
0
        private IVsThreadedWaitDialog3 CreateDialog(
            IVsThreadedWaitDialogFactory dialogFactory,
            bool showProgress
            )
        {
            Marshal.ThrowExceptionForHR(dialogFactory.CreateInstance(out var dialog2));
            Contract.ThrowIfNull(dialog2);

            var dialog3 = (IVsThreadedWaitDialog3)dialog2;

            var callback = new Callback(this);

            dialog3.StartWaitDialogWithCallback(
                szWaitCaption: _title,
                szWaitMessage: this.ProgressTracker.Description ?? _message,
                szProgressText: null,
                varStatusBmpAnim: null,
                szStatusBarText: null,
                fIsCancelable: _allowCancel,
                iDelayToShowDialog: DelayToShowDialogSecs,
                fShowProgress: showProgress,
                iTotalSteps: this.ProgressTracker.TotalItems,
                iCurrentStep: this.ProgressTracker.CompletedItems,
                pCallback: callback
                );

            return(dialog3);
        }
Ejemplo n.º 15
0
        public ThreadedWaitDialogProgressScope(string waitCaption)
        {
            IVsThreadedWaitDialogFactory factory =
                (IVsThreadedWaitDialogFactory)Package.GetGlobalService(typeof(SVsThreadedWaitDialogFactory));

            Session = factory.StartWaitDialog(waitCaption);
        }
Ejemplo n.º 16
0
        static WaitDialog Create()
        {
            if (factory == null)
            {
                factory = VsServiceProvider
                          .GetService <SVsThreadedWaitDialogFactory, IVsThreadedWaitDialogFactory>();
                if (factory == null)
                {
                    return(null);
                }
            }

            IVsThreadedWaitDialog2 vsWaitDialog = null;

            factory.CreateInstance(out vsWaitDialog);
            if (vsWaitDialog == null)
            {
                return(null);
            }

            return(new WaitDialog
            {
                VsWaitDialog = vsWaitDialog,
                Running = true,
            });
        }
Ejemplo n.º 17
0
 // Test constructor
 internal DefaultWaitDialogFactory(
     JoinableTaskContext joinableTaskContext,
     IVsThreadedWaitDialogFactory waitDialogFactory)
 {
     _waitDialogFactory   = waitDialogFactory;
     _joinableTaskFactory = joinableTaskContext.Factory;
 }
 public VisualStudioGitService(IServiceProvider serviceProvider)
 {
     _dialogFactory      = serviceProvider.GetService(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory;
     _gitCommandExecuter = new GitCommandExecuter(serviceProvider);
     _teamExplorer       = serviceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
     _dte           = serviceProvider.GetService(typeof(DTE)) as DTE;
     _vsDiffService = serviceProvider.GetService(typeof(SVsDifferenceService)) as IVsDifferenceService;
 }
Ejemplo n.º 19
0
 public BatchProcessingViewModel(DTE2 dte, ITextTemplating textTemplating, IVsThreadedWaitDialogFactory dialogFactory, string t4RootFolder, string batchRootFolder)
 {
     this.Dte             = dte;
     this.TextTemplating  = textTemplating;
     this.T4RootFolder    = t4RootFolder;
     this.BatchRootFolder = batchRootFolder;
     this.DialogFactory   = dialogFactory;
 }
Ejemplo n.º 20
0
 public static void Initialize(string AppTitle, DTE2 dte, IVsThreadedWaitDialogFactory dialogFactory, IVsOutputWindow outputWindow, Func <ChartControl> getpanewindow)
 {
     QCPluginUtilities.AppTitle      = AppTitle;
     QCPluginUtilities.dialogFactory = dialogFactory;
     QCPluginUtilities.dte           = dte;
     QCPluginUtilities.outputWindow  = outputWindow;
     QCPluginUtilities.InstallPath   = RetrieveAssemblyDirectory();
     QCPluginUtilities.GetPaneWindow = getpanewindow;
 }
 public VisualStudioWaitContext(IVsThreadedWaitDialogFactory dialogFactory,
                                string title,
                                string message,
                                bool allowCancel) {
     _title                   = title;
     _message                 = message;
     _allowCancel             = allowCancel;
     _cancellationTokenSource = new CancellationTokenSource();
     _dialog                  = CreateDialog(dialogFactory);
 }
        public WaitDialogRestorer(IPackageRestorer restorer, IVsThreadedWaitDialogFactory waitDialogFactory)
        {
            if (restorer == null)
                throw new ArgumentNullException("restorer");
            if (waitDialogFactory == null)
                throw new ArgumentNullException("waitDialogFactory");

            this.restorer = restorer;
            this.waitDialogFactory = waitDialogFactory;
        }
Ejemplo n.º 23
0
        public MainWindowVm2WebApi(DTE2 dte, ITextTemplating textTemplating, IVsThreadedWaitDialogFactory dialogFactory) : base(dte, textTemplating, dialogFactory)
        {
            InvitationViewModel InvitationVM = new InvitationViewModel();

            InvitationVM.WizardName            = "#3 WebApi Wizard";
            InvitationVM.IsReady.IsReadyEvent += InvitationViewModel_IsReady;
            this.InvitationUC       = new UserControlInvitation(InvitationVM);
            this.CurrentUserControl = this.InvitationUC;
            InvitationVM.DoAnalise(dte);
        }
Ejemplo n.º 24
0
        public MainWindowEf2Vm(DTE2 dte, ITextTemplating textTemplating, IVsThreadedWaitDialogFactory dialogFactory) : base(dte, textTemplating, dialogFactory)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            InvitationViewModel InvitationVM = new InvitationViewModel();

            InvitationVM.WizardName            = "#2 View Wizard";
            InvitationVM.IsReady.IsReadyEvent += InvitationViewModel_IsReady;
            this.InvitationUC       = new UserControlInvitation(InvitationVM);
            this.CurrentUserControl = this.InvitationUC;
            InvitationVM.DoAnalise(dte);
        }
Ejemplo n.º 25
0
 public SelectFolderViewModel(DTE2 dte, ITextTemplating textTemplating, IVsThreadedWaitDialogFactory dialogFactory, SolutionCodeElement selectedDbContext, string rootFolder, string JavaScriptsTmplst, string BatchJavaScriptsTmplst) : base()
 {
     this.T4Folders         = new ObservableCollection <string>();
     this.Dte               = dte;
     this.SelectedDbContext = selectedDbContext;
     this.DialogFactory     = dialogFactory;
     this.TextTemplating    = textTemplating;
     this.T4RootFolder      = Path.Combine(rootFolder, JavaScriptsTmplst);
     this.BatchRootFolder   = Path.Combine(rootFolder, BatchJavaScriptsTmplst);
     this.OnContextChanged  = new ContextChangedService();
 }
        public VisualStudioWaitContext(IVsThreadedWaitDialogFactory waitDialogFactory, string title, string message, bool allowCancel, int totalSteps = 0)
        {
            _title      = title;
            _message    = message;
            _totalSteps = totalSteps;

            if (allowCancel)
            {
                _cancellationTokenSource = new CancellationTokenSource();
            }

            _dialog = CreateDialog(waitDialogFactory);
        }
Ejemplo n.º 27
0
        public VisualStudioWaitContext(IVsThreadedWaitDialogFactory dialogFactory,
                                       string title,
                                       string message,
                                       bool allowCancel)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            _title                   = title;
            _message                 = message;
            _allowCancel             = allowCancel;
            _cancellationTokenSource = new CancellationTokenSource();
            _dialog                  = CreateDialog(dialogFactory);
        }
Ejemplo n.º 28
0
        private void UpdateSlowCheetah(Project project)
        {
            // This is done on the UI thread because changes are made to the project file,
            // causing it to be reloaded. To avoid conflicts with NuGet installation,
            // the update is done sequentially
            if (this.HasUserAcceptedWarningMessage(Resources.Resources.NugetUpdate_Title, Resources.Resources.NugetUpdate_Text))
            {
                // Creates dialog informing the user to wait for the installation to finish
                IVsThreadedWaitDialogFactory twdFactory = this.package.GetService(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory;
                IVsThreadedWaitDialog2       dialog     = null;
                twdFactory?.CreateInstance(out dialog);

                string title = Resources.Resources.NugetUpdate_WaitTitle;
                string text  = Resources.Resources.NugetUpdate_WaitText;
                dialog?.StartWaitDialog(title, text, null, null, null, 0, false, true);
                try
                {
                    // Installs the latest version of the SlowCheetah NuGet package
                    var componentModel = (IComponentModel)this.package.GetService(typeof(SComponentModel));
                    if (this.IsSlowCheetahInstalled(project))
                    {
                        IVsPackageUninstaller packageUninstaller = componentModel.GetService <IVsPackageUninstaller>();
                        packageUninstaller.UninstallPackage(project, PackageName, true);
                    }

                    IVsPackageInstaller2 packageInstaller = componentModel.GetService <IVsPackageInstaller2>();
                    packageInstaller.InstallLatestPackage(null, project, PackageName, false, false);

                    project.Save();
                    ProjectRootElement projectRoot = ProjectRootElement.Open(project.FullName);
                    foreach (ProjectPropertyGroupElement propertyGroup in projectRoot.PropertyGroups.Where(pg => pg.Label.Equals("SlowCheetah")))
                    {
                        projectRoot.RemoveChild(propertyGroup);
                    }

                    foreach (ProjectImportElement import in projectRoot.Imports.Where(i => i.Label == "SlowCheetah" || i.Project == "$(SlowCheetahTargets)"))
                    {
                        projectRoot.RemoveChild(import);
                    }

                    projectRoot.Save();
                }
                finally
                {
                    // Closes the wait dialog. If the dialog failed, does nothing
                    int canceled;
                    dialog?.EndWaitDialog(out canceled);
                }
            }
        }
Ejemplo n.º 29
0
        public WaitDialogRestorer(IPackageRestorer restorer, IVsThreadedWaitDialogFactory waitDialogFactory)
        {
            if (restorer == null)
            {
                throw new ArgumentNullException("restorer");
            }
            if (waitDialogFactory == null)
            {
                throw new ArgumentNullException("waitDialogFactory");
            }

            this.restorer          = restorer;
            this.waitDialogFactory = waitDialogFactory;
        }
Ejemplo n.º 30
0
        public VisualStudioWaitContext(
            IGlobalOperationNotificationService notificationService,
            IVsThreadedWaitDialogFactory dialogFactory,
            string title,
            string message,
            bool allowCancel)
        {
            _title                   = title;
            _message                 = message;
            _allowCancel             = allowCancel;
            _cancellationTokenSource = new CancellationTokenSource();

            _dialog       = CreateDialog(dialogFactory);
            _registration = notificationService.Start(title);
        }
        public VisualStudioWaitContext(
            IGlobalOperationNotificationService notificationService,
            IVsThreadedWaitDialogFactory dialogFactory,
            string title,
            string message,
            bool allowCancel)
        {
            _title = title;
            _message = message;
            _allowCancel = allowCancel;
            _cancellationTokenSource = new CancellationTokenSource();

            _dialog = CreateDialog(dialogFactory);
            _registration = notificationService.Start(title);
        }
Ejemplo n.º 32
0
        public CLIExecutor(Process executable, WaitDialogDescription dialogDesc, ProcessDataReceiverDelegate OnProcessUpdated, ProcessTerminatorDelegate OnProcessCanceled, ProcessTerminatorDelegate OnProcessExited)
        {
            this.executable        = executable;
            this.dialogDesc        = dialogDesc;
            this.OnProcessExited   = OnProcessExited;
            this.OnProcessUpdated  = OnProcessUpdated;
            this.OnProcessCanceled = OnProcessCanceled;

            IVsThreadedWaitDialogFactory dlgFactory = Package.GetGlobalService(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory;

            if (dlgFactory != null)
            {
                dlgFactory.CreateInstance(out waitDialog);
            }
        }
Ejemplo n.º 33
0
        public DefaultWaitDialogFactory(JoinableTaskContext joinableTaskContext)
        {
            if (joinableTaskContext is null)
            {
                throw new ArgumentNullException(nameof(joinableTaskContext));
            }

            _waitDialogFactory = (IVsThreadedWaitDialogFactory)Shell.Package.GetGlobalService(typeof(SVsThreadedWaitDialogFactory));
            if (_waitDialogFactory == null)
            {
                throw new ArgumentNullException(nameof(_waitDialogFactory));
            }

            _joinableTaskFactory = joinableTaskContext.Factory;
        }
Ejemplo n.º 34
0
 public MainWindowBase(DTE2 dte, ITextTemplating textTemplating, IVsThreadedWaitDialogFactory dialogFactory)
 {
     CancelClicked       = new ButtonClickedNotificationService();
     this.Dte            = dte;
     this.TextTemplating = textTemplating;
     this.DialogFactory  = dialogFactory;
     try
     {
         DefineDestinationProject();
     }
     catch
     {
         ;
     }
 }
        public IDisposable ShowProgressDialog(string caption, string message, int startDelay)
        {
            IVsThreadedWaitDialog2       vsThreadedWaitDialog2;
            IVsThreadedWaitDialogFactory service = this._serviceProvider.GetService(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory;

            Marshal.ThrowExceptionForHR(service.CreateInstance(out vsThreadedWaitDialog2));
            string str = null;
            int    num = vsThreadedWaitDialog2.StartWaitDialog(caption, message, null, null, str, startDelay, false, true);

            Marshal.ThrowExceptionForHR(num);
            Cursor overrideCursor = Mouse.OverrideCursor;

            Mouse.OverrideCursor = Cursors.Wait;
            return(new VsShellDialogService.ProgressDialog(vsThreadedWaitDialog2, overrideCursor));
        }
Ejemplo n.º 36
0
        internal PackageRestoreManager(
            DTE dte,
            ISolutionManager solutionManager,
            IFileSystemProvider fileSystemProvider,
            IPackageRepositoryFactory packageRepositoryFactory,
            IVsPackageManagerFactory packageManagerFactory,
            IVsThreadedWaitDialogFactory waitDialogFactory)
        {

            Debug.Assert(solutionManager != null);
            _dte = dte;
            _fileSystemProvider = fileSystemProvider;
            _solutionManager = solutionManager;
            _packageRepositoryFactory = packageRepositoryFactory;
            _waitDialogFactory = waitDialogFactory;
            _packageManagerFactory = packageManagerFactory;
            _solutionManager.ProjectAdded += OnProjectAdded;
            _solutionManager.SolutionOpened += OnSolutionOpenedOrClosed;
            _solutionManager.SolutionClosed += OnSolutionOpenedOrClosed;
        }
Ejemplo n.º 37
0
        public VisualStudioWaitContext(
            IGlobalOperationNotificationService notificationService,
            IVsThreadedWaitDialogFactory dialogFactory,
            string title,
            string message,
            bool allowCancel, 
            bool showProgress)
        {
            _title = title;
            _message = message;
            _allowCancel = allowCancel;
            _cancellationTokenSource = new CancellationTokenSource();

            this.ProgressTracker = showProgress
                ? new ProgressTracker((_1, _2) => UpdateDialog())
                : new ProgressTracker();

            _dialog = CreateDialog(dialogFactory, showProgress);
            _registration = notificationService.Start(title);
        }
        IVsThreadedWaitDialog3 CreateDialog(IVsThreadedWaitDialogFactory dialogFactory) {
            IVsThreadedWaitDialog2 dialog2;
            Marshal.ThrowExceptionForHR(dialogFactory.CreateInstance(out dialog2));

            var dialog3 = (IVsThreadedWaitDialog3) dialog2;

            var callback = new Callback(this);

            dialog3.StartWaitDialogWithCallback(
                szWaitCaption     : _title,
                szWaitMessage     : _message,
                szProgressText    : null,
                varStatusBmpAnim  : null,
                szStatusBarText   : null,
                fIsCancelable     : _allowCancel,
                iDelayToShowDialog: DelayToShowDialogSecs,
                fShowProgress     : false,
                iTotalSteps       : 0,
                iCurrentStep      : 0,
                pCallback         : callback);

            return dialog3;
        }
        private PackageRestoreManager CreateInstance(
            DTE dte = null,
            ISolutionManager solutionManager = null,
            IFileSystemProvider fileSystemProvider = null,
            IPackageRepositoryFactory packageRepositoryFactory = null,
            IVsThreadedWaitDialogFactory waitDialogFactory = null,
            IVsPackageManagerFactory packageManagerFactory = null,
            IPackageRepository localCache = null,
            IPackageSourceProvider packageSourceProvider = null,
            ISettings settings = null)
        {

            if (dte == null)
            {
                dte = new Mock<DTE>().Object;
            }

            if (solutionManager == null)
            {
                solutionManager = new Mock<ISolutionManager>().Object;
            }

            if (fileSystemProvider == null)
            {
                fileSystemProvider = new Mock<IFileSystemProvider>().Object;
            }

            if (packageRepositoryFactory == null)
            {
                packageRepositoryFactory = new Mock<IPackageRepositoryFactory>().Object;
            }

            if (waitDialogFactory == null)
            {
                var mockWaitDialogFactory = new Mock<IVsThreadedWaitDialogFactory>();
                var mockWaitDialog = new Mock<IVsThreadedWaitDialog2>();
                mockWaitDialog.Setup(p => p.StartWaitDialog(
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<object>(),
                    It.IsAny<string>(),
                    It.IsAny<int>(),
                    It.IsAny<bool>(),
                    It.IsAny<bool>()));
                int canceled;
                mockWaitDialog.Setup(p => p.EndWaitDialog(out canceled)).Returns(0);
                var waitDialog = mockWaitDialog.Object;
                mockWaitDialogFactory.Setup(p => p.CreateInstance(out waitDialog)).Returns(0);

                waitDialogFactory = mockWaitDialogFactory.Object;
            }

            if (packageManagerFactory == null)
            {
                packageManagerFactory = new Mock<IVsPackageManagerFactory>().Object;
            }

            if (localCache == null)
            {
                localCache = new MockPackageRepository();
            }

            if (packageSourceProvider == null)
            {
                packageSourceProvider = new Mock<IPackageSourceProvider>().Object;
            }

            if (settings == null)
            {
                settings = Mock.Of<ISettings>();
            }

            return new PackageRestoreManager(
                dte,
                solutionManager,
                fileSystemProvider,
                packageRepositoryFactory,
                packageSourceProvider,
                packageManagerFactory, 
                new VsPackageInstallerEvents(),
                localCache,
                waitDialogFactory,
                settings);
        }