private async void checkProgressUpdated(object sender, ICodeAnalyzer.ProgressEvenArgs e) { int progress = e.Progress; if (progress == 0) { progress = 1; // statusBar.Progress won't display a progress bar with 0% } await JoinableTaskFactory.SwitchToMainThreadAsync(); EnvDTE.StatusBar statusBar = _dte.StatusBar; if (statusBar != null) { string label = ""; if (progress < 100) { if (e.FilesChecked == 0 || e.TotalFilesNumber == 0) { label = "cppcheck analysis in progress..."; } else { label = "cppcheck analysis in progress (" + (completedFileCount + e.FilesChecked) + " out of " + (completedFileCount + e.TotalFilesNumber) + " files checked)"; } lastAnalyzerTotalFiles = e.TotalFilesNumber; statusBar.Progress(true, label, progress, 100); } else { label = "cppcheck analysis completed"; completedFileCount += lastAnalyzerTotalFiles; lastAnalyzerTotalFiles = 0; try { // This raises an exception during shutdown. statusBar.Progress(true, label, progress, 100); } catch (Exception) { } _ = System.Threading.Tasks.Task.Run(async delegate { await System.Threading.Tasks.Task.Delay(5000); await JoinableTaskFactory.SwitchToMainThreadAsync(); try { statusBar.Progress(false, label, 100, 100); } catch (Exception) { } }); setMenuState(false); } } }
internal void UpdateStatus(string text, bool append = false) { var service = ServiceProvider.GetService <DTE>(); if (service == null || service.StatusBar == null) { return; } if (append) { EnvDTE.StatusBar statusBar = service.StatusBar; string str = statusBar.Text + text; statusBar.Text = str; } else if (string.IsNullOrEmpty(text)) { service.StatusBar.Clear(); } else { service.StatusBar.Text = text; } }
private async void scanProgressUpdated(int filesScanned) { await JoinableTaskFactory.SwitchToMainThreadAsync(); EnvDTE.StatusBar statusBar = _dte.StatusBar; if (statusBar != null) { try { if (filesScanned >= 0) { string label = "cppcheck scanning for files (" + filesScanned + ")"; statusBar.Text = label; } else { statusBar.Clear(); } } catch (Exception ex) { } } }
private void checkProgressUpdated(object sender, ICodeAnalyzer.ProgressEvenArgs e) { int progress = e.Progress; if (progress == 0) { progress = 1; // statusBar.Progress won't display a progress bar with 0% } EnvDTE.StatusBar statusBar = _dte.StatusBar; if (statusBar != null) { String label = ""; if (progress < 100) { if (e.FilesChecked == 0 || e.TotalFilesNumber == 0) { label = "cppcheck analysis in progress..."; } else { label = "cppcheck analysis in progress (" + e.FilesChecked + " out of " + e.TotalFilesNumber + " files checked)"; } statusBar.Progress(true, label, progress, 100); } else { label = "cppcheck analysis completed"; statusBar.Progress(true, label, progress, 100); System.Threading.Tasks.Task.Run(async delegate { await System.Threading.Tasks.Task.Delay(5000); statusBar.Progress(false, label, 100, 100); }); } } }
/// <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> private void MenuItemCallback(object sender, EventArgs e) { EnvDTE.StatusBar statusBar = null; try { var config = new PipelineConfiguration(); config.Initialize(dte); if (!config.ShowDialog().Equals(DialogResult.OK)) { return; } statusBar = config.SourceProject.DTE.StatusBar; buildPipeline(config, (curr, total) => /* update lambda */ { if (curr != total) { statusBar.Progress(true, "Generating Pipeline", curr, total); } else { statusBar.Progress(false, "Pipeline Generation Complete", 1, 1); } }); } catch (Exception exception) { showException(exception); if (statusBar != null) { statusBar.Clear(); statusBar.Progress(false, "Problem generating pipeline.", 1, 1); } } }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "DBMLUpdate.Connect.DBMLUpdate") { // Some initial setup create an output pain and grab status bar if (_output == null) { _output = _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes.Add("DBML Update"); } _output.Clear(); EnvDTE.StatusBar status = _applicationObject.StatusBar; _output.Activate(); try { //Check where dealing with a dbml file if (_applicationObject.ActiveDocument != null && _applicationObject.ActiveDocument.FullName.EndsWith(".dbml", StringComparison.InvariantCultureIgnoreCase)) { _output.OutputString("Beginning Processing...\r\n"); // Grab dbml and save it if its unsaved Document actDoc = _applicationObject.ActiveDocument; ProjectItem pi = actDoc.ProjectItem; string projPath = pi.ContainingProject.FullName; string docFileName = actDoc.FullName; if (!actDoc.Saved) { status.Text = "Saving Linq-to-SQL desinger diagram..."; actDoc.Save(docFileName); } UpdateStatus(_output, status, "Parsing DBML file..."); // Real work begins in DBMLDoc DBMLDoc doc = new DBMLDoc(docFileName, pi); _output.OutputString(string.Format("Parsed {0} Tables\r\n", doc.TableCount)); UpdateStatus(_output, status, "Updating from Database..."); doc.DBUpdate(_output); status.Text = "Closing the DBML designer..."; actDoc.Close(actDoc.Saved ? vsSaveChanges.vsSaveChangesNo : vsSaveChanges.vsSaveChangesYes); UpdateStatus(_output, status, "Creating new DBML file..."); doc.CreateDBML(docFileName, _output); status.Text = "Opening designer..."; Window win = OpenDesigner(pi, docFileName); UpdateStatus(_output, status, "Re-generating classes..."); try { ((VSProjectItem)win.ProjectItem.Object).RunCustomTool(); } catch (Exception ex) { try { win.Document.Save(docFileName); } catch { UpdateStatus(_output, status, "Code re-generation failed: " + ex.Message); } } _output.OutputString("Finished Processing\r\n"); } else { _output.OutputString("The active document is not a Linq-to-SQL file.\r\n"); } } catch (Exception ex) { _output.OutputString("Refreshing entities failed due to exception:" + ex.ToString() + " Message:" + ex.Message + "\r\n"); } finally { status.Text = string.Empty; status.Progress(false, "", 0, 0); if (_output != null) { _output.Activate(); } } handled = true; } } }
private void LogToFeedbackRegion(string feedback) { EnvDTE.StatusBar statusBar = _ssms.DTE2.StatusBar; statusBar.Text = feedback; }