Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Using Text in WPF Annotation Objects

Many annotation objects utilize text as part of the annotation.

The IAnnTextObject interface provides a set of properties that are common to text and are utilized by any class of annotation object that utilizes text. This interface is implemented by several of The WPF annotation Object classes provided by LEADTOOLS. These include:

AnnButtonObject

AnnGroupObject

AnnNoteObject

AnnStampObject

AnnTextObject

AnnTextPointerObject

AnnTextRollupObject

Each of these classes (either through the direct implementation of IAnnTextObject or inheritance from the AnnTextObject class which implements the IAnnTextObject interface) accesses properties that control vertical and horizontal alignment, margin width and the actual text. The TextHorizontalAlignment and TextVerticalAlignment properties control the horizontal and vertical alignment of the text. The TextEdgeMargin property controls the distance between the text and the bounding rectangle of the text.

Annotation objects from the above-mentioned classes also access the IsTextImplemented property This is a read-only property that is used internally. The toolkit checks this property to make sure it is true and uses this information to determine which tabs the toolkit should include when displaying property dialogs in automation mode.

If the user creates a custom annotation object by deriving a new class from the AnnObjectBase class and includes text in this new class, the user should implement the IsTextImplemented property to always return "true".

For an example of user-defined annotation classes, refer to Implement User Defined Object With LEADTOOLS WPF Annotations.

AnnTextObject:

The AnnTextObject class implements the IAnnTextObject interface and accesses the common text properties mentioned above through this implementation. In addition, this class also inherits numerous properties and methods from the Object, AnnObjectBase, and AnnRectangleObject classes. The AnnTextObject class expands on these inherited classes with several properties and methods. The Clone method makes an exact copy of the AnnTextObject class object that calls it, while the Create method just creates a new AnnTextObject class object. The GetObjectData method gets information required to serialize the annotation object. Finally, the RenderObject method draws the AnnTextObject object on a specific drawing context.

Like the AnnTextObject class, the AnnGroupObject class implements the IAnnTextObject interface. The AnnButtonObject, AnnNoteObject, AnnStampObject, AnnTextPointerObject, and AnnTextRollupObject classes all inherit the AnnTextObject class and access the common text properties mentioned above through this inheritance.

AnnTextPointerObject

The AnnTextPointerObject class inherits the AnnTextObject and accesses the common text properties mentioned above through this inheritance. This class also inherits numerous properties and methods from the Object, AnnObjectBase, and AnnRectangleObject classes. In addition, the AnnTextPointerObject class extends the functionality of the AnnTextObject class by providing an extra line that starts from one of the four corners of the bounding rectangle, around the text. The other endpoint of the line can be moved to point to anything on the underlying image. This extra endpoint may or may not be fixed. The bounding rectangle is given in the Left property, Top property, Width property, and Height property. The position of this extra endpoint is given in the PointerPosition property. The FixedPointer property indicates whether this endpoint is fixed.

If the endpoint is fixed, then transforming the bounding rectangle of the text will not change the location of this endpoint. If the endpoint is not fixed, then the location of the endpoint will change as the bounding rectangle of the text is transformed. The TransformObjectMode property indicates how the transformation process of the object will be performed.

The AnnTextPointerObject class further expands on these inherited classes with several methods. The Clone method makes an exact copy of the AnnTextPointerObject class object that calls it, while the Create method just creates a new AnnTextPointerObject class object. The GetObjectData method gets information required to serialize The WPF annotation object and the DefiningGeometry property returns a Geometry representation of the text pointer annotation object.

When transforming a text pointer object, the GetTransformPoints method gets the array of points to be transformed. Once those points have been transformed, they can be set back in the text pointer object by calling the SetTransformPoints method.

AnnTextRollupObject

The AnnTextRollupObject class inherits the AnnTextObject and accesses the common text properties mentioned above through this inheritance. This class also inherits numerous properties and methods from the Object, AnnObjectBase, and AnnNoteObject classes In addition, the AnnTextRollupObject class extends the functionality of the AnnTextObject class by looking and behaving just like a note object, or being compacted to only display the first line of text. This is done using the Expanded property. If the Expanded property is true, then the text rollup object is expanded, looking and behaving like a Note annotation object. If the IsExpanded property is false, the text rollup object is compacted, or rolled up, to display only one line of text.

The AnnTextRollupObject class further expands on the inherited classes with several methods. The Clone method makes an exact copy of the AnnTextRollupObject class object that calls it, while the Create method just creates a new AnnTextRollupObject class object. The GetObjectData method gets information required to serialize The WPF annotation object and the RenderObject method draws the text rollup annotation object on a specific drawing context.