// -------------------------------------------------------------------------------------------- /// <summary> /// Creates an output pane instance using the specified output pane definition and /// IVsOutputWindowPane instance. /// </summary> /// <param name="paneDef">Pane definition instance</param> /// <param name="pane">Physical output window pane</param> /// <remarks> /// This constructor is to be used only by the OutputWindow class. /// </remarks> // -------------------------------------------------------------------------------------------- internal OutputWindowPane(OutputPaneDefinition paneDef, IVsOutputWindowPane pane) { _PaneDefinition = paneDef; if (paneDef != null) { _Name = paneDef.Name; } _Pane = pane; }
// -------------------------------------------------------------------------------------------- /// <summary> /// Deletes an output window pane according to the specified definition type. /// </summary> /// <param name="type">Pane definition type.</param> /// <returns> /// True, if the window pane is successfully deleted; otherwise, false. /// </returns> /// <remarks> /// The pane definition type should be a type deriving from WindowPaneDefinition. /// </remarks> // -------------------------------------------------------------------------------------------- public static bool DeletePane(Type type) { OutputPaneDefinition paneDef = CreatePaneDefinition(type); if (paneDef == null) { HandleError(type); } return(DeleteWindowPane(paneDef) == VSConstants.S_OK); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Gets an output window pane by using the SVsOutputWindow service. /// </summary> /// <param name="paneDef">Pane definition instance.</param> /// <param name="pane">Pane instance</param> /// <returns>HRESULT indicating the success or failure.</returns> // -------------------------------------------------------------------------------------------- private static int GetWindowPane(OutputPaneDefinition paneDef, out IVsOutputWindowPane pane) { Guid paneGuid = paneDef.GUID; if (OutputWindowInstance != null) { return(OutputWindowInstance.GetPane(ref paneGuid, out pane)); } pane = null; return(VSConstants.E_FAIL); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Creates a pane definition type instance. /// </summary> /// <param name="type">Pane definition type.</param> /// <returns> /// Pane definition instance. /// </returns> // -------------------------------------------------------------------------------------------- private static OutputPaneDefinition CreatePaneDefinition(Type type) { OutputPaneDefinition paneDef = null; try { paneDef = Activator.CreateInstance(type) as OutputPaneDefinition; } catch (SystemException) { // --- This exception is intentionally supressed. } return(paneDef); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Creates an output window pane by using the SVsOutputWindow service. /// </summary> /// <param name="paneDef">Pane definition instance.</param> /// <returns>HRESULT indicating the success or failure.</returns> // -------------------------------------------------------------------------------------------- private static int CreateWindowPane(OutputPaneDefinition paneDef) { Guid paneGuid = paneDef.GUID; return(OutputWindowInstance != null ? OutputWindowInstance.CreatePane( ref paneGuid, paneDef.Name, paneDef.InitiallyVisible? -1 : 0, paneDef.ClearWithSolution? -1 : 0) : VSConstants.E_FAIL); //return OutputWindowInstance.CreatePane( // ref paneGuid, // paneDef.Name, // paneDef.InitiallyVisible ? -1 : 0, // paneDef.ClearWithSolution ? -1 : 0); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Creates an output window pane according to the specified definition type. /// </summary> /// <param name="type">Pane definition type.</param> /// <returns> /// The newly created window pane. /// </returns> /// <remarks> /// The pane definition type should be a type deriving from WindowPaneDefinition. /// </remarks> // -------------------------------------------------------------------------------------------- public static OutputWindowPane CreatePane(Type type) { OutputPaneDefinition paneDef = CreatePaneDefinition(type); if (paneDef == null) { return(HandleError(type)); } // --- No physical IVsOutputWindowPane belongs to a virtual window. if (!paneDef.IsSilent) { int createSuccess = CreateWindowPane(paneDef); if (createSuccess != VSConstants.S_OK) { return(HandleError(type)); } } return(GetPane(type)); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Gets the output window pane according to the specified definition type. /// </summary> /// <param name="type">Pane definition type.</param> /// <returns> /// The newly created window pane. /// </returns> /// <remarks> /// The pane definition type should be a type deriving from WindowPaneDefinition. /// </remarks> // -------------------------------------------------------------------------------------------- public static OutputWindowPane GetPane(Type type) { // --- Obtain the window pane OutputPaneDefinition paneDef = CreatePaneDefinition(type); if (paneDef == null) { return(HandleError(type)); } // --- No physical IVsOutputWindowPane belongs to a virtual window. if (paneDef.IsSilent) { return(new OutputWindowPane(paneDef, null)); } IVsOutputWindowPane pane; int getSuccess = GetWindowPane(paneDef, out pane); if (getSuccess != VSConstants.S_OK || pane == null) { // --- Pane cannot be obtained, try to create first int createSuccess = CreateWindowPane(paneDef); if (createSuccess != VSConstants.S_OK) { return(HandleError(type)); } // --- Now, obtain the newly created pane getSuccess = GetWindowPane(paneDef, out pane); if (getSuccess != VSConstants.S_OK || pane == null) { return(HandleError(type)); } } // --- Retrieve the pane instance return(new OutputWindowPane(paneDef, pane)); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Deletes an output window pane by using the SVsOutputWindow service. /// </summary> /// <param name="paneDef">Pane definition instance.</param> /// <returns>HRESULT indicating the success or failure.</returns> // -------------------------------------------------------------------------------------------- private static int DeleteWindowPane(OutputPaneDefinition paneDef) { Guid paneGuid = paneDef.GUID; return(OutputWindowInstance.DeletePane(ref paneGuid)); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Creates an output pane instance using the specified output pane definition and /// IVsOutputWindowPane instance. /// </summary> /// <param name="paneDef">Pane definition instance</param> /// <param name="pane">Physical output window pane</param> /// <remarks> /// This constructor is to be used only by the OutputWindow class. /// </remarks> // -------------------------------------------------------------------------------------------- internal OutputWindowPane(OutputPaneDefinition paneDef, IVsOutputWindowPane pane) { _PaneDefinition = paneDef; if (paneDef != null) _Name = paneDef.Name; _Pane = pane; }