Using custom output panes

It is pretty simple to define, create and use custom output panes with VSXtra. This sample demonstates this.

Points of Interest:

  • You can directly write to the General pane of the Output window through System.Console.
  • Output window panes are defined by inheriting from the OutputPaneDefinition class. Custom pane properties are set through attributes decorating the class.
  • Panes can be accessed through the GetPane<TPane> method of the OutputWindow class.
Package source code:

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
using VSXtra;

namespace DeepDiver.CustomOutputWindowPane
{
  [PackageRegistration(UseManagedResourcesOnly = true)]
  [DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\9.0")]
  [InstalledProductRegistration(false, "#110", "#112", "1.0", IconResourceID = 400)]
  [ProvideLoadKey("Standard", "1.0", "CustomOutputWindowPane", "DeepDiver", 1)]
  [XtraProvideAutoLoad(typeof(UIContext.NoSolution))]
  [Guid(GuidList.guidCustomOutputWindowPanePkgString)]
  public sealed class CustomOutputWindowPanePackage : PackageBase
  {
    protected override void Initialize()
    {
      Console.WriteLine("*** Turn to the CutomPane1 and CustomePane2 output panes!");
      var pane1 = OutputWindow.GetPane<CustomPane1>();
      pane1.WriteLine("Welcome on CustomPane1!");
      var pane2 = OutputWindow.GetPane<CustomPane2>();
      pane2.WriteLine("Welcome on CustomPane2!");
    }

    [DisplayName("CustomPane1")]
    [AutoActivate(true)]
    class CustomPane1: OutputPaneDefinition {}

    [DisplayName("CustomPane2")]
    [AutoActivate(true)]
    [ClearWithSolution(true)]
    class CustomPane2 : OutputPaneDefinition { }
  }
}
Screenshots:

CustomOutputPane1.png

CustomOutputPane2.png

Last edited Aug 7, 2008 at 1:39 PM by INovak, version 2

Comments

No comments yet.