Multiply diagrams

Posted on June 15, 2011 by


It’s a fact, DSL Tools grows. He makes new friends (WPF), he tried new social experiences (Library, Extension, Bus), rethink his life (UML). But, he still has one eye (Only one diagram is associated with a language).

In the past, we proposed a workaround to overcome this limit. But, the recipe to follow at the time required an important effort.

It’s why today it has been revisited and now, it will be proposed in tin can (a solution template).

A screencast showing a scenario taking advantage of the functionalities presented in this paper is available below.

Minimal Diagrams Solution Template

This post will not give the details of the new implementation. These are minor changes mostly focused on solution packaging.

The corner stone is the definition of T4 Templates that generate code dedicated to multiples diagrams support. If some are new templates (,,,, others are well known (…). Old templates have been updated essentially to support multiple diagram instances into a same model store.

Finally, in order to improve developer experience, a dedicated DSL Tools solution template was defined.

Indeed, you can define your own DSL Tools solution templates. The best way to accomplish it rapidly is to take example from already installed DSL Tools Solution Templates.

They are located in [Program File x86]\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\DSL SDK\Designer Wizard\10.0\SolutionTemplates.

To add your own solution template to the Domain-Specific Language Designer Wizard, you only have to copy your own solution into the directory mentioned above.

DSL Tools Solution Template

Defining a new diagram

All the tedious plumbing required to support multiple diagrams is now generated by a solution template.

After choosing the dedicated solution template, to define a new diagram, the step-by-step guide has not changed since the first post.

  1. Add Class.
  2. Inherits from the generated Diagram class associated with your domain model.
  3. To declare your new class to DSL Tools,
    1. Decorate your class with DomainObjectId attribute by specifying only a new guid.
    2. Add your class to the custom type collection returned by GetCustomDomainModelTypes method of your DomainModel class.
  4. Override the ShouldAddShapeForElement method to filter the model elements displayed by this diagram.
  5. Customize your diagram by following DSL Tools guidelines. Use the DslDefinition editor to define shapes that will be used in your new diagram.

Using a new diagram

In order to open a new diagram, simply calling OpenView method of the generated DocData class with relevant parameters:

   new ViewContext("[DiagramName]", typeof([DiagramType])));

What’s next

The current solution is limited to diagrams based on old school DSL Tools design surface.

Of course, it is planned to open it to WPF as well.

But many other perspectives are allowed such as toolbox filter, free diagram (not automatically synchronized)…

Download the setup program here (Administrator rights are required).

Creative Commons License
Minimal Diagrams by MEXEDGE is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
Based on a work at

Tagged: , ,
Posted in: Modeling