148 lines
5.2 KiB
VB.net

Imports System.ComponentModel
Imports System.Text
Imports DigitalData.Modules.Logging
Imports GdPicture14
Imports GdPicture14.Annotations
Partial Public Class frmFieldEditor
Private LogConfig As LogConfig
Private Logger As Logger
Private GDViewer As GdViewer
Private Manager As AnnotationManager
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath, CompanyName:="Digital Data", ProductName:="EnvelopeGenerator")
Logger = LogConfig.GetLogger()
DocumentViewer1.Init(LogConfig, "PS231031-44053-15086")
End Sub
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
If GDViewer IsNot Nothing Then
AddHandler GDViewer.BeforeAnnotationAddedByUser, AddressOf Viewer_BeforeAnnotationAddedByUser
AddHandler GDViewer.AnnotationAddedByUser, AddressOf Viewer_AnnotationAddedByUser
GDViewer.AddStickyNoteAnnotationInteractive("SIGNATUR", Color.Black, "Arial", FontStyle.Regular, 10, 1, 0)
End If
End Sub
Private Sub Viewer_AnnotationAddedByUser(AnnotationIdx As Integer)
Dim oAnnotation = GDViewer.GetAnnotationFromIdx(AnnotationIdx)
If TypeOf oAnnotation Is AnnotationStickyNote Then
Dim oStickyNote As AnnotationStickyNote = oAnnotation
oStickyNote.Width = 1
oStickyNote.Height = 1
ApplyAnnotationStyle(oAnnotation)
End If
oAnnotation.CanRotate = False
oAnnotation.CanEdit = False
oAnnotation.CanResize = False
End Sub
Private Sub Viewer_BeforeAnnotationAddedByUser(AnnotationIdx As Integer)
'NOOP
End Sub
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim oFilePath = OpenFileDialog1.FileName
DocumentViewer1.LoadFile(oFilePath)
If DocumentViewer1.PdfViewer IsNot Nothing Then
GDViewer = DocumentViewer1.PdfViewer
Manager = GDViewer.GetAnnotationManager()
Manager.InitFromGdViewer(GDViewer)
End If
End If
End Sub
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
Dim oAnnotationCount = GDViewer.GetAnnotationCount()
For index = 0 To oAnnotationCount
Dim oAnnotation As Annotation = GDViewer.GetAnnotationFromIdx(index)
If TypeOf oAnnotation Is AnnotationStickyNote Then
Dim oStickyNote As AnnotationStickyNote = oAnnotation
Dim oWidth = InchToPixel(oStickyNote.Width)
Dim oHeight = InchToPixel(oStickyNote.Height)
Dim oTop = InchToPixel(oStickyNote.Top)
Dim oLeft = InchToPixel(oStickyNote.Left)
End If
Next
End Sub
Private Function InchToPixel(pInch As Single) As Single
Return pInch * 96
End Function
Private Function PixelToInch(pPixel As Single) As Single
Return pPixel / 96
End Function
Private Sub ApplyAnnotationStyle(ByRef pAnnotation As Annotation)
If TypeOf pAnnotation Is AnnotationStickyNote Then
Dim oStickyNote As AnnotationStickyNote = pAnnotation
oStickyNote.Fill = True
oStickyNote.FillColor = Color.LightGoldenrodYellow
oStickyNote.Text = "SIGNATUR"
oStickyNote.Alignment = StringAlignment.Center
oStickyNote.LineAlignment = StringAlignment.Center
End If
End Sub
Private Sub BarButtonItem5_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem5.ItemClick
Dim oAnnotation As AnnotationStickyNote = Manager.AddStickyNoteAnnot(0, 0, 0, 0, "SIGNATUR")
If Manager.GetStat() = GdPictureStatus.OK Then
oAnnotation.Width = 2
oAnnotation.Height = 2
oAnnotation.Left = 1
oAnnotation.Top = 1
oAnnotation.Fill = True
oAnnotation.FillColor = Color.DarkRed
oAnnotation.Text = "SIGNATUR JUNGE"
If Manager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
'oManager.BurnAnnotationsToPage(True)
'GDViewer.ReloadAnnotations()
'GDViewer.Redraw()
End If
End If
End Sub
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs)
End Sub
Private Sub BarButtonItem3_ItemClick_1(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
Dim oSelected = GDViewer.GetSelectedAnnotationIdx()
If oSelected = -1 Then
Exit Sub
End If
If MsgBox("Wollen Sie die Annotation löschen?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question, Text) = DialogResult.Yes Then
GDViewer.DeleteAnnotation(oSelected)
End If
End Sub
End Class