Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Logging
Imports GdPicture14
Imports GdPicture14.Annotations

Public Class Annotations
    Inherits BaseClass

    Private Const DEFAULT_LEFT = 10
    Private Const DEFAULT_TOP = 10
    Private Const DEFAULT_WIDTH = 200
    Private Const DEFAULT_HEIGHT = 50

    Public Sub New(pLogConfig As LogConfig)
        MyBase.New(pLogConfig)
    End Sub

    Public Function AddAnnotationInteractive(pGDViewer As GdViewer, pText As String) As Boolean
        pGDViewer.AddTextAnnotationInteractive(pText, Color.Black, "Arial", Drawing.FontStyle.Bold Or Drawing.FontStyle.Underline, 12, True, Color.Red, Color.White, 1, 0)
        If pGDViewer.GetStat = GdPictureStatus.OK Then
            Return True
        Else
            Return False
        End If
    End Function

    Public Function AddAnnotation(pGDViewer As GdViewer, pText As String) As Boolean
        Try
            Dim oStatus As GdPictureStatus = GdPictureStatus.OK
            Using oManager As AnnotationManager = pGDViewer.GetAnnotationManager()
                If oManager.InitFromGdViewer(pGDViewer) = GdPictureStatus.OK AndAlso oManager.PageCount > 0 AndAlso oManager.SelectPage(1) = GdPictureStatus.OK Then
                    Using oAnnotation As AnnotationText = oManager.AddTextAnnot(0, 0, 0, 0, pText)
                        If oManager.GetStat = GdPictureStatus.OK AndAlso oAnnotation IsNot Nothing Then
                            oAnnotation.Alignment = StringAlignment.Near
                            oAnnotation.Author = Environment.UserName
                            oAnnotation.Fill = True
                            oAnnotation.FillColor = Color.LightYellow
                            oAnnotation.FontSize = 16
                            oAnnotation.ForeColor = Color.Black
                            oAnnotation.Opacity = 0.7F
                            oAnnotation.StrokeColor = Color.Yellow
                            oAnnotation.Top = DEFAULT_TOP
                            oAnnotation.Left = DEFAULT_LEFT
                            oAnnotation.Width = DEFAULT_WIDTH
                            oAnnotation.Height = DEFAULT_HEIGHT
                            oAnnotation.Text = pText

                            If oManager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
                                oManager.BurnAnnotationsToPage(True)
                            End If
                        End If
                    End Using
                End If
                oStatus = oManager.GetStat()
            End Using

            If oStatus = GdPictureStatus.OK Then
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            Return False
        End Try
    End Function


End Class
