GdPicture.NET.14
GdPicture14.WPF Namespace / GdViewer Class / BeforeAnnotationAddedByUser Event
Example





In This Topic
BeforeAnnotationAddedByUser Event (GdViewer)
In This Topic
This event is raised right before a new GdPicture/XMP annotation is to be added by a user. This event occurs in the mouse down action, therefore it allows you to change some properties of the newly added annotation before rendering it on the screen.

The event makes use of bubble routing strategy. Please check the corresponded GdViewer.BeforeAnnotationAddedByUserEventArgs for given parameters.

Syntax
'Declaration
 
Public Event BeforeAnnotationAddedByUser As GdViewer.BeforeAnnotationAddedByUserHandler
public event GdViewer.BeforeAnnotationAddedByUserHandler BeforeAnnotationAddedByUser
public event BeforeAnnotationAddedByUser: GdViewer.BeforeAnnotationAddedByUserHandler; 
In JScript, you can handle the events defined by another class, but you cannot define your own.
public: __event GdViewer.BeforeAnnotationAddedByUserHandler* BeforeAnnotationAddedByUser
public:
event GdViewer.BeforeAnnotationAddedByUserHandler^ BeforeAnnotationAddedByUser
Event Data

The event handler receives an argument of type GdViewer.BeforeAnnotationAddedByUserEventArgs containing data related to this event. The following GdViewer.BeforeAnnotationAddedByUserEventArgs properties provide information specific to this event.

PropertyDescription
The 0-based index of the newly added annotation within the current page of the displayed document. It is a value from 0 to GetAnnotationCount-1.  
(Inherited from System.Windows.RoutedEventArgs)
(Inherited from System.Windows.RoutedEventArgs)
(Inherited from System.Windows.RoutedEventArgs)
(Inherited from System.Windows.RoutedEventArgs)
Remarks
Be aware, that this event only handles GdPicture/XMP annotations.
Example
How to utilize this event in your GdViewer control. This example shows you how to address the annotation before adding it to change its properties.
'We assume that the GdViewer1 control has been properly integrated
'and the BeforeAnnotationAddedByUser event has been properly added.
            
'Define the event.
Sub GdViewer1_BeforeAnnotationAddedByUser(ByVal sender As Object, ByVal e As GdPicture14.WPF.GdViewer.BeforeAnnotationAddedByUserEventArgs)
    Dim annot As GdPicture14.Annotations.Annotation = GdViewer1.GetAnnotationFromIdx(e.AnnotationIdx)
    If TypeOf annot Is GdPicture14.Annotations.AnnotationStickyNote Then
        CType(annot, GdPicture14.Annotations.AnnotationStickyNote).FillColor = System.Drawing.Color.Beige
    End If
End Sub
//We assume that the GdViewer1 control has been properly integrated
//and the BeforeAnnotationAddedByUser event has been properly added.
            
//Define the event.
void GdViewer1_BeforeAnnotationAddedByUser(object sender, GdPicture14.WPF.GdViewer.BeforeAnnotationAddedByUserEventArgs e)
{
    GdPicture14.Annotations.Annotation annot = GdViewer1.GetAnnotationFromIdx(e.AnnotationIdx);
    if (annot is GdPicture14.Annotations.AnnotationStickyNote)
    {
        ((GdPicture14.Annotations.AnnotationStickyNote)annot).FillColor = System.Drawing.Color.Beige;
    }
}
See Also