XCase drawing framework

  • Elements
    • DragThumb, ConnectableDragThumb, ResizeThumb, Templates
  • Junctions
    • IConnectable
    • XCaseJunction, XCasePrimitiveunction, SnapPointHook

We chose Windows Presentation Foundation for implementation of graphical user interface and drawing both the UML class diagrams and XSEM diagrams. This part covers some of the basic building blocks that we created for drawing diagrams.

Diagrams basically consist of elements (usually rectangular) and lines between these elements.


We created a set of several WPF classes to draw elements of diagram.


DragThumb is a class that can be dragged on the diagram via mouse. It is tightly related to MoveElementCommand, which wraps the dragging action. DragThumb is an ancestor of virtually all the elements in the diagram everything. It does not have visual representation itself – this is left to derived classes and their templates.


ResizeThumb is a small class that handles resizing of another element (and is related to ResizeElementCommand). Again, it lacks any visual representation. ResizeDecoratorTemplate is a control template made of ResizeThumbs and it can be applied to virtually any Control and can be used to resize the control via drag and drop.
At run time, *ResizeDecoratorTemplate is shown on those elements that are selected at the time. It allows resizing the selected element.

IConnectable, ConnectableDragThumb

IConnectable is an interface required for elements that should be connected by lines, ConnectableDragThumb its basic implementation. IConnectable basically requires the element to be able to create end points for lines.

ConnectableDragThumb derives from DragThumb. Its two main abilities – dragging via mouse (derived from DragThumb) and connecting together make ConnectableDragThumb a suitable base class for most diagram elements. ResizeDecoratorTemplate is ofteh used for resizing subclasses of ConnectableDragThumb.

Templates of elements

As written earlier, most of the diagram elements derive from ConnectableDrugThumb. Usually each element has some template that contains its visual representation, the class itself contains only logic above the visual representation. The template is usually registered as a static resource and is loaded when the element is created (in the constructor).

This example shows how XCaseCommentaryTemplate is assigned to XCaseComment – class that represent comments on diagrams:

public XCaseComment(XCaseCanvas xCaseCanvas)
	        : base(xCaseCanvas)
        #region Commentary Template Init
        Template = (ControlTemplate)Application.Current.Resources["XCaseCommentaryTemplate"];


XCaseJunction is a simple object that can draw a line between two elements. It can be a direct line or can be broken to a polyline. Elements connected by XCaseJunctions must implement IConnectable interface. Each point on a junction is a separate control (JunctionPoint) that can be dragged on the diagram. XCaseJunction connects the points.

XCasePrimitiveJunction is a much simplier control that is used to connect elements to another junctions (but can be used to connect an element to any object implementing IPrimitiveJunctionTarget). It is always drawn as a straight line, not polyline.

Last edited Oct 27, 2008 at 8:14 PM by Trupik, version 3


No comments yet.