Magnify diagram and multiply it

Posted on September 16, 2011 by

0


As we announced it, we continue to invest on our MinimalDiagrams solution template. Henceforth, the diagram brotherhood grows and welcomes wouah diagram. And, that’s not all, a new feature has been added to the solution: Toolbox filtering.

The step-by-step guide to follow have been updated as below.

Define a diagram

Define a new vintage diagram

  1. Add Class.
  2. Inherit from the generated Diagram class associated with your domain model.
  3. 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.

Define a new wouah diagram

  1. Add new WPF UserControl to your Dsl Project.
    1. The root element of your model will become the DataContext of your control.
  2. Add new Class.
  3. Inherit from the generated WPFDiagram class associated with your domain model.
  4. 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.
  5. Override the CreateControl method to associatethe newly created usercontrol with your diagram.

Filter the toolbox according to the active diagram

  1. Open your diagram class.
  2. Override the GetToolSupported method to filter the toolbox elements associated with the diagram.
    1. Each toolbox element name will be passed in parameter, returns true if the element is associated with the diagram, false otherwise.

image

Open a diagram

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

DocData.OpenView(Constants.LogicalView,
   new ViewContext("[DiagramName]", typeof([DiagramType])));

What’s next

The next efforts would focus on :

  • Allowing specific root element according to diagram
  • Offering a specific wpf diagram persistence
  • Solving WPF drag and drop
  • Proposing a diagram menu selector

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 www.netfxfactory.org.

Tagged: , , ,
Posted in: Modeling