GdPicture.NET Reference Guide
GetSelectedAnnotationIdx Method (GdViewer)
Example 





GdPicture14.WPF Namespace > GdViewer Class : GetSelectedAnnotationIdx Method
Returns an index of the selected GdPicture/XMP annotation object within the current page of the document displayed in the GdViewer control.

Be aware that this method only handles GdPicture/XMP annotations.

Syntax
'Declaration
 
Public Function GetSelectedAnnotationIdx() As Integer
public int GetSelectedAnnotationIdx()
public function GetSelectedAnnotationIdx(): Integer; 
public function GetSelectedAnnotationIdx() : int;
public: int GetSelectedAnnotationIdx(); 
public:
int GetSelectedAnnotationIdx(); 

Return Value

An index of the selected GdPicture/XMP annotation object. The returned value is between 0 and GetAnnotationCount-1 if some annotation is selected or -1 if none is selected.

Be aware that this method does not set the error status if no annotation is selected.

Remarks
Be aware that annotations are always treated relative to the currently displayed page.

Please ensure that the returned value is valid annotation index, which means it is greater then -1, before using it further. The reason is that this method does not set the error status if no annotation is selected.

Please note that this method expects to have the GdPicture XMP/Annotations Plugin to be unlocked. The method only handles GdPicture/XMP annotations as well.

Example
How to properly retrieve the selected annotation, if any.
'We assume that the GdViewer1 control has been properly integrated
'and your document has been properly displayed as well.
Dim annotIdx As Integer = GdViewer1.GetSelectedAnnotationIdx()
If annotIdx >= 0 Then
    Dim annot As GdPicture14.Annotations.Annotation = GdViewer1.GetAnnotationFromIdx(annotIdx)
    MessageBox.Show("The index of the selected annotation is: " + annotIdx + vbCrLf +
                    "  Author: " + annot.Author + "  Created: " + annot.CreationTime.ToString() + "  Subject: " + annot.Subject, "GdViewer.GetSelectedAnnotationIdx")
Else
    MessageBox.Show("No annotation is currently selected.", "GdViewer.GetSelectedAnnotationIdx")
End If
//We assume that the GdViewer1 control has been properly integrated
//and your document has been properly displayed as well.
int annotIdx = GdViewer1.GetSelectedAnnotationIdx();
if (annotIdx >= 0)
{
    GdPicture14.Annotations.Annotation annot = GdViewer1.GetAnnotationFromIdx(annotIdx);
    MessageBox.Show("The index of the selected annotation is: " + annotIdx +
                    "\n  Author: " + annot.Author + "  Created: " + annot.CreationTime + "  Subject: " + annot.Subject, "GdViewer.GetSelectedAnnotationIdx");
}
else
{
    MessageBox.Show("No annotation is currently selected.", "GdViewer.GetSelectedAnnotationIdx");
}
See Also

Reference

GdViewer Class
GdViewer Members
GetAnnotationCount Method
GetAnnotationFromIdx Method
SelectAnnotation Method
GetAnnotationManager Method