Tabs Studio Blog (organizing Visual Studio document tabs)

September 14, 2009

Customizing tab context menu from an add-in

Filed under: Uncategorized — Tags: — Sergey Vlasov @ 9:43 pm

In the next Tabs Studio version I’ve added two new events that occur just before tab context menu is opened:

namespace TabsStudioExt
{
    public interface ITabsStudioEngine
    {
        ...
        event OpeningTabContextMenuEventHandler OpeningTabContextMenu;
        event OpeningTabExtensionContextMenuEventHandler OpeningTabExtensionContextMenu;
    }
}

OpeningTabContextMenuEventArgs contains the System.Windows.Controls.ContextMenu ContextMenu property, Tab and Tabs properties. OpeningTabExtensionContextMenuEventArgs contains the ContextMenu, TabExtension, Tab and Tabs properties. An add-in can add, remove and modify menu items in the context menu based on TabExtension or Tab it was opened for. 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 was given a Name. For document tab context menu the names are: Open, OpenSeparator, Save, Close, CloseAllButThis, CloseAllDocuments, FileSeparator, CopyFullPath, OpenContainingFolder, VS2010DocumentSeparator, VS2010Floating, VS2010Dockable, TabGroupsSeparator, MoveToNextTabGroup, MoveToPreviousTabGroup, TabsStudioSeparator and TabsStudio:

Document tab context menu

Document tab context menu


For non document tab context menu additional names are: WindowSeparator, Floating, Dockable, TabbedDocument, AutoHide and Hide:
Non document tab context menu

Non document tab context menu

Blog at WordPress.com.