Tabs Studio Blog (organizing Visual Studio document tabs)

September 2, 2009

Decorator add-in

Filed under: Uncategorized — Tags: , — Sergey Vlasov @ 7:14 pm

Decorator is an example of custom properties usage. It sets distinct color for tabs that belong to the project having the most opened tabs. I.e. if 2 opened tabs are for documents from Project1, 5 tabs from Project2 and 3 tabs from Project3, then tabs from Project2 will be colored blue.

TabsStudioDecorator.Properties class defines custom dependency property IsTopProjectProperty, registers it using the RegisterAttached method and provides two static set and get methods for it.

Main Decorator class recalculates the top project when a tab is created or destroyed. Then it sets IsTopProjectProperty to true for all tabs belonging to the top project (if number of tabs in the top project is greater than 3) and to false for the rest of tabs.

Main Decorator class also implements the TabsStudioExt.IStyler interface and returns definition for the TabsStudioDecorator namespace from the GetNamespacesForResourceDictionary method.

Following style is used to color 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>
Four tabs belonging to WebSite2 project are colored blue

Four tabs belonging to WebSite2 project are colored blue

Download Decorator v1.0.0 for Tabs Studio v1.5.7.

Disambiguator add-in

Filed under: Uncategorized — Tags: — Sergey Vlasov @ 12:25 pm

Files in different projects and even files within a project can have the same names. In this case their tabs also have the same titles and one need to hover the mouse over the tabs to distinguish them by tooltip with the full path. Disambiguator add-in detects when two or more tabs have the same title and adds Visual Studio folder or project to titles for these tabs.

Disambiguator monitors TabCreated event, searches if tabs with the same name without extension already exist and adds TitleTransform to tabs found except if tab already has TitleTransform with the [Disambiguator] tag. The TitleTransform prefixes the title with the Visual Studio folder or project name (if document is not within a folder). A web site project has a full path as its name, so Disambiguator uses only last directory name in the title in this case.

Download Disambiguator v1.0.0 for Tabs Studio v1.5.7.

Tabs Studio v1.5.7 is released

Filed under: Releases — Sergey Vlasov @ 11:16 am

Tabs Studio v1.5.7 is released – added ability to use custom properties in an add-in for styling, added ability to change tab title from an add-in, restricted add-ins loading only to assemblies with the dll extension.

Using attached properties in an add-in for advanced styling

Filed under: Uncategorized — Tags: , — Sergey Vlasov @ 9:15 am

Currently in style triggers only predetermined in Tabs Studio (IsDocument, IsTabSelected) and in WPF (IsMouseOver) properties can be used. For the next Tabs Studio version I’ve added ability for an add-in to add and set its own custom properties to any tab element and use it in style triggers.

These custom properties are WPF Attached Properties. An add-in should define custom static DependencyProperty in a class (I recommend to use separate dedicated class for it), initialize this property using the RegisterAttached method and define two static methods to set and get the property.

After a custom property is defined and registered, an add-in can set it for any tab element when needed:

Properties.SetIsTopProject(tab.TabItem, isTopProject);

Where Properties is a class containing the property, SetIsTopProject is a static set method for the property, tab.TabItem is a tab element we set property for, isTopProject is a value for the property.

On the style side we use this new property in a trigger almost as usual:

<Trigger Property="TabsStudioDecorator:Properties.IsTopProject" Value="True">

We must additionally specify the XAML namespace and the class where the property is defined. Defining this custom XAML namespace is an add-in’s job. Main add-in class must implement the TabsStudioExt.IStyler interface – return a string from the GetNamespacesForResourceDictionary method with required namespace(s) definition(s):

public string GetNamespacesForResourceDictionary()
{
    return "xmlns:TabsStudioDecorator=\"clr-namespace:TabsStudioDecorator;assembly=Decorator\"";
}

September 1, 2009

Changing tab title from an add-in

Filed under: Uncategorized — Tags: — Sergey Vlasov @ 2:16 am

I’ve added infrastructure to control tab and tab extension title text from an add-in. It was already possible to modify tab label control directly, but direct modifications can be overridden by Tabs Studio and require special processing for underscore characters.

Now each title has the associated list of transforms applied to this title. Each transform is a pattern regex string, replacement regex string and tag ID string. An add-in can customize this list individually for each title (add, remove and change transforms).

More specifically, TabsStudioExt.Tab and TabsStudioExt.TabExtension classes have TitleManager property returning ITitleManager interface. ITitleManager interface has Title and UntransformedTitle properties (there is no need to access underlying label control to get title any more), Transforms property returning generic list of TitleTransform and ApplyTransforms method that an add-in should call when it has finished updating the transforms list. TitleTransform has PatternRegex, ReplacementRegex and Id properties.

An example of tab title customization usage can be disambiguation of tabs with the same name adding folder/project to tab title on tab creation when there is already a tab with the same name in the group (see my upcoming Disambiguator add-in). “Remove path from tab name” option is now also implemented as a transform (pattern ^(.*/)?(.*)$, replacement $2, id [Tabs Studio] Remove path).

Tab extension title customization can be used for decorations like this:

Custom extension transformation

Custom extension transformation


It was implemented by adding two transforms (.cpp$ -> .c++ and .cs$ -> .c#) on TabExtensionCreated event to each tab extension.

« Newer Posts

Blog at WordPress.com.