Viewing and transforming annotations, interaction with annotations in WinForms
In This Topic
The visual tool
AnnotationVisualTool is intended for viewing, editing and interaction with the annotation collection of active image in viewer.
AnnotationVisualTool class allows to:
- get access to annotation collection of an image
- display annotation collection of an image
- define the interaction mode between user and annotations
- select of one or more annotations
- detect an image region where annotation may be built or transformed
- build annotation
- transform annotation
- expand existing functionality
Programmatically access to the annotations in WinForms annotation viewer
A collection of visual appearances of annotations can be get using
AnnotationViewCollection property. Visual appearance of a selected annotation can be get using
AnnotationVisualTool.FocusedAnnotationView property.
Display and interact with annotations in WinForms annotation viewer
AnnotationVisualTool class allows to perform 3 groups of operations with annotation collection of single image:
- display annotation collection
-
implement interaction between user and annotation
- generate an event when mouse pointer is being moved above annotation
- generate an event when the user directs mouse pointer at annotation
- generate an event when the user clicks on an annotation
- perform the transition on a hyperlink when the user clicks on link annotation
- perform any other interaction between user and annotation
-
transform a single annotation or a group of annotations
- build and add annotation to annotation collection
- transform annotation (relocate, resize, rotate, mirror, apply user defined transformation)
- remove annotation from annotation collection
Use different annotation interaction modes in WinForms annotation viewer
AnnotationVisualTool class allows to choose interaction mode between user and annotations using
AnnotationVisualTool.AnnotationInteractionMode property. The following modes are available:
- None - the visual tool just displays annotations, interaction with annotations is NOT possible, editing of annotations is NOT possible
- View - the visual tool displays annotations and is possible to interact with them, editing of annotations is NOT possible
- Author - the visual tool displays annotations and is possible to edit them, interaction with annotations is NOT possible
Below is the diagram that illustrate events occurring in annotation engine:
Select one or more annotations in WinForms annotation viewer
By default,
AnnotationVisualTool class allows to select several annotations. The selected annotation collection can be get using
AnnotationVisualTool.SelectedAnnotations property. The ability of multiple annotations selection can be disabled using
AnnotationVisualTool.MultiSelect property. The
AnnotationVisualTool.AnnotationSelectionPen property allows to specify a pen, which should be used for drawing of annotation selection.
Single annotation can be selected using
AnnotationVisualTool.SetFocusedAnnotationView method programmatically.
Restrict annotation building/transformation in image region in WinForms annotation viewer
AnnotationVisualTool allows to restrict region where annotation can be built or transformed. This functionality can be enabled using
AnnotationVisualTool.IsAnnotationBoundingRectEnabled property.
AnnotationVisualTool.AnnotationBoundingRect property allows to set a region on image, where annotation may be built or transformed.
Build annotation in WinForms annotation viewer
The
AnnotationVisualTool.AddAndBuildAnnotation method allows to start the annotation building process, the
AnnotationVisualTool.FinishAnnotationBuilding method allows to finish the annotation building process, the
AnnotationVisualTool.CancelAnnotationBuilding method allows to cancel the annotation building process.
AnnotationVisualTool raises the
AnnotationVisualTool.AnnotationBuildingStarted event when annotation building process is started,
AnnotationVisualTool raises the
AnnotationVisualTool.AnnotationBuildingFinished event when annotation building process is finished,
AnnotationVisualTool raises the
AnnotationVisualTool.AnnotationBuildingCanceled event when annotation building process is canceled.
Transform annotation in WinForms annotation viewer
The transformation of focused annotation may be started via mouse.
AnnotationVisualTool raises the
AnnotationVisualTool.AnnotationTransformingStarted event when annotation transformation process is started,
AnnotationVisualTool raises the
AnnotationVisualTool.AnnotationTransformingFinished event when annotation transformation process is finished.
The visual tool allows to transform a single annotation or a group of annotations. While transforming an annotation group is possible to perform transformation of group in whole or for each annotation separately.
Use the annotation rotation assistant for rotating annotation in WinForms annotation viewer
AnnotationVisualTool class contains a rotation assistant, which can help when annotation needs to be rotated on a discrete angle. The rotation assistant is accessible using
AnnotationVisualTool.RotationAssistant property.
The rotation assistant works as follows:
- Annotation is being rotated on a discrete angle when mouse pointer is over annotation assistant area (see the image below)
- Annotation is being rotated smoothly when mouse pointer is out of annotation assistant area (see the image below)
Expand existing functionality
AnnotationVisualTool class has open architecture and allows to change, practically, any functionality in derived classes.