Project Description
An experiment project which uses MEF to easily plug in tool windows into VS2010. The tool windows are developed as ordinary WPF UserControls. Install the addin and drop your user control assembly into the extensions directory of Visual Studio and it will show up inside the IDE.

Weeko is a Siouan expression which means "Pretty". I asked my good friend Samuel for a project name and after seeing a screenshot he suggested Weeko.

In the sample screenshot below, the RSS feed, the Twitter feed and thee big clock in the corner are all separate WPF user controls loaded as tool windows into the VS2010 IDE.
sample.png

Getting Started
1) Download and install Weeko, restart VS2010 and make sure it's visible in the Extension Manager
2) Download the sample addins from the download page and unzip them to the VS2010 Extensions directory, probably in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions or something similar, depending on your OS and where you opted to install it
3) Select Tools->Load Weeko Addins from within Visual Studio and the tool windows should materialize into the IDE. You can move/dock them werever you like - VS will remember where you stuck them.

Note that in this version of Weeko, you have to select Tools->Load Weeko Addins everytime you restart VS for the windows to load. This will me managed differently in coming versions.

Make your own Tool Window Addin
Follow these steps to create your own tool window inside VS2010:

1) Download and install Weeko, restart VS2010 and make sure it's visible in the Extension Manager
2) Start a New "WPF User Control Library" and name it somthing which ends with AddinWindow.dll (for Weeko to find it)
3) Do some WPF (I leave this to you, dear coder)
4) Add a reference to System.ComponentModel.Composition (to get MEF support)
5) Add the Export attribute to the UserControl, and remember to set the typeof(UserControl):
using System.ComponentModel.Composition;
using System.Windows.Controls;

namespace SampleAddinWindow
{
    [Export(typeof(UserControl))]
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }
    }
}
6) Compile and place the assembly in the VS2010 extensions directory, probably in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions or something similar, depending on your OS and where you opted to install it
7) The moment you drop the DLL in that directory, it should pop up into the IDE. If you decide to dock it somewhere, VS will remember the location until next time.

Set Caption of Tool Window
It's possible to set the cation of the tool window. Just add a public property called "Caption":
        public string Caption
        {
            get { return "Big Clock"; }
        }
The program loads the tool window assembly as a dynamic type (new in .NET 4.0) and uses "Duck Typing" to try and get the caption. Unfortunately there is no way (that I know of) to set the icon of the tool window. I may be possible in later relases of VS2010.

Working with the VS2010 IDE
Yes, it's possible to work with the other tool windows loaded in the IDE by adding a Package property to the UserControl:
using Microsoft.VisualStudio.Shell;

private Package _package;
public Package Package
{
    get { return _package; }
    set
    {
        _package = value;
        GetSolutionInfo();
    }
}

private void GetSolutionInfo()
{
    if (Package == null) return;

    var dte = Package.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
    if (dte == null || dte.Solution == null) return;
    SolutionInfo.Content = "Solution: " + dte.Solution.FullName;

    if(dte.Solution.Projects != null)
        SolutionInfo.Content += " contains " + dte.Solution.Projects.Count + " projects";
}

Through the Package property you got complete access to the whole VisualStudio IDE - use the MSDN documentation and your imagination. The tricky thing is you have to download the VS2010 SDK to get hold of, and reference, the following assemblies:
  • Microsoft.VisualStudio.OLE.Interop
  • Microsoft.VisualStudio.Shell.10.0
  • Microsoft.VisualStudio.Shell.Interop
  • Microsoft.VisualStudio.Shell.Interop.10.0
  • Microsoft.VisualStudio.Shell.Interop.9.0
  • Microsoft.VisualStudio.Shell.Interop.8.0

Last edited Oct 30, 2009 at 4:42 PM by JohanDanforth, version 10