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:- AnnCodecsFormat.Native - a text-based file format for storing annotations
- AnnCodecsFormat.Encoded - a binary file format for storing annotations
- AnnCodecsFormat.NativeXml - a .NET Serialize format
- AnnCodecsFormat.Xml - a text-based format for storing LEAD annotations that follows the XML (Extensible Markup Language) format
- Unlike the Native/Encoded format, the XML format is both forward- and backward-compatible.
- It is human readable.
- Files using the XML format can be easily modified using a standard text editor (i.e. notepad.exe).
- Files using the XML format can be easily parsed using any standard XML parser.
- Files using the XML format can be used with any of the growing number of utilities that work with XML.
- You must provide any menus or dialogs you wish to use for entering annotation data.
- You must also provide your own means of drawing and interacting with the WPF annotations.
- No hyperlink activation is provided for non-automated annotations. In addition to providing the code for entering hyperlink type and associated parameters, you must also provide the code for accessing the default web browser and calling any programs to be run through a hyperlink.
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:
- Automated annotation menus that appear when you right-click in design mode.
- Automated drawing that lets you use the left mouse button to draw annotations in design mode.
- The WPF annotation toolbar that lets you select The WPF annotation tool to draw.
- Programmatical handling (by LEADTOOLS) of the activation of hyperlinks.
- The ability to undo/redo a number of user actions that were executed using the automated annotations functions.
- Use Rotate Control Points
- Maintain Aspect Ratio
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:
- Cancel
- OnMouseDoubleClick
- End
- EndClipCursor
- EndWorking
- OnMouseLeftButtonDown
- OnMouseRightButtonDown
- OnMouseMove
- OnMouseLeftButtonUp
- OnMouseRightButtonUp
- Move
- MoveControlPoint
- MoveHeader
- OnDraw
- OnEdit
- OnRun
- Start
- StartClipCursor
- StartWorking
- Working
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:
- CurrentObjectIdChanged event
- CurrentRubberStampTypeChanged event
- UserModeChanged event
- AfterObjectChanged event
- BeforeObjectChanged event
- CurrentDesignerChanged event
- ImageDirtyChanged event
- UndoRedoChanged event
- Draw event
- Edit event
- Run event
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:
- AnnAutomation.Copy method
- AnnAutomation.Delete method
- AnnAutomation.Paste method
- AnnAutomation.CanCopy property
- AnnAutomation.CanPaste property
- AnnAutomation.CurrentEditObject property
- AnnAutomation.ClipboardObjectFormat property
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:
- AnnAutomationManager.ContextMenu property
- AnnAutomationManager.ControlPointsGap property
- AnnAutomationManager.MultiSelectModifierKey property
- AnnAutomationManager.ObjectPropertiesDialogType property
- AnnAutomationManager.PasswordDialogType property
- AnnAutomationManager.RotateModifierKey property
- AnnAutomationManager.RubberStampButtonDropDownContextMenu property
- AnnAutomationManager.RunCursor Property
- AnnAutomationManager.SelectedObjectCursor property
- AnnAutomationManager.SelectObjectcursor property
- AnnAutomationManager.SelectRectangleCursor property
- AnnAutomationManager.ShowControlPoints property
- AnnAutomationManager.ToolBar property
- AnnAutomationManager.CreateDefaultObjectContextMenu method
- AnnAutomationManager.CreateDefaultObjects method
- AnnAutomationManager.CreateToolBar method
- AnnAutomationObject.ContextMenu property
- AnnAutomationObject.DrawCursor property
- AnnAutomationObject.DrawDesignerType property
- AnnAutomationObject.EditDesignerType property
- AnnAutomationObject.Id property
- AnnAutomationObject.Name property
- AnnAutomationObject.Object property
- AnnAutomationObject.RunDesignerType property
- AnnAutomationObject.ToolBarButton property
- AnnAutomationObject.ToolBarButtonImage property
- AnnAutomationObject.ToolBarButtonToolTip property
- AnnAutomationObject.UseRotateControlPoints property
- AnnAutomationManager.MaintainAspectRatio property
- AnnGroupEditDesigner class