static public void Run(IServiceProvider serviceProvider, IVsStatusbar statusbar) { var dte = (DTE2)serviceProvider.GetService(typeof(DTE)); var projects = dte.Solution.Projects; uint cookie = 0; object icon = (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Build; // Initialize the progress bar. statusbar.Progress(ref cookie, 1, "", 0, 0); statusbar.Animation(1, ref icon); for (uint i = 1, n = (uint)projects.Count; i <= n; ++i) { var project = projects.Item(i); statusbar.Progress(ref cookie, 1, "", i + 1, n); statusbar.SetText(string.Format("Converting {0}", project.Name)); ProjectConverter.Run(serviceProvider, project); } // Clear the progress bar. statusbar.Animation(0, ref icon); statusbar.Progress(ref cookie, 0, "", 0, 0); statusbar.FreezeOutput(0); statusbar.Clear(); }
private async Task RMarkdownRenderAsync(IRSession session, string inputFilePath, string outputFilePath, string format, int codePage, IServiceContainer services) { using (var fts = new DataTransferSession(session, services.FileSystem())) { string currentStatusText = string.Empty; uint cookie = 0; IVsStatusbar statusBar = null; services.MainThread().Post(() => { statusBar = services.GetService <IVsStatusbar>(typeof(SVsStatusbar)); statusBar.GetText(out currentStatusText); statusBar.Progress(ref cookie, 1, "", 0, 0); }); try { // TODO: progress and cancellation handling services.MainThread().Post(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownSendingInputFile.FormatInvariant(Path.GetFileName(inputFilePath)), 0, 3); }); var rmd = await fts.SendFileAsync(inputFilePath, true, null, CancellationToken.None); services.MainThread().Post(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownPublishingFile.FormatInvariant(Path.GetFileName(inputFilePath)), 1, 3); }); var publishResult = await session.EvaluateAsync <ulong>($"rtvs:::rmarkdown_publish(blob_id = {rmd.Id}, output_format = {format.ToRStringLiteral()}, encoding = 'cp{codePage}')", REvaluationKind.Normal); services.MainThread().Post(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownGetOutputFile.FormatInvariant(Path.GetFileName(outputFilePath)), 2, 3); }); await fts.FetchFileAsync(new RBlobInfo(publishResult), outputFilePath, true, null, CancellationToken.None); services.MainThread().Post(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownPublishComplete.FormatInvariant(Path.GetFileName(outputFilePath)), 3, 3); }); } finally { services.MainThread().Post(() => { statusBar?.Progress(ref cookie, 0, "", 0, 0); statusBar?.SetText(currentStatusText); }); } } }
private async Task<bool> SendToRemoteWorkerAsync(IEnumerable<string> files, string projectDir, string projectName, string remotePath, IVsStatusbar statusBar, CancellationToken cancellationToken) { await TaskUtilities.SwitchToBackgroundThread(); string currentStatusText; statusBar.GetText(out currentStatusText); var workflow = _interactiveWorkflowProvider.GetOrCreate(); var outputWindow = workflow.ActiveWindow.InteractiveWindow; uint cookie = 0; try { var session = workflow.RSession; statusBar.SetText(Resources.Info_CompressingFiles); statusBar.Progress(ref cookie, 1, "", 0, 0); int count = 0; uint total = (uint)files.Count() * 2; // for compressing and sending string compressedFilePath = string.Empty; await Task.Run(() => { compressedFilePath = _fs.CompressFiles(files, projectDir, new Progress<string>((p) => { Interlocked.Increment(ref count); statusBar.Progress(ref cookie, 1, string.Format(Resources.Info_CompressingFile, Path.GetFileName(p)), (uint)count, total); string dest = p.MakeRelativePath(projectDir).ProjectRelativePathToRemoteProjectPath(remotePath, projectName); _appShell.DispatchOnUIThread(() => { outputWindow.WriteLine(string.Format(Resources.Info_LocalFilePath, p)); outputWindow.WriteLine(string.Format(Resources.Info_RemoteFilePath, dest)); }); }), CancellationToken.None); statusBar.Progress(ref cookie, 0, "", 0, 0); }); using (var fts = new DataTransferSession(session, _fs)) { cookie = 0; statusBar.SetText(Resources.Info_TransferringFiles); total = (uint)_fs.FileSize(compressedFilePath); var remoteFile = await fts.SendFileAsync(compressedFilePath, true, new Progress<long>((b) => { statusBar.Progress(ref cookie, 1, Resources.Info_TransferringFiles, (uint)b, total); }), cancellationToken); statusBar.SetText(Resources.Info_ExtractingFilesInRHost); await session.EvaluateAsync<string>($"rtvs:::save_to_project_folder({remoteFile.Id}, {projectName.ToRStringLiteral()}, '{remotePath.ToRPath()}')", REvaluationKind.Normal, cancellationToken); _appShell.DispatchOnUIThread(() => { outputWindow.WriteLine(Resources.Info_TransferringFilesDone); }); } } catch(Exception ex) when (ex is UnauthorizedAccessException || ex is IOException) { _appShell.ShowErrorMessage(Resources.Error_CannotTransferFile.FormatInvariant(ex.Message)); } catch (RHostDisconnectedException rhdex) { _appShell.DispatchOnUIThread(() => { outputWindow.WriteErrorLine(Resources.Error_CannotTransferNoRSession.FormatInvariant(rhdex.Message)); }); } finally { statusBar.Progress(ref cookie, 0, "", 0, 0); statusBar.SetText(currentStatusText); } return true; }
private async Task RMarkdownRenderAsync(IRSession session, IFileSystem fs, string inputFilePath, string outputFilePath, string format, int codePage, IApplicationShell appShell) { using (var fts = new DataTransferSession(session, fs)) { string currentStatusText = string.Empty; uint cookie = 0; IVsStatusbar statusBar = null; appShell.DispatchOnUIThread(() => { statusBar = appShell.GetGlobalService <IVsStatusbar>(typeof(SVsStatusbar)); statusBar.GetText(out currentStatusText); statusBar.Progress(ref cookie, 1, "", 0, 0); }); try { appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownSendingInputFile.FormatInvariant(Path.GetFileName(inputFilePath)), 0, 3); }); var rmd = await fts.SendFileAsync(inputFilePath); appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownPublishingFile.FormatInvariant(Path.GetFileName(inputFilePath)), 1, 3); }); var publishResult = await session.EvaluateAsync <ulong>($"rtvs:::rmarkdown_publish(blob_id = {rmd.Id}, output_format = {format.ToRStringLiteral()}, encoding = 'cp{codePage}')", REvaluationKind.Normal); appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownGetOutputFile.FormatInvariant(Path.GetFileName(outputFilePath)), 2, 3); }); await fts.FetchFileAsync(new RBlobInfo(publishResult), outputFilePath); appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownPublishComplete.FormatInvariant(Path.GetFileName(outputFilePath)), 3, 3); }); } finally { appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 0, "", 0, 0); statusBar?.SetText(currentStatusText); }); } } }
public static void Reset() { _nTotal = 0; _nComplete = 0; label = "Tobasco progress"; statusBar.Progress(ref cookie, 1, label, _nComplete, _nTotal); }
private void MenuItemClick(object sender, EventArgs e) { try { uint cookie = 0; _statusBar.Progress(ref cookie, 1, "", 0, 0); _statusBar.Animation(1, ref _sortIcon); var selectedResxFilePaths = GetSelectedResxFilePaths().ToList(); for (var i = 0; i < selectedResxFilePaths.Count; i++) { _resxSorter. Sort(XDocument.Load(selectedResxFilePaths[i])). Save(selectedResxFilePaths[i]); _statusBar.Progress(ref cookie, 1, "", (uint)i + 1, (uint)selectedResxFilePaths.Count); _statusBar.SetText(string.Format("Sorting {0} out of {1} resx files...", i + 1, selectedResxFilePaths.Count)); } WriteToOutput(string.Join(Environment.NewLine, new[] { string.Format("Sorted {0} resx files:", selectedResxFilePaths.Count()) }.Concat( selectedResxFilePaths))); _statusBar.Progress(ref cookie, 0, "", 0, 0); _statusBar.Animation(0, ref _sortIcon); SetStatusBar("Resx sort succeeded"); } catch (Exception exception) { WriteToOutput("Failed to sort resx files: {0}", exception.Message); SetStatusBar("Failed to sort resx files"); } }
/// <summary> /// Shows the progress indicator in the status bar. /// Set <paramref name="currentStep"/> and <paramref name="numberOfSteps"/> /// to the same value to stop the progress. /// </summary> /// <param name="text">The text to display in the status bar.</param> /// <param name="currentStep">The current step number starting at 1.</param> /// <param name="numberOfSteps">The total number of steps to completion.</param> public async Task ShowProgressAsync(string text, int currentStep, int numberOfSteps) { if (currentStep == 0) { throw new ArgumentOutOfRangeException(nameof(currentStep), "currentStep must have a value of 1 or higher."); } await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); IVsStatusbar statusBar = await VS.Services.GetStatusBarAsync(); statusBar.FreezeOutput(0); uint cookie = 0; // Start by resetting the status bar. if (currentStep == 1) { statusBar.Progress(ref cookie, 1, "", 0, 0); } // Then report progress. if (currentStep < numberOfSteps) { statusBar.Progress(ref cookie, 1, text, (uint)currentStep, (uint)numberOfSteps); } // And clear the status bar when done. else { statusBar.Progress(ref cookie, 1, "", 0, 0); } }
/// <summary> /// SrcML service starts to monitor the opened solution. /// </summary> /// <param name="srcMLArchiveDirectory"></param> /// <param name="shouldReset"></param> public void StartMonitoring(bool shouldReset, string srcMLBinaryDirectory) { // Get the path of the folder that storing the srcML archives var openSolution = GetOpenSolution(); string baseDirectory = GetSrcMLArchiveFolder(openSolution); SrcMLFileLogger.DefaultLogger.Info("SrcMLGlobalService.StartMonitoring( " + baseDirectory + " )"); try { if (shouldReset) { SrcMLFileLogger.DefaultLogger.Info("Reset flag is set - Removing " + baseDirectory); Directory.Delete(baseDirectory, true); } // Create a new instance of SrcML.NET's LastModifiedArchive LastModifiedArchive lastModifiedArchive = new LastModifiedArchive(baseDirectory, LastModifiedArchive.DEFAULT_FILENAME, _taskManager.GlobalScheduler); // Create a new instance of SrcML.NET's SrcMLArchive SrcMLArchive sourceArchive = new SrcMLArchive(baseDirectory, SrcMLArchive.DEFAULT_ARCHIVE_DIRECTORY, true, new SrcMLGenerator(srcMLBinaryDirectory), new ShortXmlFileNameMapping(Path.Combine(baseDirectory, SrcMLArchive.DEFAULT_ARCHIVE_DIRECTORY)), _taskManager.GlobalScheduler); CurrentSrcMLArchive = sourceArchive; // Create a new instance of SrcML.NET's solution monitor if (openSolution != null) { CurrentMonitor = new SourceMonitor(openSolution, DirectoryScanningMonitor.DEFAULT_SCAN_INTERVAL, _taskManager.GlobalScheduler, baseDirectory, lastModifiedArchive, sourceArchive); CurrentMonitor.DirectoryAdded += RespondToDirectoryAddedEvent; CurrentMonitor.DirectoryRemoved += RespondToDirectoryRemovedEvent; CurrentMonitor.UpdateArchivesStarted += CurrentMonitor_UpdateArchivesStarted; CurrentMonitor.UpdateArchivesCompleted += CurrentMonitor_UpdateArchivesCompleted; CurrentMonitor.AddDirectoriesFromSaveFile(); CurrentMonitor.AddSolutionDirectory(); } // Subscribe events from Solution Monitor if (CurrentMonitor != null) { CurrentMonitor.FileChanged += RespondToFileChangedEvent; // Initialize the progress bar. if (statusBar != null) { statusBar.Progress(ref cookie, 1, "", 0, 0); } // Start monitoring var updateTask = CurrentMonitor.UpdateArchivesAsync(); CurrentMonitor.StartMonitoring(); OnMonitoringStarted(new EventArgs()); SaveTimer.Start(); } } catch (Exception e) { SrcMLFileLogger.DefaultLogger.Error(SrcMLExceptionFormatter.CreateMessage(e, "Exception in SrcMLGlobalService.StartMonitoring()")); } }
public void Report(int progress) { _progress = progress; TRD.Tasks.Task.Factory.StartNew(() => _statusBar.Progress(ref _cookie, 1, _name, (uint)progress, _count), TRD.CancellationToken.None, TaskCreationOptions.None, _uiScheduler); }
/// <summary> /// Starts determinate progress bar animation /// </summary> /// <param name="totalAmount">Total number of units of work that will be done</param> /// <param name="text">Text to display in the status bar</param> public static void StartDeterminate(int totalAmount, string text) { CheckInstance(); statusBarCookie = 0; total = (uint)totalAmount; try { statusBar.Progress(ref statusBarCookie, 1, text, 0, total); } catch { } }
public override void Dispose() { _taskFactory.Run(async() => { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); StatusBar.Animation(0, ref icon); StatusBar.Progress(ref cookie, 0, "", 0, 0); StatusBar.FreezeOutput(0); StatusBar.Clear(); }); }
public override void Dispose() { _taskFactory.Run(async() => { await _taskFactory.SwitchToMainThreadAsync(); _statusBar.Animation(0, ref Icon); _statusBar.Progress(ref _cookie, 0, "", 0, 0); _statusBar.FreezeOutput(0); _statusBar.Clear(); }); }
void OnTransformSelectedExec(object sender, EventArgs e) { this.SaveAllDocumentsBeforeBuild(); _dte.ExecuteCommand("View.Output", ""); OutputWindowHelper outHelper = new OutputWindowHelper(_dte); List <ProjectItem> toProcess = new List <ProjectItem>(); //Get items to be transformed. Project selectedProject = ToDteProject(GetSelectedProject(_serviceProvider)); FindProjectItems(selectedProject, toProcess); outHelper.Clear(); outHelper.AddMessage(string.Format(Resources.StartCodeGen, selectedProject.Name)); outHelper.AddMessage(Resources.Seperator); uint pdwCookie = 0; uint count = (uint)toProcess.Count; IVsStatusbar service = _serviceProvider.GetService(typeof(IVsStatusbar)) as IVsStatusbar; if (service != null) { service.Progress(ref pdwCookie, 1, Resources.TextTemplatingStatusBarLabel, 0, count); } uint complete = 1; bool errorFlag = false; foreach (ProjectItem item in toProcess) { Application.DoEvents(); VSProjectItem vsItem = item.Object as VSProjectItem; if (vsItem != null) { errorFlag |= this.RunCustomTool(item, vsItem, GetCustomTool(item), outHelper); } if (service != null) { service.Progress(ref pdwCookie, 1, Resources.TextTemplatingStatusBarLabel, complete, count); } complete++; Application.DoEvents(); } outHelper.AddMessage(Resources.Seperator); outHelper.AddMessage(Resources.EndCodeGen); if (service != null) { service.Progress(ref pdwCookie, 0, string.Empty, count, count); } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> public void MenuItemCallback(object sender, EventArgs e) { IVsStatusbar statusBar = (IVsStatusbar)ServiceProvider.GetService(typeof(SVsStatusbar)); uint cookie = 0; string label = "SILVERPROD Best practis analysing"; object icon = (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Build; // Display the icon in the Animation region. statusBar.Animation(1, ref icon); statusBar.SetText(label); statusBar.Progress(ref cookie, 1, label, 5, 10); DTE dte = Package.GetGlobalService(typeof(SDTE)) as DTE; Project activeProject = null; Array activeSolutionProjects = GetActiveProject(dte); Boolean error = false; String Spd = Properties.ModelList.Default["Trigramme"].ToString(); if (activeSolutionProjects != null && activeSolutionProjects.Length > 0) { activeProject = activeSolutionProjects.GetValue(0) as Project; errorListProvider.Tasks.Clear(); SPD spd = new SPD(); spd.ShowDialog(); error = AnalyserRules.TryByProjectItem(activeProject.ProjectItems, errorListProvider, Spd, dte, activeProject.FullName); errorListProvider.Show(); TeamServeceConnect.getListWorkitem(TeamServeceConnect.getURI(dte.Solution.FullName)); if (!error) { if (TeamServeceConnect.getURI(dte.Solution.FullName) != "") { string _ret = "The solution is not configured with DevOps/VSTS"; AnalyserRules.addMessageErrorList(dte, errorListProvider, _ret, dte.Solution.FullName, "", 0, 0); } if (TeamServeceConnect.getListTeamProjects(dte.Solution.FullName).Contains(activeProject.FullName.Split('\\')[activeProject.FullName.Split('\\').Length - 1].Replace(".rnrproj", ""))) { System.Windows.Forms.MessageBox.Show("true"); } System.Windows.Forms.MessageBox.Show(TeamServeceConnect.getListTeamProjects(dte.Solution.FullName)[TeamServeceConnect.getListTeamProjects(dte.Solution.FullName).IndexOf(activeProject.FullName.Split('\\')[activeProject.FullName.Split('\\').Length - 1].Replace(".rnrproj", ""))].ToString()); } } label = "SILVERPROD Best practis analysed"; statusBar.Progress(ref cookie, 0, "", 0, 0); statusBar.SetText(label); }
public StatusBarUpdater(IVsStatusbar statusBar, IThreadingContext threadingContext, string?projectOrSolutionName, uint totalProjectCount) { Contract.ThrowIfFalse(threadingContext.HasMainThread); _statusBar = statusBar; _threadingContext = threadingContext; _totalProjectCount = totalProjectCount; _statusMessageWhileRunning = projectOrSolutionName != null ? string.Format(ServicesVSResources.Running_code_analysis_for_0, projectOrSolutionName) : ServicesVSResources.Running_code_analysis_for_Solution; _statusMesageOnCompleted = projectOrSolutionName != null ? string.Format(ServicesVSResources.Code_analysis_completed_for_0, projectOrSolutionName) : ServicesVSResources.Code_analysis_completed_for_Solution; _statusMesageOnTerminated = projectOrSolutionName != null ? string.Format(ServicesVSResources.Code_analysis_terminated_before_completion_for_0, projectOrSolutionName) : ServicesVSResources.Code_analysis_terminated_before_completion_for_Solution; // Set the initial status bar progress and text. _statusBar.Progress(ref _statusBarCookie, fInProgress: 1, _statusMessageWhileRunning, nComplete: 0, nTotal: totalProjectCount); _statusBar.SetText(_statusMessageWhileRunning); // Create a timer to periodically update the status message while running analysis. _timer = new Timer(new TimerCallback(UpdateStatusOnTimer), new AutoResetEvent(false), dueTime: TimeSpan.FromSeconds(5), period: TimeSpan.FromSeconds(5)); }
private void UpdateStatusCore() { _threadingContext.JoinableTaskFactory.RunAsync(async() => { await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(); string message; int fInProgress; var analyzedProjectCount = (uint)_analyzedProjectCount; if (analyzedProjectCount == _totalProjectCount) { message = _statusMesageOnCompleted; fInProgress = 0; } else if (_disposed) { message = _statusMesageOnTerminated; fInProgress = 0; } else { message = _statusMessageWhileRunning; fInProgress = 1; } // Update the status bar progress and text. _statusBar.Progress(ref _statusBarCookie, fInProgress, message, analyzedProjectCount, _totalProjectCount); _statusBar.SetText(message); }); }
public ProgressBarHelper(IVsStatusbar statusbar, string label) { _statusbar = statusbar; _label = label ?? ""; _statusbar.Progress(ref _cookie, 1, "", 0, 0); }
private void UpdateStatusBar(int completed, int total) { if (!disposedValue) { var message = string.Format(AnalysisStrings.ReanalysisStatusBar_InProgress, completed, total); statusBar?.Progress(ref pwdCookie, 1, message, (uint)completed, (uint)total); } }
public StatusReporter(IVsStatusbar statusBar, string name, uint count) { _statusBar = statusBar; _name = name; _count = count; // Initialize the progress bar. _statusBar.Progress(ref _cookie, 1, "", 0, 0); }
private void SetupTimer() { this.timer.Enabled = true; this.timer.Elapsed += (sender, args) => { GenerationEvent[] items; lock (locker) { if (timestamp.AddMilliseconds(500) > DateTime.Now) { return; } items = queue.ToArray(); queue.Clear(); } var count = (uint)items.Length; if (count <= 0) { return; } object icon; uint cookie; PrepareStatusbar(out cookie, out icon); var stopwatch = Stopwatch.StartNew(); uint i = 0; var parallellQueue = items.AsParallel(); parallellQueue.ForAll(item => { item.Action(item); statusBar.Progress(ref cookie, 1, string.Empty, ++i, count); }); stopwatch.Stop(); Log.Debug("Queue flushed in {0} ms", stopwatch.ElapsedMilliseconds); ClearStatusbar(cookie, ref icon); }; }
private void Cleanup() { if (pwdCookie != 0) { statusBar.Progress(ref pwdCookie, 0, "", 0, 0); pwdCookie = 0; } }
public ProgressBarHelper(IVsStatusbar statusbar, string label) { ThreadHelper.ThrowIfNotOnUIThread(); _statusbar = statusbar; _label = label ?? ""; _cookie = 0; _statusbar.Progress(ref _cookie, 1, _label, 0, Total); }
public void SetStatusProgress(uint cookie, int progress, string label, uint complete, uint total) { if (null == _statusbar) { return; } _statusbar.Progress(cookie, progress, label, complete, total); }
// TIPS Progress bar /// <summary> /// Displays the progress bar. /// </summary> /// <param name="message">The message.</param> /// <param name="processed">The processed.</param> /// <param name="total">The total.</param> public void DisplayProgress(string message, int processed, int total) { if (message == null) { message = string.Empty; } if (processed < 0) { processed = 0; } if (total < 0) { total = 0; } if (processed < total) { if (statusbar == null) { statusbar = GetService <IVsStatusbar>(); } if (statusbar != null) { statusbar.Progress(ref statusbarCookie, 1, message, (uint)processed, (uint)total); } } else { if (statusbarCookie != 0) { if (statusbar == null) { statusbar = GetService <IVsStatusbar>(); } if (statusbar != null) { statusbar.Progress(ref statusbarCookie, 0, string.Empty, (uint)total, (uint)total); } } statusbar = null; statusbarCookie = 0; } }
void UpdateStatusBar(bool usingStatusBar, string text, uint soFar, uint total) { IVsStatusbar statusBar = _serviceProvider.GetService(typeof(SVsStatusbar)) as IVsStatusbar; statusBar.Progress(ref _statusBarCookie, usingStatusBar ? 1 : 0, text, soFar, total); if (!usingStatusBar) { _statusBarCookie = 0; } }
//<Snippet1> void ProgressBarExample() { IVsStatusbar statusBar = (IVsStatusbar)GetService(typeof(SVsStatusbar)); uint cookie = 0; string label = "Progress bar label..."; // Initialize the progress bar. statusBar.Progress(ref cookie, 1, "", 0, 0); for (uint i = 0, total = 100; i <= total; i++) { // Display incremental progress. statusBar.Progress(ref cookie, 1, label, i, total); System.Threading.Thread.Sleep(1); } // Clear the progress bar. statusBar.Progress(ref cookie, 0, "", 0, 0); }
private void Cleanup() { installer.InstallationCompleted -= HandleInstallationCompleted; installer.InstallationProgressChanged -= HandleDownloadProgressChanged; if (pwdCookie != 0) { statusBar.Progress(ref pwdCookie, 0, Strings.Daemon_Downloading_StatusBarMessage, 0, 0); pwdCookie = 0; } }
public VsStatusBarProgress(IVsStatusbar vsStatusbar, IMainThread mainThread, int totalSteps) { mainThread.Assert(); _vsStatusbar = vsStatusbar; _mainThread = mainThread; _totalSteps = (uint)totalSteps; _vsStatusbar.GetText(out string text); _vsStatusbar.Progress(ref _progressCookie, 1, string.Empty, 0, _totalSteps); _originalText = text; }
public void Report(int value) { if (!m_initialized) { Initialize(); } if (!m_initialized) { return; } m_statusBar.Progress(ref m_cookie, 1, ProgressBarLabel, (uint)value, 100); }
public void Progress(int period, string text) { if (InProgress) { return; } InProgress = true; _resetEvent.Reset(); _worker = new BackgroundWorker { WorkerSupportsCancellation = true }; _worker.DoWork += (sender, args) => { var worker = sender as BackgroundWorker; if (worker == null) { return; } var messageTail = ""; const int iterations = 10; while (!worker.CancellationPending) { for (var i = (uint)0; i < iterations; i++) { if (worker.CancellationPending) { break; } _statusbar.Progress(ref _statusbarCookie, 1, text + " " + messageTail, i, iterations); messageTail = "." + ((messageTail.Length < 3) ? messageTail : ""); Thread.Sleep(period / iterations); } } _resetEvent.Set(); }; _worker.RunWorkerAsync(); }
public void ExecuteAsCompiling(Action action, TextWriter outputWriter) { IVsStatusbar statusBar = (IVsStatusbar)GetGlobalService(typeof(SVsStatusbar)); uint cookie = 0; statusBar.Progress(ref cookie, 1, "Compiling...", 0, 0); var gowp = (IVsOutputWindowPane)GetService(typeof(SVsGeneralOutputWindowPane)); if (gowp != null) { gowp.Clear(); } action(); if (gowp != null) { gowp.OutputStringThreadSafe(outputWriter.ToString()); gowp.Activate(); } statusBar.Progress(ref cookie, 0, "", 0, 0); }
/// <summary> /// Get all library archives accessible to the linker of the specified project. /// </summary> /// <param name="project">The project to get the LibArchives for</param> /// <param name="statusBar">the VS status bar</param> /// <returns>Parsed libraries which are accessible by the linker of the given project.</returns> public List<LibArchive> GetLibraryArchives(Project project, IVsStatusbar statusBar) { int frozen; uint cookie = 0; statusBar.IsFrozen(out frozen); if (!_projectArchiveMap.ContainsKey(project)) { var archives = new List<LibArchive>(); var libraries = GetLibraries(project); if (frozen == 0) statusBar.Progress(ref cookie, 1, "", 0, (uint)libraries.Count); int i = 0; foreach(var lib in libraries) { if (frozen == 0) { statusBar.Progress(ref cookie, 1, "", (uint) i++, (uint)libraries.Count); statusBar.SetText("Scanning " + Path.GetFileName(lib)); } archives.Add(GetArchive(lib)); } _projectArchiveMap.Add(project, archives); } if (frozen == 0) { statusBar.Progress(ref cookie, 0, "", 0, 0); statusBar.Clear(); } return _projectArchiveMap[project]; }