/// <summary> /// output string into output window (general pane) /// </summary> /// <param name="output">string to output</param> private void OutputString(string output) { if (_generalPane == null) { try { IVsOutputWindow outWindow = PowerShellToolsPackage.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow; Guid generalPaneGuid = VSConstants.OutputWindowPaneGuid.GeneralPane_guid; // By default this is no pane created in output window, so we need to create one by our own // This call won't do anything if there is one exists int hr = outWindow.CreatePane(generalPaneGuid, "General", 1, 1); outWindow.GetPane(ref generalPaneGuid, out _generalPane); } catch (Exception ex) { Log.Error("Failed to create general pane of output window due to exception: ", ex); throw; } } if (_generalPane != null) { _generalPane.Activate(); // Brings this pane into view _generalPane.OutputStringThreadSafe(output); // Thread-safe so the the output order can be preserved } }
public EditorFactory(PowerShellToolsPackage package) { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} constructor", this.ToString())); this.editorPackage = package; }
/// <summary> /// Initialization routine for the Editor. Loads the list of properties for the xml document /// which will show up in the properties window /// </summary> /// <param name="package"></param> private void PrivateInit(PowerShellToolsPackage package, string fileName) { myPackage = package; loading = false; gettingCheckoutStatus = false; trackSel = null; Control.CheckForIllegalCrossThreadCalls = false; // Create an ArrayList to store the objects that can be selected ArrayList listObjects = new ArrayList(); // Create the object that will show the document's properties // on the properties window. EditorProperties prop = new EditorProperties(this); listObjects.Add(prop); // Create the SelectionContainer object. selContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(true, false); selContainer.SelectableObjects = listObjects; selContainer.SelectedObjects = listObjects; // Create and initialize the editor System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditorPane)); this.editorControl = new EditorControl(fileName); resources.ApplyResources(this.editorControl, "editorControl", CultureInfo.CurrentUICulture); }
/// <summary> /// Constructor that calls the Microsoft.VisualStudio.Shell.WindowPane constructor then /// our initialization functions. /// </summary> /// <param name="package">Our Package instance.</param> public EditorPane(PowerShellToolsPackage package, string fileName) : base(null) { _fileName = fileName; PrivateInit(package, fileName); }
internal void VSOutputProgress(long sourceId, ProgressRecord record) { if (record == null) { throw new ArgumentNullException("record"); } //TODO: If Visual studio ever has a global event/task pane, this would be a perfect place to tie into here. var statusBar = (IVsStatusbar)PowerShellToolsPackage.GetGlobalService(typeof(SVsStatusbar)); if (statusBar != null) { uint cookie = 0; ProgressRecordType progressStatus = record.RecordType; string label = string.Format(ResourceStrings.ProgressBarFormat, record.Activity, record.StatusDescription); switch (progressStatus) { case ProgressRecordType.Processing: { if (record.PercentComplete >= 0 && record.PercentComplete < 100) { statusBar.Progress(ref cookie, 1, label, (uint)record.PercentComplete, 100); } else if (record.PercentComplete == 100) { statusBar.Progress(ref cookie, 1, "", 0, 0); } else { // According to PS ProgressRecord docs, Negative values means a progress bar should not be displayed. lock (AnimationProgressSyncObject) { if (_animationProgressSources.Add(sourceId)) //Returns false if already exists. { // This is needed because Visual Studio keeps a count of each animation. // Animation is removed only when count goes to zero. statusBar.Animation(1, AnimationIconGeneralIndex); } statusBar.SetText(label); } } //Currently, we do not show Seconds Remaining break; } case ProgressRecordType.Completed: { //Only other value is ProgressRecordType.Completed if (record.PercentComplete >= 0) { statusBar.Progress(ref cookie, 0, string.Empty, 0, 0); } else { lock (AnimationProgressSyncObject) { if (_animationProgressSources.Remove(sourceId)) //returns false if item not found. { statusBar.Animation(0, AnimationIconGeneralIndex); } statusBar.SetText(label); } } break; } } } }