14-08-23
This commit is contained in:
parent
7c31ccee1c
commit
069f5a6f88
@ -1,5 +1,5 @@
|
|||||||
Public Class EnvelopeDocumentElement
|
Public Class EnvelopeDocumentElement
|
||||||
Public Property Id As Integer = 0
|
Public Property Id As Integer = -1
|
||||||
Public Property X As Double
|
Public Property X As Double
|
||||||
Public Property Y As Double
|
Public Property Y As Double
|
||||||
Public Property Width As Double
|
Public Property Width As Double
|
||||||
@ -11,5 +11,18 @@
|
|||||||
Public Property [ReadOnly] As Boolean = False
|
Public Property [ReadOnly] As Boolean = False
|
||||||
Public Property Page As Integer = 1
|
Public Property Page As Integer = 1
|
||||||
Public Property Status As Constants.ElementStatus = Constants.ElementStatus.Created
|
Public Property Status As Constants.ElementStatus = Constants.ElementStatus.Created
|
||||||
Public Property AnnotationIndex As Integer
|
Public Property Index As Integer = 0
|
||||||
|
|
||||||
|
Public ReadOnly Property Top As Single
|
||||||
|
Get
|
||||||
|
Return Math.Round(Y, 5)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Public ReadOnly Property Left As Single
|
||||||
|
Get
|
||||||
|
Return Math.Round(X, 5)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -19,8 +19,7 @@ Public Class ElementModel
|
|||||||
.Y = pRow.ItemEx("POSITION_Y", 0.0),
|
.Y = pRow.ItemEx("POSITION_Y", 0.0),
|
||||||
.Width = pRow.ItemEx("WIDTH", 0.0),
|
.Width = pRow.ItemEx("WIDTH", 0.0),
|
||||||
.Height = pRow.ItemEx("HEIGHT", 0.0),
|
.Height = pRow.ItemEx("HEIGHT", 0.0),
|
||||||
.Page = pRow.ItemEx("PAGE", 0),
|
.Page = pRow.ItemEx("PAGE", 0)
|
||||||
.AnnotationIndex = pRow.ItemEx("ANNOTATION_INDEX", 0)
|
|
||||||
}
|
}
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ Public Class ElementModel
|
|||||||
|
|
||||||
Public Function List(pDocumentId As Integer) As List(Of EnvelopeDocumentElement)
|
Public Function List(pDocumentId As Integer) As List(Of EnvelopeDocumentElement)
|
||||||
Try
|
Try
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] WHERE DOCUMENT_ID = {pDocumentId} ORDER BY PAGE ASC, ANNOTATION_INDEX ASC"
|
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] WHERE DOCUMENT_ID = {pDocumentId} ORDER BY PAGE ASC"
|
||||||
Dim oTable = Database.GetDatatable(oSql)
|
Dim oTable = Database.GetDatatable(oSql)
|
||||||
|
|
||||||
Return oTable?.Rows.Cast(Of DataRow).
|
Return oTable?.Rows.Cast(Of DataRow).
|
||||||
@ -67,8 +66,7 @@ Public Class ElementModel
|
|||||||
,[REQUIRED]
|
,[REQUIRED]
|
||||||
,[READ_ONLY]
|
,[READ_ONLY]
|
||||||
,[STATUS]
|
,[STATUS]
|
||||||
,[PAGE]
|
,[PAGE])
|
||||||
,[ANNOTATION_INDEX])
|
|
||||||
VALUES
|
VALUES
|
||||||
(@DOCUMENT_ID
|
(@DOCUMENT_ID
|
||||||
,@RECEIVER_ID
|
,@RECEIVER_ID
|
||||||
@ -80,8 +78,7 @@ Public Class ElementModel
|
|||||||
,@REQUIRED
|
,@REQUIRED
|
||||||
,@READ_ONLY
|
,@READ_ONLY
|
||||||
,@STATUS
|
,@STATUS
|
||||||
,@PAGE
|
,@PAGE)"
|
||||||
,@INDEX)"
|
|
||||||
|
|
||||||
Dim oCommand As New SqlCommand(oSql)
|
Dim oCommand As New SqlCommand(oSql)
|
||||||
oCommand.Parameters.Add("DOCUMENT_ID", SqlDbType.NVarChar).Value = pElement.DocumentId
|
oCommand.Parameters.Add("DOCUMENT_ID", SqlDbType.NVarChar).Value = pElement.DocumentId
|
||||||
@ -95,7 +92,6 @@ Public Class ElementModel
|
|||||||
oCommand.Parameters.Add("READ_ONLY", SqlDbType.Bit).Value = pElement.ReadOnly
|
oCommand.Parameters.Add("READ_ONLY", SqlDbType.Bit).Value = pElement.ReadOnly
|
||||||
oCommand.Parameters.Add("STATUS", SqlDbType.NVarChar).Value = pElement.Status.ToString
|
oCommand.Parameters.Add("STATUS", SqlDbType.NVarChar).Value = pElement.Status.ToString
|
||||||
oCommand.Parameters.Add("PAGE", SqlDbType.Int).Value = pElement.Page
|
oCommand.Parameters.Add("PAGE", SqlDbType.Int).Value = pElement.Page
|
||||||
oCommand.Parameters.Add("INDEX", SqlDbType.Int).Value = pElement.AnnotationIndex
|
|
||||||
|
|
||||||
If Database.ExecuteNonQuery(oCommand) Then
|
If Database.ExecuteNonQuery(oCommand) Then
|
||||||
pElement.Id = GetElementId(pElement)
|
pElement.Id = GetElementId(pElement)
|
||||||
|
|||||||
@ -12,6 +12,12 @@ Public Class FieldEditorController
|
|||||||
Private ReadOnly Document As EnvelopeDocument
|
Private ReadOnly Document As EnvelopeDocument
|
||||||
Public Property Elements As New List(Of EnvelopeDocumentElement)
|
Public Property Elements As New List(Of EnvelopeDocumentElement)
|
||||||
|
|
||||||
|
Public Class ElementInfo
|
||||||
|
Public ReceiverId As Integer
|
||||||
|
Public Page As Integer
|
||||||
|
Public Guid As Integer
|
||||||
|
End Class
|
||||||
|
|
||||||
Public Sub New(pState As State, pDocument As EnvelopeDocument)
|
Public Sub New(pState As State, pDocument As EnvelopeDocument)
|
||||||
MyBase.New(pState.LogConfig)
|
MyBase.New(pState.LogConfig)
|
||||||
Database = pState.Database
|
Database = pState.Database
|
||||||
@ -20,19 +26,56 @@ Public Class FieldEditorController
|
|||||||
ElementModel = New ElementModel(pState)
|
ElementModel = New ElementModel(pState)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub AddOrUpdateElement(pAnnotation As AnnotationStickyNote)
|
Public Function GetElementInfo(pAnnotationTag As String) As ElementInfo
|
||||||
Dim oTag As String() = pAnnotation.Tag.Split("|"c)
|
Dim oTag As String() = pAnnotationTag.Split("|"c)
|
||||||
Dim oReceiverId = Integer.Parse(oTag(0))
|
Dim oReceiverId = Integer.Parse(oTag(0))
|
||||||
Dim oPage = Integer.Parse(oTag(1))
|
Dim oPage = Integer.Parse(oTag(1))
|
||||||
Dim oIndex = Integer.Parse(oTag(2))
|
Dim oGuid = Integer.Parse(oTag(2))
|
||||||
Dim oELement = Elements.Where(Function(e) e.AnnotationIndex = oIndex And e.Page = oPage And e.ReceiverId = oReceiverId).SingleOrDefault()
|
|
||||||
|
|
||||||
If oELement IsNot Nothing Then
|
Return New ElementInfo With {
|
||||||
oELement.Height = pAnnotation.Height
|
.Guid = oGuid,
|
||||||
oELement.Width = pAnnotation.Width
|
.Page = oPage,
|
||||||
oELement.X = pAnnotation.Left
|
.ReceiverId = oReceiverId
|
||||||
oELement.Y = pAnnotation.Top
|
}
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function GetElementByPosition(pAnnotation As AnnotationStickyNote, pPage As Integer, pReceiverId As Integer) As EnvelopeDocumentElement
|
||||||
|
Dim oElement = Elements.
|
||||||
|
Where(Function(e)
|
||||||
|
Return e.Left = CSng(Math.Round(pAnnotation.Left, 5)) And
|
||||||
|
e.Top = CSng(Math.Round(pAnnotation.Top, 5)) And
|
||||||
|
e.Page = pPage And
|
||||||
|
e.ReceiverId = pReceiverId
|
||||||
|
End Function).SingleOrDefault()
|
||||||
|
Return oElement
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function GetElementByGuid(pGuid As Integer) As EnvelopeDocumentElement
|
||||||
|
Dim oElement = Elements.Where(Function(e) pGuid = e.Id).SingleOrDefault()
|
||||||
|
Return oElement
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function GetElement(pAnnotation As AnnotationStickyNote) As EnvelopeDocumentElement
|
||||||
|
Dim oInfo = GetElementInfo(pAnnotation.Tag)
|
||||||
|
|
||||||
|
If oInfo.Guid = -1 Then
|
||||||
|
Return GetElementByPosition(pAnnotation, oInfo.Page, oInfo.ReceiverId)
|
||||||
Else
|
Else
|
||||||
|
Return GetElementByGuid(oInfo.Guid)
|
||||||
|
End If
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Sub AddOrUpdateElement(pAnnotation As AnnotationStickyNote)
|
||||||
|
Dim oElement = GetElement(pAnnotation)
|
||||||
|
|
||||||
|
If oElement IsNot Nothing Then
|
||||||
|
oElement.Height = pAnnotation.Height
|
||||||
|
oElement.Width = pAnnotation.Width
|
||||||
|
oElement.X = pAnnotation.Left
|
||||||
|
oElement.Y = pAnnotation.Top
|
||||||
|
Else
|
||||||
|
Dim oInfo = GetElementInfo(pAnnotation.Tag)
|
||||||
|
|
||||||
Elements.Add(New EnvelopeDocumentElement() With {
|
Elements.Add(New EnvelopeDocumentElement() With {
|
||||||
.ElementType = Common.Constants.ElementType.Signature.ToString,
|
.ElementType = Common.Constants.ElementType.Signature.ToString,
|
||||||
.Height = pAnnotation.Height,
|
.Height = pAnnotation.Height,
|
||||||
@ -40,13 +83,18 @@ Public Class FieldEditorController
|
|||||||
.X = pAnnotation.Left,
|
.X = pAnnotation.Left,
|
||||||
.Y = pAnnotation.Top,
|
.Y = pAnnotation.Top,
|
||||||
.DocumentId = Document.Id,
|
.DocumentId = Document.Id,
|
||||||
.ReceiverId = oReceiverId,
|
.ReceiverId = oInfo.ReceiverId,
|
||||||
.AnnotationIndex = oIndex,
|
.Page = oInfo.Page
|
||||||
.Page = oPage
|
|
||||||
})
|
})
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Public Function ClearElements(pPage As Integer, pReceiverId As Integer) As IEnumerable(Of EnvelopeDocumentElement)
|
||||||
|
Return Elements.
|
||||||
|
Where(Function(e) e.Page <> pPage And e.ReceiverId <> pReceiverId).
|
||||||
|
ToList()
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function LoadElements() As Boolean
|
Public Function LoadElements() As Boolean
|
||||||
Elements = ElementModel.List(Document.Id)
|
Elements = ElementModel.List(Document.Id)
|
||||||
|
|
||||||
@ -77,4 +125,20 @@ Public Class FieldEditorController
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function DeleteElement(pElement As EnvelopeDocumentElement) As Boolean
|
||||||
|
Try
|
||||||
|
' Element aus Datenbank löschen
|
||||||
|
If ElementModel.DeleteElement(pElement) Then
|
||||||
|
Dim oElement = New List(Of EnvelopeDocumentElement)() From {pElement}
|
||||||
|
Elements = Elements.Except(oElement).ToList()
|
||||||
|
Return True
|
||||||
|
Else
|
||||||
|
Logger.Error("Element [{0}] could not be deleted!", pElement.Id)
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return False
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
Imports DevExpress.XtraBars
|
Imports System.Windows.Forms.VisualStyles.VisualStyleElement.Window
|
||||||
|
Imports DevExpress.Utils
|
||||||
|
Imports DevExpress.XtraBars
|
||||||
|
Imports DevExpress.XtraBars.Ribbon.ViewInfo
|
||||||
Imports DigitalData.Modules.Logging
|
Imports DigitalData.Modules.Logging
|
||||||
Imports EnvelopeGenerator.Common
|
Imports EnvelopeGenerator.Common
|
||||||
Imports GdPicture14
|
Imports GdPicture14
|
||||||
Imports GdPicture14.Annotations
|
Imports GdPicture14.Annotations
|
||||||
|
Imports NLog.Fluent
|
||||||
|
|
||||||
Partial Public Class frmFieldEditor
|
Partial Public Class frmFieldEditor
|
||||||
Private LogConfig As LogConfig
|
Private LogConfig As LogConfig
|
||||||
@ -63,23 +67,38 @@ Partial Public Class frmFieldEditor
|
|||||||
|
|
||||||
Private Function CreateBarItem(pReceiver As EnvelopeReceiver) As BarItem
|
Private Function CreateBarItem(pReceiver As EnvelopeReceiver) As BarItem
|
||||||
Dim oItem = New BarButtonItem(BarManager1, pReceiver.Name)
|
Dim oItem = New BarButtonItem(BarManager1, pReceiver.Name)
|
||||||
AddHandler oItem.ItemClick, AddressOf BarItem_Click
|
AddHandler oItem.ItemClick, AddressOf ReceiverItem_Click
|
||||||
oItem.Tag = pReceiver
|
oItem.Tag = pReceiver
|
||||||
Return oItem
|
Return oItem
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Sub BarItem_Click(sender As Object, e As ItemClickEventArgs)
|
Private Sub ReceiverItem_Click(sender As Object, e As ItemClickEventArgs)
|
||||||
AddElements()
|
Me.SuspendLayout()
|
||||||
|
|
||||||
|
Dim oReceiver As EnvelopeReceiver = e.Item.Tag
|
||||||
|
Dim oCurrentPage = GDViewer.CurrentPage
|
||||||
|
Dim oCurrentPosition = GDViewer.GetVScrollBarPosition()
|
||||||
|
|
||||||
|
If oReceiver.Id = SelectedReceiver.Id Then
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
AddElementsToController()
|
||||||
|
|
||||||
If Controller.SaveElements(SelectedReceiver.Id) Then
|
If Controller.SaveElements(SelectedReceiver.Id) Then
|
||||||
Dim oReceiver As EnvelopeReceiver = e.Item.Tag
|
|
||||||
SetReceiver(oReceiver)
|
SetReceiver(oReceiver)
|
||||||
ClearAnnotations()
|
ClearAnnotations()
|
||||||
LoadAnnotations(oReceiver.Id)
|
LoadAnnotations(oReceiver.Id)
|
||||||
GDViewer.DisplayFirstPage()
|
DisplayPage(oCurrentPage)
|
||||||
|
GDViewer.SetVScrollBarPosition(oCurrentPosition)
|
||||||
|
GDViewer.Redraw()
|
||||||
|
TestViewerActionSuccessful("ReceiverItem_Click/Redraw")
|
||||||
Else
|
Else
|
||||||
MsgBox("Elemente konnten nicht gespeichert werden!", MsgBoxStyle.Critical, Text)
|
MsgBox("Elemente konnten nicht gespeichert werden!", MsgBoxStyle.Critical, Text)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
Me.ResumeLayout()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub SetReceiver(pReceiver As EnvelopeReceiver)
|
Private Sub SetReceiver(pReceiver As EnvelopeReceiver)
|
||||||
@ -87,7 +106,14 @@ Partial Public Class frmFieldEditor
|
|||||||
SelectedReceiver = pReceiver
|
SelectedReceiver = pReceiver
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
Private Sub DisplayPage(pPage As Integer)
|
||||||
|
GDViewer.LockViewer = True
|
||||||
|
GDViewer.DisplayPage(pPage)
|
||||||
|
GDViewer.LockViewer = False
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub BarButtonItem1_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
||||||
If GDViewer IsNot Nothing Then
|
If GDViewer IsNot Nothing Then
|
||||||
|
|
||||||
AddHandler GDViewer.BeforeAnnotationAddedByUser, AddressOf Viewer_BeforeAnnotationAddedByUser
|
AddHandler GDViewer.BeforeAnnotationAddedByUser, AddressOf Viewer_BeforeAnnotationAddedByUser
|
||||||
@ -102,7 +128,7 @@ Partial Public Class frmFieldEditor
|
|||||||
Private Sub Viewer_AnnotationAddedByUser(pAnnotationIdx As Integer)
|
Private Sub Viewer_AnnotationAddedByUser(pAnnotationIdx As Integer)
|
||||||
Dim oAnnotation = GDViewer.GetAnnotationFromIdx(pAnnotationIdx)
|
Dim oAnnotation = GDViewer.GetAnnotationFromIdx(pAnnotationIdx)
|
||||||
Dim oPage = GDViewer.CurrentPage
|
Dim oPage = GDViewer.CurrentPage
|
||||||
Dim oTag = GetAnnotationTag(SelectedReceiver.Id, oPage, pAnnotationIdx)
|
Dim oTag = GetAnnotationTag(SelectedReceiver.Id, oPage, -1)
|
||||||
|
|
||||||
If TypeOf oAnnotation Is AnnotationStickyNote Then
|
If TypeOf oAnnotation Is AnnotationStickyNote Then
|
||||||
Dim oStickyNote As AnnotationStickyNote = oAnnotation
|
Dim oStickyNote As AnnotationStickyNote = oAnnotation
|
||||||
@ -123,22 +149,31 @@ Partial Public Class frmFieldEditor
|
|||||||
'NOOP
|
'NOOP
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub btnSave_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSave.ItemClick
|
Private Sub btnSave_ItemClick(sender As Object, e As ItemClickEventArgs) Handles btnSave.ItemClick
|
||||||
'TODO: Save Annotations in Background
|
Dim oCurrentPage = GDViewer.CurrentPage
|
||||||
AddElements()
|
|
||||||
|
AddElementsToController()
|
||||||
|
|
||||||
If Not Controller.SaveElements(SelectedReceiver.Id) Then
|
If Not Controller.SaveElements(SelectedReceiver.Id) Then
|
||||||
MsgBox("Elemente konnten nicht gespeichert werden!", MsgBoxStyle.Critical, Text)
|
MsgBox("Elemente konnten nicht gespeichert werden!", MsgBoxStyle.Critical, Text)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
GDViewer.DisplayPage(GDViewer.CurrentPage)
|
UpdateAnnotationTag()
|
||||||
|
DisplayPage(oCurrentPage)
|
||||||
|
GDViewer.Redraw()
|
||||||
|
TestViewerActionSuccessful("btnSave_ItemClick/Redraw")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub AddElements()
|
Private Sub AddElementsToController()
|
||||||
Dim oPageCount = GDViewer.PageCount
|
Dim oPageCount = GDViewer.PageCount
|
||||||
|
|
||||||
For oPage = 1 To oPageCount
|
For oPage = 1 To oPageCount
|
||||||
GDViewer.DisplayPage(oPage)
|
GDViewer.DisplayPage(oPage)
|
||||||
|
AddElementsToController(oPage)
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub AddElementsToController(pPage As Integer)
|
||||||
Dim oAnnotationCount = GDViewer.GetAnnotationCount()
|
Dim oAnnotationCount = GDViewer.GetAnnotationCount()
|
||||||
|
|
||||||
For oAnnotationIndex = 0 To oAnnotationCount - 1
|
For oAnnotationIndex = 0 To oAnnotationCount - 1
|
||||||
@ -148,9 +183,33 @@ Partial Public Class frmFieldEditor
|
|||||||
Controller.AddOrUpdateElement(oStickyNote)
|
Controller.AddOrUpdateElement(oStickyNote)
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub UpdateAnnotationTag()
|
||||||
|
|
||||||
|
Dim oPageCount = GDViewer.PageCount
|
||||||
|
|
||||||
|
For oPage = 1 To oPageCount
|
||||||
|
GDViewer.DisplayPage(oPage)
|
||||||
|
|
||||||
|
Dim oAnnotationCount = GDViewer.GetAnnotationCount()
|
||||||
|
For oAnnotationIndex = 0 To oAnnotationCount - 1
|
||||||
|
Dim oAnnotation As Annotation = GDViewer.GetAnnotationFromIdx(oAnnotationIndex)
|
||||||
|
If TypeOf oAnnotation Is AnnotationStickyNote Then
|
||||||
|
Dim oStickyNote As AnnotationStickyNote = oAnnotation
|
||||||
|
Dim oTag = oStickyNote.Tag
|
||||||
|
Dim oInfo = Controller.GetElementInfo(oTag)
|
||||||
|
|
||||||
|
If oInfo.Guid = -1 Then
|
||||||
|
Dim oElement = Controller.GetElement(oStickyNote)
|
||||||
|
oStickyNote.Tag = GetAnnotationTag(SelectedReceiver.Id, oPage, oElement.Id)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Next
|
||||||
Next
|
Next
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Private Sub ApplyAnnotationStyle(ByRef pAnnotation As Annotation)
|
Private Sub ApplyAnnotationStyle(ByRef pAnnotation As Annotation)
|
||||||
If TypeOf pAnnotation Is AnnotationStickyNote Then
|
If TypeOf pAnnotation Is AnnotationStickyNote Then
|
||||||
Dim oStickyNote As AnnotationStickyNote = pAnnotation
|
Dim oStickyNote As AnnotationStickyNote = pAnnotation
|
||||||
@ -163,21 +222,36 @@ Partial Public Class frmFieldEditor
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Private Sub BarButtonItem3_ItemClick_1(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDelete.ItemClick
|
Private Sub btnDelete_ItemClick(sender As Object, e As ItemClickEventArgs) Handles btnDelete.ItemClick
|
||||||
Dim oSelected = GDViewer.GetSelectedAnnotationIdx()
|
Dim oSelected = GDViewer.GetSelectedAnnotationIdx()
|
||||||
|
|
||||||
|
If TestViewerActionSuccessful("btnDelete_ItemClick/GetSelectedAnnotationIdx") = False Then
|
||||||
|
Logger.Warn("Selected Annotation could not be fetched!")
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
If oSelected = -1 Then
|
If oSelected = -1 Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If MsgBox("Wollen Sie die Annotation löschen?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question, Text) = DialogResult.Yes Then
|
If MsgBox("Wollen Sie die Annotation löschen?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question, Text) = DialogResult.Yes Then
|
||||||
|
Dim oAnnotation = GDViewer.GetAnnotationFromIdx(oSelected)
|
||||||
|
Dim oElement = Controller.GetElement(oAnnotation)
|
||||||
|
|
||||||
|
' Delete Element if it was already saved to db
|
||||||
|
If oElement IsNot Nothing Then
|
||||||
|
Controller.DeleteElement(oElement)
|
||||||
|
End If
|
||||||
|
|
||||||
GDViewer.DeleteAnnotation(oSelected)
|
GDViewer.DeleteAnnotation(oSelected)
|
||||||
|
If TestViewerActionSuccessful("btnDelete_ItemClick/DeleteAnnotation") = False Then
|
||||||
|
Logger.Warn("Annotation could not be deleted!")
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub LoadAnnotation(pElement As EnvelopeDocumentElement, pReceiverId As Integer)
|
Private Sub LoadAnnotation(pElement As EnvelopeDocumentElement, pReceiverId As Integer)
|
||||||
Dim oAnnotation As AnnotationStickyNote = Manager.AddStickyNoteAnnot(0, 0, 0, 0, "SIGNATUR")
|
Dim oAnnotation As AnnotationStickyNote = Manager.AddStickyNoteAnnot(0, 0, 0, 0, "SIGNATUR")
|
||||||
Dim oIndex = Manager.GetAnnotationIdx(oAnnotation)
|
|
||||||
Dim oPage = pElement.Page
|
Dim oPage = pElement.Page
|
||||||
|
|
||||||
If Manager.GetStat() = GdPictureStatus.OK Then
|
If Manager.GetStat() = GdPictureStatus.OK Then
|
||||||
@ -188,29 +262,54 @@ Partial Public Class frmFieldEditor
|
|||||||
oAnnotation.Fill = True
|
oAnnotation.Fill = True
|
||||||
oAnnotation.FillColor = Color.DarkRed
|
oAnnotation.FillColor = Color.DarkRed
|
||||||
oAnnotation.Text = "SIGNATUR"
|
oAnnotation.Text = "SIGNATUR"
|
||||||
oAnnotation.Tag = GetAnnotationTag(pReceiverId, oPage, oIndex)
|
oAnnotation.Tag = GetAnnotationTag(pReceiverId, oPage, pElement.Id)
|
||||||
|
Else
|
||||||
'If Manager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
|
Dim oStatus = Manager.GetStat()
|
||||||
'End If
|
MsgBox(String.Format("GDViewer returned error [{0}] on action [{1}]", oStatus.ToString, "LoadAnnotation"))
|
||||||
|
Logger.Error("GDViewer returned error [{0}] on action [{1}]", oStatus.ToString, "LoadAnnotation")
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub ClearAnnotations()
|
Private Sub ClearAnnotations()
|
||||||
Dim oPageCount = GDViewer.PageCount
|
Dim oPageCount = GDViewer.PageCount
|
||||||
|
|
||||||
For oPage = 1 To oPageCount
|
For oPage = 1 To oPageCount
|
||||||
GDViewer.DisplayPage(oPage)
|
DisplayPage(oPage)
|
||||||
Dim oAnnotationCount = GDViewer.GetAnnotationCount()
|
Dim oAnnotationCount = GDViewer.GetAnnotationCount()
|
||||||
|
|
||||||
For oAnnotationIndex = 0 To oAnnotationCount - 1
|
For oAnnotationIndex = 0 To oAnnotationCount - 1
|
||||||
GDViewer.DeleteAnnotation(oAnnotationIndex)
|
' We always delete the first item in the list of annotations,
|
||||||
|
' because DeleteAnnotation expects and index, not an identifier
|
||||||
|
GDViewer.DeleteAnnotation(0)
|
||||||
|
If TestViewerActionSuccessful("ClearAnnotations") = False Then
|
||||||
|
Logger.Warn("Annotation could not be cleared!")
|
||||||
|
End If
|
||||||
Next
|
Next
|
||||||
Next
|
Next
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Function TestViewerActionSuccessful(pAction As String) As Boolean
|
||||||
|
Dim oStatus = GDViewer.GetStat()
|
||||||
|
If oStatus = GdPictureStatus.OK Then
|
||||||
|
Return True
|
||||||
|
Else
|
||||||
|
MsgBox(String.Format("GDViewer returned error [{0}] on action [{1}]", oStatus.ToString, pAction))
|
||||||
|
Logger.Error("GDViewer returned error [{0}] on action [{1}]", oStatus.ToString, pAction)
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
Private Sub LoadAnnotations(pReceiverId As Integer)
|
Private Sub LoadAnnotations(pReceiverId As Integer)
|
||||||
Dim oPageCount = GDViewer.PageCount
|
Dim oPageCount = GDViewer.PageCount
|
||||||
|
|
||||||
For oPage = 1 To oPageCount
|
For oPage = 1 To oPageCount
|
||||||
GDViewer.DisplayPage(oPage)
|
DisplayPage(oPage)
|
||||||
|
|
||||||
|
If TestViewerActionSuccessful("LoadAnnotations/DisplayPage") = False Then
|
||||||
|
Logger.Warn("Page could not be displayed!")
|
||||||
|
End If
|
||||||
|
|
||||||
Dim oCurrentPage = oPage
|
Dim oCurrentPage = oPage
|
||||||
Dim oElements = Controller.Elements.
|
Dim oElements = Controller.Elements.
|
||||||
Where(Function(e) e.Page = oCurrentPage And e.ReceiverId = pReceiverId).
|
Where(Function(e) e.Page = oCurrentPage And e.ReceiverId = pReceiverId).
|
||||||
@ -222,8 +321,8 @@ Partial Public Class frmFieldEditor
|
|||||||
Next
|
Next
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Function GetAnnotationTag(pReceiver As Integer, pPage As Integer, pIndex As Integer) As String
|
Private Function GetAnnotationTag(pReceiver As Integer, pPage As Integer, pGuid As Integer) As String
|
||||||
Return $"{pReceiver}|{pPage}|{pIndex}"
|
Return $"{pReceiver}|{pPage}|{pGuid}"
|
||||||
End Function
|
End Function
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user