UML classes are automatically displayed in different colors depending on their stereotypes, when you have installed this sample extension to Visual Studio Ultimate. When the user changes the stereotype, the color changes.

Test the sample

  1. You must have:
    • Visual Studio Ultimate
    • Visual Studio SDK
  2. Download, unzip, and open the .sln file in Visual Studio.
  3. Press F5 to run it. An experimental instance of Visual Studio will open.
  4. Create or open a UML class diagram, and experiment with changing the stereotypes.

How it Works

The code registers an event handler, which listens for creation or deletion of StereotypeInstance objects, and updates the color. The event handler is registered when the model opens, by using a method that is registered to perform validation on open. For more information, see How to Respond to Changes in a UML Model.

Adapt the sample

You can adapt the source code and extend it to suit your own project. For example, it currently only deals with a small fixed set of stereotypes, which you would want to extend.

Install the Extension

To install the extension on your computer, or on another computer where Visual Studio Ultimate is installed:

  1. Copy bin\Debug\*.vsix to the target computer
  2. Double-click the .vsix file

To uninstall, use Tools>Extension Manager in Visual Studio.

Discussion and Questions

Please post questions and suggestions in the Visualization and Modeling SDK Forum.

 

Related samples