This commit is contained in:
Jonathan Jenne
2023-12-07 14:02:17 +01:00
parent cd7af973a1
commit bbfccc4a4f
4 changed files with 399 additions and 416 deletions

View File

@@ -23,7 +23,9 @@ Partial Public Class frmFieldEditor
Public Property SelectedReceiver As EnvelopeReceiver = Nothing
Public Property State As State
Private SIGNATURE_LABEL As String = Resources.Envelope.Signature '"Signatur"
Private UnsavedChanges As Boolean = False
Private Const SIGNATURE_LABEL = "Signatur"
Private Const SIGNATURE_WIDTH As Single = 1
Private Const SIGNATURE_HEIGHT As Single = 0.5
@@ -35,7 +37,7 @@ Partial Public Class frmFieldEditor
LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath, CompanyName:="Digital Data", ProductName:="EnvelopeGenerator")
Logger = LogConfig.GetLogger()
Me.Text = State.DbConfig.ExternalProgramName + " - " + Resources.Envelope.Signature_Editor
Me.Text = State.DbConfig.ExternalProgramName + " - Signatur-Editor"
If Document Is Nothing Then
Throw New ArgumentNullException("Document")
@@ -77,6 +79,7 @@ Partial Public Class frmFieldEditor
GDViewer = DocumentViewer1.PdfViewer
AddHandler GDViewer.BeforeAnnotationAddedByUser, AddressOf Viewer_BeforeAnnotationAddedByUser
AddHandler GDViewer.AnnotationAddedByUser, AddressOf Viewer_AnnotationAddedByUser
AddHandler GDViewer.AnnotationMoved, AddressOf Viewer_AnnotationMoved
Manager = GDViewer.GetAnnotationManager()
Manager.InitFromGdViewer(GDViewer)
@@ -85,6 +88,10 @@ Partial Public Class frmFieldEditor
End If
End Sub
Private Sub Viewer_AnnotationMoved(AnnotationIdx As Integer)
UnsavedChanges = True
End Sub
Private Function CreateBarItem(pReceiver As EnvelopeReceiver) As BarItem
Dim oItem = New BarButtonItem(BarManager1, pReceiver.Name)
Dim oBaseCircle As SvgImage = SvgImageCollection1.Item(0)
@@ -158,19 +165,26 @@ Partial Public Class frmFieldEditor
End Sub
Private Sub btnSave_ItemClick(sender As Object, e As ItemClickEventArgs) Handles btnSave.ItemClick
Private Sub SaveElements()
Dim oCurrentPage = GDViewer.CurrentPage
AddElementsToController()
If Not Controller.SaveElements(SelectedReceiver.Id) Then
MsgBox(Resources.Envelope.Elements_could_not_be_saved, MsgBoxStyle.Critical, Text)
Exit Sub
End If
UpdateAnnotationTag()
DisplayPage(oCurrentPage)
GDViewer.Redraw()
TestViewerActionSuccessful("btnSave_ItemClick/Redraw")
UnsavedChanges = False
End Sub
Private Sub btnSave_ItemClick(sender As Object, e As ItemClickEventArgs) Handles btnSave.ItemClick
SaveElements()
End Sub
Private Sub AddElementsToController()
@@ -236,7 +250,7 @@ Partial Public Class frmFieldEditor
Exit Sub
End If
If MsgBox(Resources.Envelope.Do_you_want_to_delete_the_signature, MsgBoxStyle.YesNo Or MsgBoxStyle.Question, Text) = DialogResult.Yes Then
If MsgBox("Wollen Sie die Signatur löschen?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question, Text) = DialogResult.Yes Then
Dim oAnnotation = GDViewer.GetAnnotationFromIdx(oSelected)
Dim oElement = Controller.GetElement(oAnnotation)
@@ -292,6 +306,8 @@ Partial Public Class frmFieldEditor
ApplyAnnotationStyleForExistingAnnotation(oAnnotation, SelectedReceiver.Color)
End If
UnsavedChanges = True
End Sub
Private Function GetOrientation() As PageOrientation
@@ -391,8 +407,19 @@ Partial Public Class frmFieldEditor
Return $"{pReceiver}|{pPage}|{pGuid}"
End Function
Private Sub PopupMenu1_BeforePopup(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles PopupMenu1.BeforePopup
Private Sub frmFieldEditor_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If UnsavedChanges Then
Dim oResult = MsgBox("Es sind ungespeicherte Änderungen vorhanden. Wollen Sie diese Speichern?", MsgBoxStyle.Question Or MsgBoxStyle.YesNoCancel, Text)
Select Case oResult
Case MsgBoxResult.Cancel
e.Cancel = True
Case MsgBoxResult.Yes
SaveElements()
Case Else
' just let the form close
End Select
End If
End Sub
End Class