TestGUI: Work on Annotations

This commit is contained in:
Jonathan Jenne 2022-05-31 16:26:53 +02:00
parent 8b3c425d6b
commit aeb1b5fce5
5 changed files with 409 additions and 276 deletions

View File

@ -0,0 +1,68 @@
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

View File

@ -39,6 +39,7 @@ Public Class DocumentViewer
Private _logger As Logger Private _logger As Logger
Private _email As Email2 Private _email As Email2
Private _Config As ConfigManager(Of Config) Private _Config As ConfigManager(Of Config)
Private _Annotations As Annotations
Private _hide_file_info_from_user As Boolean = False Private _hide_file_info_from_user As Boolean = False
Private _FilePath As String Private _FilePath As String
@ -65,14 +66,13 @@ Public Class DocumentViewer
_email = New Email2(pLogConfig) _email = New Email2(pLogConfig)
_licenseKey = pLicenseKey _licenseKey = pLicenseKey
_licenseManager.RegisterKEY(_licenseKey) _licenseManager.RegisterKEY(_licenseKey)
_Annotations = New Annotations(pLogConfig)
Dim oConfigPath = ConfigPath() Dim oConfigPath = ConfigPath()
_Config = New ConfigManager(Of Config)(pLogConfig, oConfigPath) _Config = New ConfigManager(Of Config)(pLogConfig, oConfigPath)
End Sub End Sub
Private Function ConfigPath() As String
Return Path.Combine(Application.UserAppDataPath, "DocumentViewer")
End Function
''' <summary> ''' <summary>
''' Terminate Viewer, freeing up resources and deleting temp files ''' Terminate Viewer, freeing up resources and deleting temp files
@ -138,6 +138,19 @@ Public Class DocumentViewer
UpdateMainUi() UpdateMainUi()
End Sub End Sub
Public Function AddAnnotation(pText As String) As Boolean
Dim oFontStyle = System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline
GdViewer.AddTextAnnotationInteractive(pText, Color.Black, "Arial", oFontStyle, 12, True, Color.Red, Color.White, 1, 0)
Return True
End Function
Public Sub Save()
If GdViewer.SaveDocumentToPDF(_FilePath) = GdPictureStatus.OK Then
_logger.Debug("PDF Successfully saved")
End If
End Sub
Public Sub CloseDocument() Public Sub CloseDocument()
Try Try
GdViewer.CloseDocument() GdViewer.CloseDocument()
@ -147,201 +160,6 @@ Public Class DocumentViewer
End Try End Try
End Sub End Sub
Public Sub DeleteTempFiles()
For Each oFile In _TempFiles
Try
_logger.Debug("Deleting temp file [{0}]", oFile)
File.Delete(oFile)
Catch ex As Exception
_logger.Warn("Could not delete temp file [{0}]", oFile)
End Try
Next
End Sub
Private Sub SetViewerMode(Extension As String)
Select Case Extension.ToUpper
Case ".MSG"
_ViewerMode = ViewerMode.RichText
Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
_ViewerMode = ViewerMode.RichText
Case ".XLSX", ".XLS", "CSV"
_ViewerMode = ViewerMode.Excel
Case Else
_ViewerMode = ViewerMode.GDPicture
End Select
End Sub
Private Sub FreeFile()
Try
If Len(_FilePath) = 0 OrElse _Fileinfo Is Nothing Then
Exit Sub
End If
Dim oExtension As String = _Fileinfo.Extension.ToUpper
Select Case _ViewerMode
Case ViewerMode.RichText
_logger.Debug("Closing RichText Editor")
RichEditControl1.CreateNewDocument()
Case ViewerMode.Excel
_logger.Debug("Closing Excel Editor")
SpreadsheetControl1.CreateNewDocument()
Case Else
_logger.Debug("Closing GDPicture Viewer")
GdViewer.CloseDocument()
End Select
Catch ex As Exception
_logger.Warn($"Unexpected error in FreeFile: {ex.Message}")
End Try
End Sub
Private Function DoLoadFile(FilePath As String) As Boolean
Try
Dim oFileInfo = New FileInfo(FilePath)
Dim oExtension As String = oFileInfo.Extension.ToUpper
RichEditControl1.Visible = False
RichEditControl1.Dock = DockStyle.None
SpreadsheetControl1.Visible = False
SpreadsheetControl1.Dock = DockStyle.None
Select Case oExtension.ToUpper
Case ".MSG"
Dim oEmlPath As String = _email.Convert_ToEml(FilePath)
_TempFiles.Add(oEmlPath)
DoLoadFile(oEmlPath)
Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(oExtension))
RichEditControl1.Visible = True
RichEditControl1.Dock = DockStyle.Fill
Case ".XLSX", ".XLS", ".CSV"
Dim oFormat = GetSpreadsheetFormat(oExtension)
SpreadsheetControl1.LoadDocument(FilePath, oFormat)
Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
oRange.AutoFitColumns()
SpreadsheetControl1.Visible = True
SpreadsheetControl1.Dock = DockStyle.Fill
Case Else
'ToolbarDocumentViewer.Visible = True
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
GdViewer.DisplayFromFile(FilePath)
End Select
UpdateMainUi()
Return True
Catch ex As Exception
_logger.Error(ex)
Return False
End Try
End Function
Private Function DoLoadFile(Stream As Stream, Extension As String) As Boolean
Try
RichEditControl1.Visible = False
RichEditControl1.Dock = DockStyle.None
SpreadsheetControl1.Visible = False
SpreadsheetControl1.Dock = DockStyle.None
Select Case Extension.ToUpper
Case ".MSG"
Dim oTempFileName = Path.Combine(IO.Path.GetTempPath(), Guid.NewGuid.ToString & ".msg")
Using oFileStream As New FileStream(oTempFileName, FileMode.Create)
Stream.Seek(0, SeekOrigin.Begin)
Stream.CopyTo(oFileStream)
Stream.Flush()
End Using
Dim oEmlPath As String = _email.Convert_ToEml(oTempFileName)
DoLoadFile(oEmlPath)
Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
RichEditControl1.LoadDocument(Stream, GetDocumentFormat(Extension))
RichEditControl1.ActiveViewType = XtraRichEdit.RichEditViewType.PrintLayout
RichEditControl1.Visible = True
RichEditControl1.Dock = DockStyle.Fill
Case ".XLSX", ".XLS", ".CSV"
SpreadsheetControl1.LoadDocument(Stream, GetSpreadsheetFormat(Extension))
Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
oRange.AutoFitColumns()
SpreadsheetControl1.Visible = True
SpreadsheetControl1.Dock = DockStyle.Fill
Case Else
'ToolbarDocumentViewer.Visible = True
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
GdViewer.DisplayFromStream(Stream)
End Select
UpdateMainUi()
Return True
Catch ex As Exception
_logger.Error(ex)
Return False
End Try
End Function
Private Function GetSpreadsheetFormat(Extension) As Spreadsheet.DocumentFormat
Dim oFormat As Spreadsheet.DocumentFormat = Spreadsheet.DocumentFormat.Undefined
Select Case Extension.ToUpper
Case ".XLSX" : oFormat = Spreadsheet.DocumentFormat.Xlsx
Case ".XLS" : oFormat = Spreadsheet.DocumentFormat.Xls
Case ".CSV" : oFormat = Spreadsheet.DocumentFormat.Csv
End Select
Return oFormat
End Function
Private Function GetDocumentFormat(Extension) As XtraRichEdit.DocumentFormat
Dim oFormat As XtraRichEdit.DocumentFormat = XtraRichEdit.DocumentFormat.Undefined
Select Case Extension.ToUpper
Case ".EML" : oFormat = XtraRichEdit.DocumentFormat.Mht
Case ".DOC" : oFormat = XtraRichEdit.DocumentFormat.Doc
Case ".DOCX" : oFormat = XtraRichEdit.DocumentFormat.OpenXml
Case ".ODT" : oFormat = XtraRichEdit.DocumentFormat.OpenDocument
Case ".RTF" : oFormat = XtraRichEdit.DocumentFormat.Rtf
Case ".TXT" : oFormat = XtraRichEdit.DocumentFormat.PlainText
End Select
Return oFormat
End Function
Private Sub btnOpen_Click(sender As Object, e As EventArgs)
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
If OpenFileDialog.ShowDialog() = DialogResult.OK Then
GdViewer.DisplayFromFile(OpenFileDialog.FileName)
End If
GdViewer.Focus()
UpdateMainUi()
End Sub
''' <summary> ''' <summary>
''' Configures the viewer to hide the file path to the end-user. ''' Configures the viewer to hide the file path to the end-user.
''' </summary> ''' </summary>
@ -377,74 +195,41 @@ Public Class DocumentViewer
SetViewOnly(ViewOnly) SetViewOnly(ViewOnly)
End Sub End Sub
Private Sub UpdateMainUi()
Select Case _Config?.Config?.PageFit
Case Config.PageFitSetting.FitPage
FitToPage()
Case Config.PageFitSetting.FitWidth
FitToWidth()
End Select
Select Case _ViewerMode #Region "Form Events"
Case ViewerMode.GDPicture
buttonPrint.Enabled = True
buttonFitWidth.Enabled = True
buttonFitPage.Enabled = True
buttonZoomIn.Enabled = True
buttonZoomOut.Enabled = True
buttonRotateLeft.Enabled = True
buttonRotateRight.Enabled = True
buttonFlipX.Enabled = True
buttonFlipY.Enabled = True
buttonFirstPage.Enabled = True
buttonPrevPage.Enabled = True
buttonNextPage.Enabled = True
buttonLastPage.Enabled = True
buttonSettings.Enabled = True
txtCurrentPage.Enabled = True
Case ViewerMode.RichText
buttonFitPage.Enabled = True
buttonZoomIn.Enabled = True
buttonZoomOut.Enabled = True
buttonFitWidth.Enabled = True
buttonNextPage.Enabled = True
buttonPrevPage.Enabled = True
buttonPrint.Enabled = False
buttonRotateLeft.Enabled = False
buttonRotateRight.Enabled = False
buttonFlipX.Enabled = False
buttonFlipY.Enabled = False
buttonFirstPage.Enabled = False
buttonLastPage.Enabled = False
buttonSettings.Enabled = False
txtCurrentPage.Enabled = False
Case ViewerMode.Excel
buttonPrint.Enabled = False
buttonFitWidth.Enabled = False
buttonFitPage.Enabled = False
buttonZoomIn.Enabled = False
buttonZoomOut.Enabled = False
buttonRotateLeft.Enabled = False
buttonRotateRight.Enabled = False
buttonFlipX.Enabled = False
buttonFlipY.Enabled = False
buttonFirstPage.Enabled = False
buttonPrevPage.Enabled = False
buttonNextPage.Enabled = False
buttonLastPage.Enabled = False
buttonSettings.Enabled = False
txtCurrentPage.Enabled = False
End Select
Private Sub btnFitWidth_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitWidth.ItemClick
FitToWidth()
_Config.Config.PageFit = Config.PageFitSetting.FitWidth
_Config.Save()
End Sub End Sub
Private Sub btnFitPage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitPage.ItemClick
FitToPage()
_Config.Config.PageFit = Config.PageFitSetting.FitPage
_Config.Save()
End Sub
Private Sub RichEditControl1_SizeChanged(sender As Object, e As EventArgs) Handles RichEditControl1.SizeChanged
Dim oControlWidth = RichEditControl1.Width - 100
Dim oPageWidth = Units.DocumentsToPixelsF(RichEditControl1.Document.Sections(0).Page.Width, RichEditControl1.DpiX)
RichEditControl1.Views.PrintLayoutView.ZoomFactor = oControlWidth / oPageWidth
End Sub
Private Sub btnOpen_Click(sender As Object, e As EventArgs)
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
If OpenFileDialog.ShowDialog() = DialogResult.OK Then
GdViewer.DisplayFromFile(OpenFileDialog.FileName)
End If
GdViewer.Focus()
UpdateMainUi()
End Sub
Private Sub btnFirstPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonFirstPage.ItemClick Private Sub btnFirstPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonFirstPage.ItemClick
GdViewer.DisplayFirstPage() GdViewer.DisplayFirstPage()
End Sub End Sub
@ -553,6 +338,12 @@ Public Class DocumentViewer
End Using End Using
UpdateaNavigationToolbar() UpdateaNavigationToolbar()
End Sub End Sub
#End Region
#Region "Private Functions"
Private Function ConfigPath() As String
Return Path.Combine(Application.UserAppDataPath, "DocumentViewer")
End Function
Private Sub UpdateaNavigationToolbar() Private Sub UpdateaNavigationToolbar()
Try Try
@ -583,17 +374,103 @@ Public Class DocumentViewer
End Try End Try
End Sub End Sub
Private Sub btnFitWidth_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitWidth.ItemClick Public Sub DeleteTempFiles()
FitToWidth() For Each oFile In _TempFiles
_Config.Config.PageFit = Config.PageFitSetting.FitWidth Try
_Config.Save() _logger.Debug("Deleting temp file [{0}]", oFile)
File.Delete(oFile)
Catch ex As Exception
_logger.Warn("Could not delete temp file [{0}]", oFile)
End Try
Next
End Sub End Sub
Private Sub btnFitPage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitPage.ItemClick Private Sub SetViewerMode(Extension As String)
FitToPage() Select Case Extension.ToUpper
_Config.Config.PageFit = Config.PageFitSetting.FitPage Case ".MSG"
_Config.Save() _ViewerMode = ViewerMode.RichText
Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
_ViewerMode = ViewerMode.RichText
Case ".XLSX", ".XLS", "CSV"
_ViewerMode = ViewerMode.Excel
Case Else
_ViewerMode = ViewerMode.GDPicture
End Select
End Sub End Sub
Private Sub FreeFile()
Try
If Len(_FilePath) = 0 OrElse _Fileinfo Is Nothing Then
Exit Sub
End If
Dim oExtension As String = _Fileinfo.Extension.ToUpper
Select Case _ViewerMode
Case ViewerMode.RichText
_logger.Debug("Closing RichText Editor")
RichEditControl1.CreateNewDocument()
Case ViewerMode.Excel
_logger.Debug("Closing Excel Editor")
SpreadsheetControl1.CreateNewDocument()
Case Else
_logger.Debug("Closing GDPicture Viewer")
GdViewer.CloseDocument()
End Select
Catch ex As Exception
_logger.Warn($"Unexpected error in FreeFile: {ex.Message}")
End Try
End Sub
Private Function DoLoadFile(FilePath As String) As Boolean
Try
Dim oFileInfo = New FileInfo(FilePath)
Dim oExtension As String = oFileInfo.Extension.ToUpper
RichEditControl1.Visible = False
RichEditControl1.Dock = DockStyle.None
SpreadsheetControl1.Visible = False
SpreadsheetControl1.Dock = DockStyle.None
Select Case oExtension.ToUpper
Case ".MSG"
Dim oEmlPath As String = _email.Convert_ToEml(FilePath)
_TempFiles.Add(oEmlPath)
DoLoadFile(oEmlPath)
Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(oExtension))
RichEditControl1.Visible = True
RichEditControl1.Dock = DockStyle.Fill
Case ".XLSX", ".XLS", ".CSV"
Dim oFormat = GetSpreadsheetFormat(oExtension)
SpreadsheetControl1.LoadDocument(FilePath, oFormat)
Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
oRange.AutoFitColumns()
SpreadsheetControl1.Visible = True
SpreadsheetControl1.Dock = DockStyle.Fill
Case Else
'ToolbarDocumentViewer.Visible = True
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
GdViewer.DisplayFromFile(FilePath)
End Select
UpdateMainUi()
Return True
Catch ex As Exception
_logger.Error(ex)
Return False
End Try
End Function
Private Sub FitToPage() Private Sub FitToPage()
If _ViewerMode = ViewerMode.GDPicture Then If _ViewerMode = ViewerMode.GDPicture Then
@ -613,9 +490,159 @@ Public Class DocumentViewer
End If End If
End Sub End Sub
Private Sub RichEditControl1_SizeChanged(sender As Object, e As EventArgs) Handles RichEditControl1.SizeChanged Private Function DoLoadFile(Stream As Stream, Extension As String) As Boolean
Dim oControlWidth = RichEditControl1.Width - 100 Try
Dim oPageWidth = Units.DocumentsToPixelsF(RichEditControl1.Document.Sections(0).Page.Width, RichEditControl1.DpiX) RichEditControl1.Visible = False
RichEditControl1.Views.PrintLayoutView.ZoomFactor = oControlWidth / oPageWidth RichEditControl1.Dock = DockStyle.None
SpreadsheetControl1.Visible = False
SpreadsheetControl1.Dock = DockStyle.None
Select Case Extension.ToUpper
Case ".MSG"
Dim oTempFileName = Path.Combine(IO.Path.GetTempPath(), Guid.NewGuid.ToString & ".msg")
Using oFileStream As New FileStream(oTempFileName, FileMode.Create)
Stream.Seek(0, SeekOrigin.Begin)
Stream.CopyTo(oFileStream)
Stream.Flush()
End Using
Dim oEmlPath As String = _email.Convert_ToEml(oTempFileName)
DoLoadFile(oEmlPath)
Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
RichEditControl1.LoadDocument(Stream, GetDocumentFormat(Extension))
RichEditControl1.ActiveViewType = XtraRichEdit.RichEditViewType.PrintLayout
RichEditControl1.Visible = True
RichEditControl1.Dock = DockStyle.Fill
Case ".XLSX", ".XLS", ".CSV"
SpreadsheetControl1.LoadDocument(Stream, GetSpreadsheetFormat(Extension))
Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
oRange.AutoFitColumns()
SpreadsheetControl1.Visible = True
SpreadsheetControl1.Dock = DockStyle.Fill
Case Else
'ToolbarDocumentViewer.Visible = True
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
GdViewer.ForceTemporaryMode = True
GdViewer.DisplayFromStream(Stream)
End Select
UpdateMainUi()
Return True
Catch ex As Exception
_logger.Error(ex)
Return False
End Try
End Function
Private Function GetSpreadsheetFormat(Extension) As Spreadsheet.DocumentFormat
Dim oFormat As Spreadsheet.DocumentFormat = Spreadsheet.DocumentFormat.Undefined
Select Case Extension.ToUpper
Case ".XLSX" : oFormat = Spreadsheet.DocumentFormat.Xlsx
Case ".XLS" : oFormat = Spreadsheet.DocumentFormat.Xls
Case ".CSV" : oFormat = Spreadsheet.DocumentFormat.Csv
End Select
Return oFormat
End Function
Private Function GetDocumentFormat(Extension) As XtraRichEdit.DocumentFormat
Dim oFormat As XtraRichEdit.DocumentFormat = XtraRichEdit.DocumentFormat.Undefined
Select Case Extension.ToUpper
Case ".EML" : oFormat = XtraRichEdit.DocumentFormat.Mht
Case ".DOC" : oFormat = XtraRichEdit.DocumentFormat.Doc
Case ".DOCX" : oFormat = XtraRichEdit.DocumentFormat.OpenXml
Case ".ODT" : oFormat = XtraRichEdit.DocumentFormat.OpenDocument
Case ".RTF" : oFormat = XtraRichEdit.DocumentFormat.Rtf
Case ".TXT" : oFormat = XtraRichEdit.DocumentFormat.PlainText
End Select
Return oFormat
End Function
Private Sub UpdateMainUi()
Select Case _Config?.Config?.PageFit
Case Config.PageFitSetting.FitPage
FitToPage()
Case Config.PageFitSetting.FitWidth
FitToWidth()
End Select
Select Case _ViewerMode
Case ViewerMode.GDPicture
buttonPrint.Enabled = True
buttonFitWidth.Enabled = True
buttonFitPage.Enabled = True
buttonZoomIn.Enabled = True
buttonZoomOut.Enabled = True
buttonRotateLeft.Enabled = True
buttonRotateRight.Enabled = True
buttonFlipX.Enabled = True
buttonFlipY.Enabled = True
buttonFirstPage.Enabled = True
buttonPrevPage.Enabled = True
buttonNextPage.Enabled = True
buttonLastPage.Enabled = True
buttonSettings.Enabled = True
txtCurrentPage.Enabled = True
Case ViewerMode.RichText
buttonFitPage.Enabled = True
buttonZoomIn.Enabled = True
buttonZoomOut.Enabled = True
buttonFitWidth.Enabled = True
buttonNextPage.Enabled = True
buttonPrevPage.Enabled = True
buttonPrint.Enabled = False
buttonRotateLeft.Enabled = False
buttonRotateRight.Enabled = False
buttonFlipX.Enabled = False
buttonFlipY.Enabled = False
buttonFirstPage.Enabled = False
buttonLastPage.Enabled = False
buttonSettings.Enabled = False
txtCurrentPage.Enabled = False
Case ViewerMode.Excel
buttonPrint.Enabled = False
buttonFitWidth.Enabled = False
buttonFitPage.Enabled = False
buttonZoomIn.Enabled = False
buttonZoomOut.Enabled = False
buttonRotateLeft.Enabled = False
buttonRotateRight.Enabled = False
buttonFlipX.Enabled = False
buttonFlipY.Enabled = False
buttonFirstPage.Enabled = False
buttonPrevPage.Enabled = False
buttonNextPage.Enabled = False
buttonLastPage.Enabled = False
buttonSettings.Enabled = False
txtCurrentPage.Enabled = False
End Select
End Sub End Sub
#End Region
End Class End Class

View File

@ -114,6 +114,7 @@
<Import Include="System.Threading.Tasks" /> <Import Include="System.Threading.Tasks" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Annotations.vb" />
<Compile Include="Config.vb" /> <Compile Include="Config.vb" />
<Compile Include="DocumentViewer.Designer.vb"> <Compile Include="DocumentViewer.Designer.vb">
<DependentUpon>DocumentViewer.vb</DependentUpon> <DependentUpon>DocumentViewer.vb</DependentUpon>
@ -172,6 +173,10 @@
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Modules.Base\Base\Base.vbproj">
<Project>{6ea0c51f-c2b1-4462-8198-3de0b32b74f8}</Project>
<Name>Base</Name>
</ProjectReference>
<ProjectReference Include="..\Modules.Config\Config.vbproj"> <ProjectReference Include="..\Modules.Config\Config.vbproj">
<Project>{44982f9b-6116-44e2-85d0-f39650b1ef99}</Project> <Project>{44982f9b-6116-44e2-85d0-f39650b1ef99}</Project>
<Name>Config</Name> <Name>Config</Name>

View File

@ -24,19 +24,23 @@ Partial Class frmDocView
Private Sub InitializeComponent() Private Sub InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel() Me.Panel1 = New System.Windows.Forms.Panel()
Me.Button2 = New System.Windows.Forms.Button() Me.Button2 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
Me.Button1 = New System.Windows.Forms.Button() Me.Button1 = New System.Windows.Forms.Button()
Me.TextBox1 = New System.Windows.Forms.TextBox() Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog() Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog()
Me.DocumentViewer1 = New DigitalData.Controls.DocumentViewer.DocumentViewer() Me.DocumentViewer1 = New DigitalData.Controls.DocumentViewer.DocumentViewer()
Me.Button4 = New System.Windows.Forms.Button()
Me.Panel1.SuspendLayout() Me.Panel1.SuspendLayout()
Me.SuspendLayout() Me.SuspendLayout()
' '
'Panel1 'Panel1
' '
Me.Panel1.Controls.Add(Me.Button2) Me.Panel1.Controls.Add(Me.Button2)
Me.Panel1.Controls.Add(Me.Button4)
Me.Panel1.Controls.Add(Me.Button3)
Me.Panel1.Controls.Add(Me.Button1) Me.Panel1.Controls.Add(Me.Button1)
Me.Panel1.Controls.Add(Me.TextBox1) Me.Panel1.Controls.Add(Me.TextBox1)
Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill Me.Panel1.Dock = System.Windows.Forms.DockStyle.Top
Me.Panel1.Location = New System.Drawing.Point(0, 0) Me.Panel1.Location = New System.Drawing.Point(0, 0)
Me.Panel1.Name = "Panel1" Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(1079, 43) Me.Panel1.Size = New System.Drawing.Size(1079, 43)
@ -51,9 +55,18 @@ Partial Class frmDocView
Me.Button2.Text = "Unload File" Me.Button2.Text = "Unload File"
Me.Button2.UseVisualStyleBackColor = True Me.Button2.UseVisualStyleBackColor = True
' '
'Button3
'
Me.Button3.Location = New System.Drawing.Point(911, 10)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(75, 23)
Me.Button3.TabIndex = 1
Me.Button3.Text = "Annotate"
Me.Button3.UseVisualStyleBackColor = True
'
'Button1 'Button1
' '
Me.Button1.Location = New System.Drawing.Point(864, 10) Me.Button1.Location = New System.Drawing.Point(542, 10)
Me.Button1.Name = "Button1" Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23) Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 1 Me.Button1.TabIndex = 1
@ -64,7 +77,7 @@ Partial Class frmDocView
' '
Me.TextBox1.Location = New System.Drawing.Point(12, 12) Me.TextBox1.Location = New System.Drawing.Point(12, 12)
Me.TextBox1.Name = "TextBox1" Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(846, 20) Me.TextBox1.Size = New System.Drawing.Size(524, 20)
Me.TextBox1.TabIndex = 0 Me.TextBox1.TabIndex = 0
' '
'OpenFileDialog1 'OpenFileDialog1
@ -73,20 +86,29 @@ Partial Class frmDocView
' '
'DocumentViewer1 'DocumentViewer1
' '
Me.DocumentViewer1.Dock = System.Windows.Forms.DockStyle.Bottom Me.DocumentViewer1.Dock = System.Windows.Forms.DockStyle.Fill
Me.DocumentViewer1.FileLoaded = False Me.DocumentViewer1.FileLoaded = False
Me.DocumentViewer1.Location = New System.Drawing.Point(0, 43) Me.DocumentViewer1.Location = New System.Drawing.Point(0, 43)
Me.DocumentViewer1.Name = "DocumentViewer1" Me.DocumentViewer1.Name = "DocumentViewer1"
Me.DocumentViewer1.Size = New System.Drawing.Size(1079, 463) Me.DocumentViewer1.Size = New System.Drawing.Size(1079, 463)
Me.DocumentViewer1.TabIndex = 0 Me.DocumentViewer1.TabIndex = 0
' '
'Button4
'
Me.Button4.Location = New System.Drawing.Point(830, 10)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(75, 23)
Me.Button4.TabIndex = 1
Me.Button4.Text = "Save"
Me.Button4.UseVisualStyleBackColor = True
'
'frmDocView 'frmDocView
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1079, 506) Me.ClientSize = New System.Drawing.Size(1079, 506)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.DocumentViewer1) Me.Controls.Add(Me.DocumentViewer1)
Me.Controls.Add(Me.Panel1)
Me.Name = "frmDocView" Me.Name = "frmDocView"
Me.Text = "frmDocView" Me.Text = "frmDocView"
Me.Panel1.ResumeLayout(False) Me.Panel1.ResumeLayout(False)
@ -101,4 +123,6 @@ Partial Class frmDocView
Friend WithEvents TextBox1 As TextBox Friend WithEvents TextBox1 As TextBox
Friend WithEvents OpenFileDialog1 As OpenFileDialog Friend WithEvents OpenFileDialog1 As OpenFileDialog
Friend WithEvents Button2 As Button Friend WithEvents Button2 As Button
Friend WithEvents Button3 As Button
Friend WithEvents Button4 As Button
End Class End Class

View File

@ -17,4 +17,13 @@ Public Class frmDocView
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
DocumentViewer1.Done() DocumentViewer1.Done()
End Sub End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If DocumentViewer1.AddAnnotation("Some Text") Then
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
DocumentViewer1.Save()
End Sub
End Class End Class