VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
In This Topic
    Annotation view in WPF
    In This Topic
    The WpfAnnotationView class is always created on the base of AnnotationData class and defines the annotation's visual appearance and the way the user may interact with annotation.
    Link between classes derived from AnnotationData and WpfAnnotationView is registered using the WpfAnnotationViewFactory.RegisterViewForAnnotationData method.

    As in the case with classes derived from AnnotationData class, the classes derived from WpfAnnotationView class are divided into 3 types:

    WpfAnnotationView class contains the WpfAnnotationView.Data property, which allows to get reference to a linked instance AnnotationData class. Also WpfAnnotationView class contains a set of properties similar to the properties of AnnotationData class, which allow to relay annotation's properties through WpfAnnotationView.

    Here is C#/VB.NET code that shows how to create an instance of view for EllipseAnnotationData annotation:
    public static Vintasoft.Imaging.Annotation.Wpf.UI.WpfAnnotationView CreateViewForEllipseAnnotationData(
        Vintasoft.Imaging.Annotation.EllipseAnnotationData ellipseAnnotation)
    {
        return new Vintasoft.Imaging.Annotation.Wpf.UI.WpfEllipseAnnotationView(ellipseAnnotation);
    }
    
    Public Shared Function CreateViewForEllipseAnnotationData(ellipseAnnotation As Vintasoft.Imaging.Annotation.EllipseAnnotationData) As Vintasoft.Imaging.Annotation.Wpf.UI.WpfAnnotationView
        Return New Vintasoft.Imaging.Annotation.Wpf.UI.WpfEllipseAnnotationView(ellipseAnnotation)
    End Function
    


    Annotation bounding rectangles

    The visual appearance of annotation has several bounding rectangle types. The following types are used for solving various tasks related to correct drawing and interaction with annotation:


    Render annotations on drawing context

    WpfAnnotationView class provides WpfAnnotationView.Render method, which allows to render annotation on specified System.Windows.Media.DrawingContext object.

    Here is C#/VB.NET code that shows how to render specified annotation on specified image:
    public static void DrawAnnotationOnImage(
        Vintasoft.Imaging.Annotation.Wpf.UI.WpfAnnotationViewCollection annotations,
        Vintasoft.Imaging.VintasoftImage image)
    {
        annotations.Draw(image, (Vintasoft.Imaging.VintasoftImage)image.Clone());
    }
    
    Public Shared Sub DrawAnnotationOnImage(annotations As Vintasoft.Imaging.Annotation.Wpf.UI.WpfAnnotationViewCollection, image As Vintasoft.Imaging.VintasoftImage)
        annotations.Draw(image, DirectCast(image.Clone(), Vintasoft.Imaging.VintasoftImage))
    End Sub
    


    Focus annotation in WPF annotation viewer

    Every annotation may receive focus in the image viewer. When an annotation is focused there appears a selection rectangle around it, which can be transformed (scaled, mirrored, rotated) and the annotation will be transformed in proportion to the selection rectangle.

    The views for annotations, which are based on a set of points, in addition, may be transformed using points. When annotation is selected - all of its points become selected, the user may change the location of each point using dragging.

    Also the views for annotations, which are based on a set of points, support composite selection mode, which allows to transform annotation both using selection rectangle and using points.

    The selection/transformation mode of annotation, which are based on a set of points, may be changed using WpfLineAnnotationViewBase.GripMode property.


    Build and transform annotation in WPF annotation viewer

    WpfAnnotationView.Builder property defines the interactive controller, which is used for annotation building.
    WpfAnnotationView.Transformer property defines the interactive controller, which is used for annotation transformation.

    Also WpfAnnotationView class has WpfAnnotationView.InteractionController property which defines the currently used interactive controller.
    Detailed information about building and transformation of annotation can be found in article: Building and transformation of annotations in WPF.


    Monitor the annotation state

    WpfAnnotationView class provides events, which allow to monitor the annotation state:


    Annotation collection

    The WpfAnnotationViewCollection class is always created on the base of AnnotationDataCollection class and represents a collection of annotation's views, which are linked with annotation data from AnnotationDataCollection.
    The WpfAnnotationViewCollection class makes changes synchronously in its collection and in linked AnnotationDataCollection.
    The WpfAnnotationViewCollection class provides the ability to add, remove, reorder, resort elements, transform to WpfAnnotationView elements array, access to AnnotationDataCollection. Also WpfAnnotationViewCollection class allows to: