XCase drawing framework
- DragThumb, ConnectableDragThumb, ResizeThumb, Templates
- 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
, 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.
is a small class that handles resizing of another element (and is related to ResizeElementCommand). Again, it lacks any visual representation.
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.
is an interface required for elements that should be connected by lines,
its basic implementation. IConnectable
basically requires the element to be able to create end points for lines.
derives from DragThumb
. Its two main abilities – dragging via mouse (derived from
) and connecting together make ConnectableDragThumb
a suitable base class for most diagram elements.
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)
#region Commentary Template Init
Template = (ControlTemplate)Application.Current.Resources["XCaseCommentaryTemplate"];
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
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.
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
). It is always drawn as a straight line, not polyline.