Tabs Studio home Order Download Documentation Blog* Support
Feature Overview User Guide Style Tab Grouping Add-ins

Add-ins

Using add-ins

Tabs Studio supports custom add-ins that can extend Tabs Studio functionality and interact with the Visual Studio shell. Add-in dlls are loaded from the Add-in installation folder at startup. The Add-in Manager window can be opened using the Tabs Studio context menu or TabsStudio.Connect.Addins command. It displays all loaded add-ins and allows add-in configuration if add-in supports it:

Tabs Studio Add-in Manager

If an add-in is not loaded successfully in VS 2010 check whether it is blocked as downloaded from the Internet.

Developing add-ins

An add-in for Tabs Studio is a .NET dll. Main add-in class should implement TabsStudioExt.ITabsStudioAddin interface to be loaded by Tabs Studio at startup:
namespace TabsStudioExt
{
    public interface ITabsStudioAddin
    {
        void OnConnection(ITabsStudioEngine engine, EnvDTE80.DTE2 dte);
        void OnDisconnection();
    }
}
Only one add-in per dll is allowed. TabsStudioExt interfaces are declared in the TabsStudioExt.dll that is installed along with the TabsStudio.dll. EnvDTE80.DTE2 parameter in the OnConnection method offers access to the Visual Studio extensibility model. TabsStudioExt.ITabsStudioEngine interface offers Tabs Studio methods and events that add-in can use for Tabs Studio customization (see Tab Studio controls specification for more details):
namespace TabsStudioExt
{
    public interface ITabsStudioEngine
    {
        event TabExtensionCreatedEventHandler TabExtensionCreated;
        event TabExtensionDestroyedEventHandler TabExtensionDestroyed;
        event TabExtensionRenamedEventHandler TabExtensionRenamed;

        event TabCreatedEventHandler TabCreated;
        event TabDestroyedEventHandler TabDestroyed;
        event TabRenamedEventHandler TabRenamed;
        
        event TabsCreatedEventHandler TabsCreated;
        event TabsDestroyedEventHandler TabsDestroyed;

        event OpeningTabContextMenuEventHandler OpeningTabContextMenu;
        event OpeningTabExtensionContextMenuEventHandler OpeningTabExtensionContextMenu;

        System.Collections.Generic.List<Tabs> GetTabs();
        EnvDTE.AddIn GetAddIn();
    }
}
Sample add-in solution structure

Using Visual Studio 2008 and C#, start creating an add-in from the C# class library template project. References to EnvDTE and EnvDTE80 are needed to use the DTE2 parameter in the OnConnection method. PresentationCore, PresentationFramework and WindowsBase are needed to work with WPF controls. TabsStudioExt defines all Tabs Studio extensibility interfaces.

To execute custom Visual Studio commands and set commands availability status your main add-in class must implement the EnvDTE.IDTCommandTarget interface (Exec and QueryStatus methods):

public class Navigator : TabsStudioExt.ITabsStudioAddin, EnvDTE.IDTCommandTarget
To support configurability add-in's main class must implement the TabsStudioExt.IConfigurable interface:
public class Tracer : TabsStudioExt.ITabsStudioAddin, TabsStudioExt.IConfigurable
Add-in information for Add-in Manager is extracted from the version resource in the add-in dll file. Add-in name is extracted from the ProductName key, in C# project it is set using the AssemblyProduct attribute. Description is extracted from the FileDescription key defined by the AssemblyTitle attribute. Version is extracted from the ProductVersion key defined by the AssemblyFileVersion attribute.

To change tab title from an add-in use the TitleManager property in TabsStudioExt.Tab and TabsStudioExt.TabExtension classes. An add-in can modify the regex transforms list and call the ApplyTransforms method.

To define custom properties for styling, an add-in can use WPF Attached Properties and implement the TabsStudioExt.IStyler interface returning a string with required additional namespace definitions:
public string GetNamespacesForResourceDictionary()
{
    return "xmlns:TabsStudioDecorator=\"clr-namespace:TabsStudioDecorator;assembly=Decorator\"";
}
An add-in can add, remove and modify menu items in the Tabs Studio context menu handling OpeningTabContextMenu and OpeningTabExtensionContextMenu events. Right click on a tab with a single extension generates the OpeningTabExtensionContextMenu event. To simplify customization from an add-in, each menu item and separator in the default context menu has distinct Name. For document tab context menu, the names are: Open, OpenSeparator, Save, SaveSeparator, Close, CloseAllButThis, CloseAllDocuments, FileSeparator, CopyFullPath, OpenContainingFolder, VS2010DocumentSeparator, VS2010Floating, VS2010Dockable, TabGroupsSeparator, MoveToNextTabGroup, MoveToPreviousTabGroup, TabsStudioSeparator and TabsStudio. For non-document tab context menu, additional names are: WindowSeparator, Floating, Dockable, TabbedDocument, AutoHide and Hide.

To debug an add-in using Visual Studio:

  1. Remove your add-in from the TabsStudioAddins directory and start VS.
  2. In your add-in project set the Build - Output path to your TabsStudioAddins directory (e.g. C:\Users\myadmin\Documents\Visual Studio 2008\Addins\TabsStudioAddins).
  3. In your add-in project set Debug - Start external program to VS (e.g. C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe).
  4. Start Debugging as usual.

Sample add-ins

Decorator v1.0.1 - sets the IsTopProject property for tabs that belong to the project having the most opened tabs. Demonstrates use of custom properties for styling. The following style can be used to actually color the top project tabs that are not currently selected to white-blue gradient:
<Style TargetType="TabsStudio:Tab" BasedOn="{StaticResource DefaultTabStyle}">
    <Style.Triggers>
        <MultiTrigger>
            <MultiTrigger.Conditions>
                <Condition Property="TabsStudioDecorator:Properties.IsTopProject" Value="True"/>
                <Condition Property="IsTabSelected" Value="False"/>
            </MultiTrigger.Conditions>
            <Setter Property="Background">
                <Setter.Value>
                     <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                         <GradientStop Color="#F5F5F5" Offset="0"/>
                         <GradientStop Color="#B0B0F0" Offset="1"/>
                     </LinearGradientBrush>
                </Setter.Value>
            </Setter>
        </MultiTrigger>
    </Style.Triggers>
</Style>
Disambiguator v1.0.0 - detects when two or more tabs have the same title and adds Visual Studio folder or project to titles for these tabs. Demonstrates use of TitleManager and TitleTransform.

Localizer v1.0.0 - tab context menu translation for German and Spanish localized Visual Studio editions.

Navigator v1.0.1 - allows to switch tabs using keyboard. It provides two new Visual Studio commands to activate tabs on the left and on the right of the currently selected one. Demonstrates Visual Studio commands creation in Tabs Studio's add-in.

NewGroup v1.0.0 - for VS 2010 adds New horizontal/vertical tab group commands to the Tabs Studio context menu.

Saver v1.0.1 - restores tab positions when opening a solution to the last state. Demonstrates use of the GetTabs method.

Sorter v1.0.2 - automatically sorts tabs in alphabetical order.

Sync v1.0.0 - adds new command to the Tabs Studio context menu to locate document in the Solution Explorer window.

Tracer v1.0.1 - traces ITabsStudioEngine events using the System.Diagnostics.Trace.WriteLine method (use DebugView to view trace events).