LEADTOOLS Annotations for WPF and Silverlight Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.22
Implementing WPF Annotations

Note: This topic is for Document/Medical only.

Annotations are based on vectored drawing functions and are associated with bitmaps as an overlay of the displayed image. LEADTOOLS supports a number of annotation types, including lines, rectangles, hotspots, redact objects, polygons, and containers. A container is a specialized annotation object that lets you position and groups other annotation objects, including other container objects.

Support for the various annotation objects is provided by The WPF annotation object classes, which are named using a format of AnnXXXXObject where XXXX is the type of object. For a full list of available annotation object classes, refer to Types Of Annotation Objects. LEADTOOLS maintains annotations separately from images. Your application code is responsible for maintaining the relationships between images and annotations. For example, The WPF annotation example that ships with LEADTOOLS creates a WPF Annotation file that has the same name as its associated image file, but with a different extension. When the image file is loaded, the program looks for an associated annotation file and loads it as well.

Annotations can be saved using the AnnCodecs.Save method in one of three formats: The Xml format is the preferred format for storing annotations. There are many advantages of using the XML format: Non-automated Annotations Non-automated annotations allow you to customize the creation of and interaction with annotations to suit your own needs. When programming non-automated annotations, it is important to remember:

For tutorials on creating a non-automated annotation program, see Implementing a WPF Non-Automated Annotation Program and Using WPF Non-Automated Annotations in Run Mode.

Automated Annotations Automated annotations require an automation object to be associated with a ImageViewer. This automation object lets you maintain default properties for all objects. For example, you can use it to set the default font and the default line width. Keep in mind, however, that scaling factors affect the appearance of these default measurements. The values are set based on the scaling factors that are in effect at the time you create the object. Features associated with automated annotations are:

The user interface for the automated annotations has several options that allow you to control the behavior of The WPF annotation objects, including options that allow you to select whether you want to do the following:

For more information, refer to WPF Annotation Rotation Options. For a tutorial on creating an automated annotation program, see Working With Automated Annotations.

WPF Annotation Classes.

The following paragraphs provide a brief introduction to the major classes that are used to implement support for annotations:

The AnnAutomationObject class defines all the properties needed to automate a WPF Annotation object. You create an instance of this class and fill it up with the properties you want and then you add it to the Objects collection. At any time, you can enumerate the Objects collection and add or remove or modify any properties you want. The CreateDefaultObjects method creates the default AnnAutomationObject objects for the default annotation objects. LEADTOOLS will create the automation properties for the default annotation objects. You can change any property behavior by overriding members of this class or deriving your own. Use the CreateDefaultObjects method to create the default automation annotation objects, and the CreateDefaultObjectContextMenu method to create the context menu associated with a certain id. You should call the CreateToolBar method after you finish setting up the automation objects in Objects or CreateDefaultObjects. After calling this method, a ToolBar is created and you can add it to your form.

Use the FindObject method to find the AnnAutomationObject associated with a certain id.

The AnnAutomationManager class holds the collection of all AnnAutomation objects in the application as well The WPF annotation toolbar. Cursor, keyboard, context sensitive menus, property dialogs and various other user interface options and settings are stored here as well. An automated annotation application usually creates one AnnAutomationManager object per application.

When working with annotations, the background brush (the brush that fills the interior) of many objects can be changed by changing the object's "fill", and line characteristics can be changed by changing the object's "stroke". For more information, refer to Changing Annotation Automation Background Brushes.. Support for annotation brushes/strokes is provided by the Brush and its derived classes.

The AnnCodecs class handles loading and saving operations. The following methods let you load annotations from a file or save them to a file:

The AnnContainer class represents a WPF Annotation container, a rectangular area that holds annotation objects. The container is responsible for maintaining these objects as well as rendering.

The AnnDesigner class is the base class for all the designers in The WPF annotation toolkit. An AnnDesigner derived class controls the user interface functionality involved in drawing, editing or running an object. This class provides the basic functionality common to all the designers such as hooking into a container, clipping the mouse cursor, etc. You assign an AnnContainer object to the Container member. Then based on the exact designer functionality, it will hook into the various mouse events to draw a new, edit an existing (by moving, resizing, etc.) or run (if the container is in Run user mode) an AnnObject. The AnnDesigner classes provide the following methods as appropriate:

The AnnObject class is the base class for all annotation objects used in The WPF annotations class library. This class holds common drawing information shared by all annotation objects in The WPF annotations class library. You can query the properties of this class to easily figure out if a certain class supports stroke, fill or text and quickly change them. For example, the Properties dialogs used in the automation mode do just that to test whether to display the stroke options.

Events

Use the following events to adapt your application:

WPF Annotation Object Headers

You can use annotation object headers to differentiate between multiple objects in a container. LEADTOOLS does not use the object header in any special way and the value has no special meaning. For information on using annotation object headers, refer to WPF Annotation Object Headers.

WPF Annotation Interfaces

LEADTOOLS provides several interfaces for use with the various annotation objects in automation mode. In automation mode The WPF annotation framework uses the appropriate interfaces to display dialogs, with the appropriate tabs, for The WPF annotation objects. The IAnnPicture interface supports standard picture properties used by annotation objects from those classes that implement this interface. The IAnnText interface is used by The WPF annotation framework to draw a text string.

User Interface, Automation Mode

The following methods and properties support Windows clipboard operations:

Grouping and Ungrouping

The following methods let you group or ungroup annotation objects:

For more information on grouping and ungrouping, refer to Grouping and Ungrouping Annotation Objects.

Undo

The LEADTOOLS annotation features include an Undo engine for undoing annotation automation operations. The AnnAutomation.UndoCapacity property specifies the number of operations that can be undone. The default is 10 actions. LEADTOOLS provides a number of methods and properties for handling undo capabilities in non-automated operations. For more information, refer to Undoing Wpf Annotation Automation Operations.

User Modes

Use the UserMode property to get or set the current user mode. AnnUserMode.Design is for creating objects; AnnUserMode.Run mode is for viewing them. Switching the user mode to Run automatically hides the automation ToolBar . Setting the user mode to Design displays the ToolBar. The UserModeChanged event is fired whenever the UserMode property is changed. The following properties and methods let you create and customize the interface used in automation mode:

For a tutorial on creating an automated annotation program, see Working With Automated Annotations.