Projektdateien hinzufügen.
This commit is contained in:
70
Classes/Annotations.vb
Normal file
70
Classes/Annotations.vb
Normal file
@@ -0,0 +1,70 @@
|
||||
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
|
||||
|
||||
'pGDViewer.ann
|
||||
|
||||
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
|
||||
137
Classes/Search.vb
Normal file
137
Classes/Search.vb
Normal file
@@ -0,0 +1,137 @@
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports GdPicture14
|
||||
|
||||
Public Class Search
|
||||
Inherits BaseClass
|
||||
|
||||
Public Property SearchQuery As String = ""
|
||||
Public Property CaseSensitive As Boolean = False
|
||||
Public Property WholeWords As Boolean = False
|
||||
|
||||
Private _Viewer As GdViewer = Nothing
|
||||
Private _AnnotationManager As New AnnotationManager()
|
||||
|
||||
Private _CurrentPage As Integer = 0
|
||||
Private _CurrentQuery As String = ""
|
||||
Private _CurrentOccurrenceCount = 0
|
||||
Private _CurrentSelectedOccurrence = 0
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pGDViewer As GdViewer)
|
||||
MyBase.New(pLogConfig)
|
||||
_Viewer = pGDViewer
|
||||
_AnnotationManager.InitFromGdViewer(pGDViewer)
|
||||
|
||||
AddHandler _Viewer.PageDisplayed, AddressOf Viewer_PageDisplayed
|
||||
End Sub
|
||||
|
||||
Public Sub SearchAll(pQuery As String)
|
||||
' Exit, if query has not changed
|
||||
If _CurrentQuery = pQuery Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' Save query
|
||||
_CurrentQuery = pQuery
|
||||
|
||||
' Reset previous highlights, then search for the new query
|
||||
_Viewer.RemoveAllRegions()
|
||||
DoSearchText()
|
||||
|
||||
' Select the next occurrence
|
||||
NextHighlight()
|
||||
End Sub
|
||||
|
||||
Public Sub NextHighlight()
|
||||
' This also applies when the page has *NO* occurrences, so 0 = 0
|
||||
If _CurrentOccurrenceCount = _CurrentSelectedOccurrence Then
|
||||
Dim oCount = 0
|
||||
' If there are no occurrences on the current page, got to the *next page*
|
||||
While _CurrentOccurrenceCount = _CurrentSelectedOccurrence And _CurrentPage <= _Viewer.PageCount
|
||||
oCount += 1
|
||||
If _CurrentPage = _Viewer.PageCount Then
|
||||
_Viewer.DisplayFirstPage()
|
||||
Else
|
||||
_Viewer.DisplayNextPage()
|
||||
End If
|
||||
If oCount > 333 Then
|
||||
Exit While
|
||||
End If
|
||||
End While
|
||||
|
||||
' Safeguard against selecting a non-existing occurrence on the last page
|
||||
If _CurrentOccurrenceCount > 0 Then
|
||||
SelectHighlight(1)
|
||||
Else
|
||||
' Disable next button
|
||||
End If
|
||||
Else
|
||||
' Otherwise just select the next occurrence
|
||||
SelectHighlight(_CurrentSelectedOccurrence + 1)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub PrevHighlight()
|
||||
If _CurrentOccurrenceCount = 0 Or _CurrentSelectedOccurrence = 1 Then
|
||||
Dim oCount = 0
|
||||
While (_CurrentOccurrenceCount = 0 Or _CurrentSelectedOccurrence = 1) And _CurrentPage >= 1
|
||||
oCount += 1
|
||||
If _CurrentPage = 1 Then
|
||||
_Viewer.DisplayLastPage()
|
||||
Else
|
||||
_Viewer.DisplayPreviousPage()
|
||||
End If
|
||||
If oCount > 333 Then
|
||||
Exit While
|
||||
End If
|
||||
End While
|
||||
|
||||
If _CurrentOccurrenceCount > 0 Then
|
||||
SelectHighlight(_CurrentOccurrenceCount)
|
||||
End If
|
||||
|
||||
Else
|
||||
' Otherwise just select the previous occurrence
|
||||
SelectHighlight(_CurrentSelectedOccurrence - 1)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub SelectHighlight(pOccurrence As Integer)
|
||||
Dim oFound = _Viewer.SearchText(_CurrentQuery, pOccurrence, CaseSensitive, WholeWords)
|
||||
If _Viewer.GetStat() = GdPictureStatus.OK And _Viewer.IsRect() Then
|
||||
_Viewer.RectIsEditable = False
|
||||
_Viewer.CenterOnRect()
|
||||
|
||||
_CurrentSelectedOccurrence = pOccurrence
|
||||
Else
|
||||
_CurrentSelectedOccurrence = 0
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub Viewer_PageDisplayed()
|
||||
If _CurrentPage <> _Viewer.CurrentPage Then
|
||||
_CurrentPage = _Viewer.CurrentPage
|
||||
|
||||
If _CurrentQuery.Length > 0 Then
|
||||
DoSearchText()
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub DoSearchText()
|
||||
|
||||
|
||||
_Viewer.SearchText(_CurrentQuery, 0, CaseSensitive, WholeWords)
|
||||
|
||||
Dim oRegionCount = _Viewer.RegionCount()
|
||||
For index = 1 To oRegionCount
|
||||
Dim oId = _Viewer.GetRegionID(index)
|
||||
_Viewer.SetRegionEditable(oId, False)
|
||||
Next
|
||||
|
||||
|
||||
_CurrentOccurrenceCount = _Viewer.GetTextOccurrenceCount(_CurrentPage, _CurrentQuery, CaseSensitive, WholeWords)
|
||||
_CurrentSelectedOccurrence = 0
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user