VintaSoft Imaging .NET SDK v8.6
In This Topic
    Annotation data
    In This Topic

    The AnnotationData class is intended for storing the base information about annotation. The complete information about annotation is stored in a class derived from AnnotationData class.

    Annotations, derived from AnnotationData class, are divided into 3 types:



    Base concepts of annotation

    Each annotation has location, size, rotation angle, bounding rectangle and center of rotation.

    Location of rectangle based annotation always matches with center of annotation's rectangle. Location of points based annotation by default matches with its first point, unless the coordinates of the first point are changed.

    Bounding rectangle of annotation is the minimal rectangle which includes the annotation in whole and which sides are parallels to the image sides. For rectangle based annotation the bounding rectangle is the minimal rectangle which includes all vertices of annotation's rectangle and its center always matches with center of annotation's rectangle. For points based annotation the bounding rectangle is the minimal rectangle which includes all annotation's points.

    Rotation center of annotation is the point in the image coordinate system, in regard to which the annotation is rotated when the value of Rotation property is changed. The rotation center of any annotation can be calculated as follows:

    AnnotationData.GetLocationWithoutRotation and AnnotationData.GetCenterRelativeToLocation methods are created in a way to get matched the rotation center and the center of bounding rectangle of any non-rotated annotation.



    Annotation's coordinate system and units of measure

    Annotation's location and size are specified and stored in the image coordinate system with the beginning in the left upper corner. Unit of measure is 1 DIP (Device Independent Pixel) which equal 1/96 inch.

    Annotation's rotation angle is the deviation angle from normal non-rotated state of annotation. It is specified and stored in degrees. Rotation angle has positive value when annotation is rotating clockwise and negative when counterclockwise.



    Annotation's properties

    AnnotationData class contains a set of properties divided into following groups:
    Classes derived from AnnotationData class have additional properties which specify annotation data, for example LineAnnotationDataBase class has Points property which contains information about points of annotation.



    Methods of AnnotationData class which provide additional information about annotation

    The following methods of AnnotationData class provide additional information about annotation:


    Events of changing annotation's properties

    There are some events in AnnotationData class which allow to detect if any property value of annotation is changing or changed.


    Loading and saving annotation

    AnnotationData class implements ISerializable interface. This allows to manage the process of loading/saving annotation and to use any formatter, a class which implements IFormatter interface, for loading/saving annotation collection.



    Batch change of annotation properties

    Sometimes it may be necessary to perform an operation over annotation which could include simultaneous change of several properties. This operation is called batch change of annotation properties and can be implemented using methods of ISupportInitialize interface which by-turn is implemented by AnnotationData class.

    BeginInit method allows to start performing batch change of annotation properties. At execution of this method is generated AnnotationData.PropertyChanged event with arguments: PropertyName="IsInitializing", NewValue=True.

    EndInit method allows to stop performing batch change of annotation properties. At execution of this method is generated AnnotationData.PropertyChanged event with arguments: PropertyName="IsInitializing", NewValue=False.

    BeginInit and EndInit methods just generate additional PropertyChanged events and have no influence on logic of calling AnnotationData.PropertyChanging and AnnotationData.PropertyChanged events of annotation.
    BeginInit and EndInit methods support nesting.



    Cloning of annotation

    AnnotationData class implements ICloneable interface.

    The following example shows how to clone single annotation from a collection and add cloned annotation into the same collection:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging.Annotation
    
    Private Sub CloneAndAdd(annotationCollection As Vintasoft.Imaging.Annotation.AnnotationDataCollection, index As Integer)
        ' clone annotation at specified index
        Dim clonedAnnotation As Vintasoft.Imaging.Annotation.AnnotationData = DirectCast(annotationCollection(index).Clone(), Vintasoft.Imaging.Annotation.AnnotationData)
        ' add cloned annotation to the end of the collection
        annotationCollection.Add(clonedAnnotation)
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging.Annotation
    
    void CloneAndAdd(Vintasoft.Imaging.Annotation.AnnotationDataCollection annotationCollection, int index)
    {
        // clone annotation at specified index
        Vintasoft.Imaging.Annotation.AnnotationData clonedAnnotation = 
            (Vintasoft.Imaging.Annotation.AnnotationData)annotationCollection[index].Clone();
        // add cloned annotation to the end of the collection
        annotationCollection.Add(clonedAnnotation);
    }
                    
    



    Annotation collection.

    Several instances of AnnotationData class can be integrated into a collection using AnnotationDataCollection class. AnnotationDataCollection class provides the ability to add, remove, rearrange, sort elements, convert AnnotationData elements to array, subscribe to property changing/change events of each annotation.

    Annotation collection which is associated with concrete image page is represented by AnnotationDataCollection class.