Subject: Modeling Power Toys Add-ins
From: "Saved by Windows Internet Explorer 7"
Date: Sun, 6 Apr 2008 13:28:23 +0900

Modeling Power Toys Add-ins

Visual Studio 2005 contains a set of visual designers providing modeling of different applications and their parts including Class Designer and Distributed Systems Designers. The set of add-ins described herein provides additional prototype functionality to the designers.

Design Tools Enhancements add-in provides common features applicable to all designers such as pan/zoom window, formatting commands etc whereas Class Designer Enhancements add-in provides some additional functionality specific for the Class Designer.

You can choose to enable all or any of the add-ins – to make your go to Tools | Add-in Manager in Visual Studio main menu and change the state of the add-ins in the opened dialog.

Figure1. All Add-ins Enabled in Add-in Manager Dialog

In addition a fine-grained control is provided by each add-in to which features will be loaded and enabled. To customize feature set of any add-in open Tools | Options dialog from main menu, navigate to Modeling Add-ins category and make your choices for add-in features on the right side of the dialog. Note that in the current version the whole add-in which options are changed will be reloaded when the Options dialog is closed.

Figure 2. Add-in Options Page

The reminder of this document describes individual features provided by the add-ins. Last section describes how get started with building similar add-ins on your own in case you choose to do so.

Table of Contents

Modeling Power Toys Add-ins 1

Table of Contents 2

Design Tools Enhancements 3

Diagram Search. 3

Formatting Commands 3

Floating Property Grid. 4

Pan/Zoom Window. 5

Design Surface Scrolling Improvements 6

Create Comments with Double-Click 7

Design Surface Grid. 7

Class Designer Enhancements 7

Export Diagrams for Web. 7

Display Xml Comment Command. 8

Documentation Tool Window. 8

Filtering Appearance. 9

Filtering Lines 10

Filtering Members 10

Fast Navigation. 10

Interface Lollipop Labels Commands 10

Inheritance Visualization Commands 11

Show Type Command. 11

Association and Inheritance Line Dongles 11

Type Creation Commands 12

Add Member Commands 12

View Class Diagram Command Improvements 12

Creating Custom Add-ins 12

Design Tools Enhancements

Paragraphs in this section describe features included in the Design Tools Enhancements add-in.

Diagram Search

This feature enables Find First and Find Next commands on the diagram. You can invoke these commands via the menu, toolbar or Ctrl+F/F3 shortcuts. When Find command is invoked Find in Diagram dialog appears which provides standard search options:

Figure 3. Find in Diagram dialog

Search shape contents option enables search for elements inside expanded shapes. Search collapsed shapes allows you to search inside collapsed shapes as well.

Find Next will reuse the options set by previous Find First and navigate the next matched element on the diagram.

Formatting Commands

The add-in enables all standard Windows Forms designer layout/formatting commands on modeling design surfaces – commands are shown on the top-level Format menu and the layout toolbar:

Figure 4. Formatting toolbar

Floating Property Grid

When element is selected, its properties are normally displayed on the Properties Window, however it is located far from the selected element and often involves context switching between the design surface and the tool window. Floating properties window feature allows you to avoid switching context. When this feature is enabled and element(s) is selected on design surface, a little “right arrow” icon appears to the right from selection. When the arrow is clicked, property window appears right on design surface allowing editing properties of selected elements:

Figure 5. Floating Properties Window

The property window will disappear as soon as you click on design surface or change selection.

In case you need to change properties on several different elements consequently, you may want to use pinned mode of the feature – to enter this mode click the arrow while holding Control key – this will pin the properties window on design surface and it will follow selection until it is closed via the “X” button on the window.

Figure 6. Floating Properties Window in Pin Mode

Pan/Zoom Window

This feature provides overview and faster navigation facilities for design surface. The feature consists of 2 elements – the in-place thumbnail view which is available via clicking the size-all icon at the bottom-right corner of the diagram:

Figure 7. Thumbnail View launch icon

After pressing left mouse button down on the icon move the mouse on the thumbnail view form which appears to change diagram scroll position on observe the changes immediately reflected on the diagram. To exit thumbnail view scrolling, release the mouse button.

Figure 8. Thumbnail View window

In addition, you can bring up the Pan & Zoom tool window from View | Other Windows main menu in order to keep diagram overview around. Simply click/drag on the tool window surface to change diagram scroll position. The tool window follows active document selection allowing you to switch between diagrams while tool window is visible.

Figure 9. Pan & Zoom Tool Window

Design Surface Scrolling Improvements

This feature allows you to scroll the diagram by dragging design surface like it is a sheet of paper – just hold Ctrl and Alt keys together, click anywhere on design surface and drag it in direction opposite to the side of the diagram you’d like to make visible.

IE-like scrolling mode is also provided – to start scrolling in this mode, click with mouse wheel anywhere on the diagram to choose an anchor point, then move the mouse from the anchor point towards the side of diagram you want to make visible – scrolling will start.

Figure 10. IE-like Scrolling

To change direction of scrolling, move mouse towards new direction, to stop scrolling move mouse on top of the anchor symbol.

Create Comments with Double-Click

This feature makes adding comments to the diagrams as simple as double-clicking anywhere on design surface – a comment shape will be created at the clicked location and will automatically enter in-place editing mode allowing enter comment text.

Design Surface Grid

This feature adds Show Grid command to the Edit top-level menu and diagram context menu which displays shape positioning grid on design surface:

Figure 11. Diagram grid

Class Designer Enhancements

Paragraphs in this section describe features included in the Class Designer Enhancements add-in.

Export Diagrams for Web

This feature adds Export Diagram for Web command to the class diagram context menu which allows you to export class diagrams in XML or HTML format for publishing on the web.

When command is invoked the following dialog appears:

Figure 11. Export Diagram for Web Dialog

By default it will create only the .xml file which you can format later on. You can choose to export as HTML – in this case XML file is transformed into HTML using either default or custom XSL style sheet. In case of default transformer, it will create an image-map with tooltips on all diagram elements. You can find some sample .xsl files in the installation folder.

Display Xml Comment Command

This command is available on members and types and creates a comment shape on the diagram containing summary XML comment for the selected element which facilitates preparing diagrams for publishing or documentation. Command is also available on multiple selection.

Documentation Tool Window

This feature allows you to bring Documentation tool window from View | Other Windows main menu in order to easily edit summary and remarks properties on class diagram elements.

Figure 12. Documentation Tool Window

Filtering Appearance

A set of features is provided in order to filter visual appearance of shapes on the diagram for cleaner printing – commands placed on the Class Diagram | Filter Appearance main menu include Hide Gradients, Hide Controls, Hide Shadows – these commands hide corresponding elements of the diagram.

Hide All command will invoke the three commands above and Show All will revert any of the three commands to normal diagram appearance.

Figure 13. Shape appearance before filtering

Figure 14. Shape appearance after filtering

Filtering Lines

The following commands are available from Class Diagram | Filter Lines main menu:

-          Hide Inheritance Lines – hides all inheritance lines in selection.

-          Show All Inheritance Lines – shows all hidden inheritance lines on the diagram.

-          Show All Public Associations – shows all possibly public associations on the diagram.

-          Show All Associations – shows all possible associations on the diagram.

-          Show Associations As Members – shows all association lines as members.

Filtering Members

The following commands available from Class Diagram | Filter Members main menu provide ways to show/hide members on multiple selection or whole diagram at once:

-          Hide Private – hides all private members.

-          Hide Private and Internal – hides all private and/or internal members.

-          Show Only Public – hides all members except for public, all hidden public members are shown.

-          Show Only Public and Protected – hides all members except for public and protected, hidden public and/or protected members are shown.

-          Show All Members – shows all hidden members.

Fast Navigation

The add-in allows fast switching/navigation on certain elements, i.e.:

-          Alt+Click on a property or a field to show it association.

-          Alt+Click on an association line to show it as a member.

-          Alt+Click on Expand button of a type shape to move all types below it when expanding.

-          Alt+Click on interface label to select its members inside the type.

-          Alt+Click on base type label on a type to invoke Show Base Types command.

Interface Lollipop Labels Commands

This feature adds a new Select Members command to the interface lollipop labels which selects members of the type which implement selected interface, for example when invoked on IConvertible interface on Int32 struct, the command select GetTypeCode and ToString methods which implement the IConvertible interface:

Figure 15. Result of Select Members command

Inheritance Visualization Commands

The add-in provides some additional commands to facilitate diagram creation:

-          Show Type command on all members – displays type of the member on the diagram (similar to Show as Association, but works on all members and doesn’t create a line).

-          Show -> Descendants – shows all types derived from selected one (directly or indirectly).

-          Show -> Ascendants – shows all base types of selected one up to System.Object.

-          Show -> Interfaces – shows all interfaces implemented by a given type.

Show Type Command

Show Type command is available on any member (including methods and events) and works just like Show As Association, but doesn’t create a line – i.e. it brings the return type of the member as a shape on the diagram.

Association and Inheritance Line Dongles

You can use this feature for fast and easy creation of inheritance and association lines: when a type shape is selected, a green inheritance arrow appears on the top side of the shape and association arrow appears on the right side of the shape when this feature is enabled. To create a new line, simply click and drag the green arrows to base type or target property type for inheritance and association appropriately.

Figure 16. Inheritance and Association line dongles

Type Creation Commands

Add Commands on Types

The following additional commands are available from the Add sub-menu on types (classes, interfaces, etc):

-          Derived Class – creates a new class derived from the selected one.

-          Derived Interface – same for interface.

-          Nested Class, Interface etc – creates nested types of specified kind.

Add Member Commands

Some additional commands for creating members are added to the shape’s Add sub-menu:

-          Read-Only Property – creates read-only property on the type.

-          Indexer – creates an indexer.

View Class Diagram Command Improvements

View Class Diagram command is back in the code editor! You can right-click a member or a type which is shown on the diagram and this command will find and select it for you on the diagram. This facilitates switching back and forward between Class Designer and the code editor.

Creating Custom Add-ins

The installation package of Modeling Power Toys Add-ins includes a new project type – “Class Designer Add-in” available from Visual C# category in the New Project dialog. You can use this project type to create your own add-ins for Class Designer and other designers.

To get started, create a new project from this template.

Figure 17. Creating a new Class Designer Add-in project

There is a reference in the project to ModelingAddIns.dll which you will need to fix – to do so open project properties, choose Reference Paths tab and add the install path of Modeling Power Toys Add-ins to the list of reference paths for the project (e.g. “C:\Documents and Settings\{username}\My Documents\Visual Studio 2005\Addins”).

Build the project and start another instance of Visual Studio, create a new project and add a class diagram with some type shapes. Select a type shape and choose from Class Diagram main menu menu item which starts with “CustomCommand” – this is the command created by the new add-in.

By default the command simply moves selected shapes by one grid unit to the right. To modify command behavior open Connect.cs file in the created project and modify OnInvoked method to perform the action you need. To change command name/placement, modify strings passed to the Command and CommandPlacement attributes applied to the CustomCommand class.

You can add more commands by simply creating new classes in the add-in assembly using existing one as a template. See the source code for Modeling Power Toys Add-ins for some samples on how to perform different operations on class diagrams and create more complicated features.