From aeb1b5fce5e760b61b8f3c4c3f4ae1b73766888d Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 31 May 2022 16:26:53 +0200 Subject: [PATCH] TestGUI: Work on Annotations --- Controls.DocumentViewer/Annotations.vb | 68 +++ Controls.DocumentViewer/DocumentViewer.vb | 473 +++++++++--------- Controls.DocumentViewer/DocumentViewer.vbproj | 5 + GUIs.Test.TestGUI/frmDocView.Designer.vb | 34 +- GUIs.Test.TestGUI/frmDocView.vb | 9 + 5 files changed, 361 insertions(+), 228 deletions(-) create mode 100644 Controls.DocumentViewer/Annotations.vb diff --git a/Controls.DocumentViewer/Annotations.vb b/Controls.DocumentViewer/Annotations.vb new file mode 100644 index 00000000..9bdc1aab --- /dev/null +++ b/Controls.DocumentViewer/Annotations.vb @@ -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 diff --git a/Controls.DocumentViewer/DocumentViewer.vb b/Controls.DocumentViewer/DocumentViewer.vb index 1935397d..9a9350ff 100644 --- a/Controls.DocumentViewer/DocumentViewer.vb +++ b/Controls.DocumentViewer/DocumentViewer.vb @@ -39,6 +39,7 @@ Public Class DocumentViewer Private _logger As Logger Private _email As Email2 Private _Config As ConfigManager(Of Config) + Private _Annotations As Annotations Private _hide_file_info_from_user As Boolean = False Private _FilePath As String @@ -65,14 +66,13 @@ Public Class DocumentViewer _email = New Email2(pLogConfig) _licenseKey = pLicenseKey _licenseManager.RegisterKEY(_licenseKey) + _Annotations = New Annotations(pLogConfig) Dim oConfigPath = ConfigPath() _Config = New ConfigManager(Of Config)(pLogConfig, oConfigPath) End Sub - Private Function ConfigPath() As String - Return Path.Combine(Application.UserAppDataPath, "DocumentViewer") - End Function + ''' ''' Terminate Viewer, freeing up resources and deleting temp files @@ -138,6 +138,19 @@ Public Class DocumentViewer UpdateMainUi() 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() Try GdViewer.CloseDocument() @@ -147,6 +160,220 @@ Public Class DocumentViewer End Try End Sub + ''' + ''' Configures the viewer to hide the file path to the end-user. + ''' + ''' + ''' True means that all file info should be hidden from the end-user + ''' False means the end user may see the filepath or other info about the file + ''' + Public Sub SetViewOnly(ViewOnly As Boolean) + If ViewOnly Then + buttonPrint.Visibility = XtraBars.BarItemVisibility.Never + Else + buttonPrint.Visibility = XtraBars.BarItemVisibility.Always + End If + + _hide_file_info_from_user = ViewOnly + End Sub + + Public Sub SetAllowAnnotations(AllowAnnotations As Boolean) + + End Sub + + ''' + ''' DEPRECATED: Use SetViewOnly + ''' + Public Sub RightViewOnly(ViewOnly As Boolean) + SetViewOnly(ViewOnly) + End Sub + + ''' + ''' DEPRECATED: Use SetViewOnly + ''' + Public Sub RightOnlyView(ViewOnly As Boolean) + SetViewOnly(ViewOnly) + End Sub + + + + + +#Region "Form Events" + + 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 + + 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 + GdViewer.DisplayFirstPage() + End Sub + + Private Sub btnPreviousPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonPrevPage.ItemClick + If _ViewerMode = ViewerMode.GDPicture Then + GdViewer.DisplayPreviousPage() + ElseIf _ViewerMode = ViewerMode.RichText Then + Dim oCmd As New PreviousPageCommand(RichEditControl1) + oCmd.Execute() + End If + End Sub + + Private Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonNextPage.ItemClick + If _ViewerMode = ViewerMode.GDPicture Then + GdViewer.DisplayNextPage() + ElseIf _ViewerMode = ViewerMode.RichText Then + Dim oCmd As New NextPageCommand(RichEditControl1) + oCmd.Execute() + End If + End Sub + + Private Sub btnLastPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonLastPage.ItemClick + GdViewer.DisplayLastPage() + End Sub + + Private Sub tbCurrentPage_Leave(ByVal sender As System.Object, ByVal e As EventArgs) Handles txtCurrentPage.EditValueChanged + Dim page As Integer = 0 + If Integer.TryParse(txtCurrentPage.EditValue, page) Then + If page > 0 And page <= GdViewer.PageCount Then + GdViewer.DisplayPage(page) + UpdateaNavigationToolbar() + End If + End If + End Sub + + Private Sub GdViewer1_PageChanged() Handles GdViewer.PageChanged + UpdateaNavigationToolbar() + End Sub + + Private Sub GdViewer1_AfterZoomChange() Handles GdViewer.AfterZoomChange + UpdateaNavigationToolbar() + If GdViewer.MouseMode = ViewerMouseMode.MouseModeAreaZooming Then + GdViewer.MouseMode = ViewerMouseMode.MouseModePan + End If + End Sub + + Private Sub btnZoomOut_Click(sender As Object, e As EventArgs) Handles buttonZoomOut.ItemClick + If _ViewerMode = ViewerMode.GDPicture Then + GdViewer.ZoomOUT() + ElseIf _ViewerMode = ViewerMode.RichText Then + Dim oCmd As New ZoomOutCommand(RichEditControl1) + oCmd.Execute() + End If + End Sub + + Private Sub btnZoomIn_Click(sender As Object, e As EventArgs) Handles buttonZoomIn.ItemClick + If _ViewerMode = ViewerMode.GDPicture Then + GdViewer.ZoomIN() + ElseIf _ViewerMode = ViewerMode.RichText Then + Dim oCmd As New ZoomInCommand(RichEditControl1) + oCmd.Execute() + End If + End Sub + + Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles buttonPrint.ItemClick + If GdViewer.PageCount = 0 Then + Return + End If + + GdViewer.PrintDialog() + End Sub + + Private Sub btnRotateLeft_Click(sender As Object, e As EventArgs) Handles buttonRotateLeft.ItemClick + GdViewer.Rotate(RotateFlipType.Rotate270FlipNone) + End Sub + + Private Sub btnRotateRight_Click(sender As Object, e As EventArgs) Handles buttonRotateRight.ItemClick + GdViewer.Rotate(RotateFlipType.Rotate90FlipNone) + End Sub + + Private Sub btnFlipX_Click(sender As Object, e As EventArgs) Handles buttonFlipX.ItemClick + GdViewer.Rotate(RotateFlipType.RotateNoneFlipX) + End Sub + + Private Sub btnFlipY_Click(sender As Object, e As EventArgs) Handles buttonFlipY.ItemClick + GdViewer.Rotate(RotateFlipType.RotateNoneFlipY) + End Sub + + Private Sub GdViewer1_TransferEnded(ByVal status As GdPictureStatus, ByVal download As System.Boolean) Handles GdViewer.TransferEnded + GdViewer.Focus() + UpdateMainUi() + End Sub + + Private Sub AddSearchRegion(ByVal occurence As Integer, ByVal leftCoordinate As Single, ByVal topCoordinate As Single, ByVal regionWidth As Single, ByVal regionheight As Single, ByVal ensureVisibility As Boolean) + Dim searchRegion As Integer = GdViewer.AddRegionInches("SearchResult" & occurence, leftCoordinate, topCoordinate, regionWidth, regionheight, ForegroundMixMode.ForegroundMixModeMASKPEN, Color.Yellow) + GdViewer.SetRegionEditable(searchRegion, False) + If ensureVisibility Then + GdViewer.EnsureRegionVisibility(searchRegion) + End If + End Sub + + Private Sub btnSettings_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonSettings.ItemClick + Using frmSettings As New frmViewerSettings(GdViewer) + frmSettings.ShowDialog(Me) + End Using + UpdateaNavigationToolbar() + End Sub +#End Region + +#Region "Private Functions" + Private Function ConfigPath() As String + Return Path.Combine(Application.UserAppDataPath, "DocumentViewer") + End Function + + Private Sub UpdateaNavigationToolbar() + Try + Dim oCurrentZoom As Double = GdViewer.Zoom + Dim oCurrentPage As Integer = GdViewer.CurrentPage + Dim oPageCount As Integer = GdViewer.PageCount + txtCurrentPage.EditValue = oCurrentPage + labelPageCount.Caption = $"/ {oPageCount}" + + If oCurrentPage = oPageCount Then + buttonLastPage.Enabled = False + buttonNextPage.Enabled = False + buttonPrevPage.Enabled = True + buttonFirstPage.Enabled = True + ElseIf oCurrentPage = 1 Then + buttonPrevPage.Enabled = False + buttonFirstPage.Enabled = False + buttonLastPage.Enabled = True + buttonNextPage.Enabled = True + Else + buttonPrevPage.Enabled = True + buttonFirstPage.Enabled = True + buttonLastPage.Enabled = True + buttonNextPage.Enabled = True + End If + Catch ex As Exception + _logger.Error(ex) + End Try + End Sub + Public Sub DeleteTempFiles() For Each oFile In _TempFiles Try @@ -170,8 +397,6 @@ Public Class DocumentViewer _ViewerMode = ViewerMode.GDPicture End Select End Sub - - Private Sub FreeFile() Try If Len(_FilePath) = 0 OrElse _Fileinfo Is Nothing Then @@ -247,6 +472,24 @@ Public Class DocumentViewer End Try End Function + Private Sub FitToPage() + If _ViewerMode = ViewerMode.GDPicture Then + GdViewer.ZoomMode = ViewerZoomMode.ZoomModeFitToViewer + ElseIf _ViewerMode = ViewerMode.RichText Then + Dim oCmd As New FitToPageCommand(RichEditControl1) + oCmd.Execute() + End If + End Sub + + Private Sub FitToWidth() + If _ViewerMode = ViewerMode.GDPicture Then + GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer + ElseIf _ViewerMode = ViewerMode.RichText Then + Dim oCmd As New FitWidthCommand(RichEditControl1) + oCmd.Execute() + End If + End Sub + Private Function DoLoadFile(Stream As Stream, Extension As String) As Boolean Try RichEditControl1.Visible = False @@ -289,6 +532,7 @@ Public Class DocumentViewer GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter + GdViewer.ForceTemporaryMode = True GdViewer.DisplayFromStream(Stream) End Select @@ -329,54 +573,6 @@ Public Class DocumentViewer 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 - - ''' - ''' Configures the viewer to hide the file path to the end-user. - ''' - ''' - ''' True means that all file info should be hidden from the end-user - ''' False means the end user may see the filepath or other info about the file - ''' - Public Sub SetViewOnly(ViewOnly As Boolean) - If ViewOnly Then - buttonPrint.Visibility = XtraBars.BarItemVisibility.Never - Else - buttonPrint.Visibility = XtraBars.BarItemVisibility.Always - End If - - _hide_file_info_from_user = ViewOnly - End Sub - - Public Sub SetAllowAnnotations(AllowAnnotations As Boolean) - - End Sub - - ''' - ''' DEPRECATED: Use SetViewOnly - ''' - Public Sub RightViewOnly(ViewOnly As Boolean) - SetViewOnly(ViewOnly) - End Sub - - ''' - ''' DEPRECATED: Use SetViewOnly - ''' - Public Sub RightOnlyView(ViewOnly As Boolean) - SetViewOnly(ViewOnly) - End Sub - Private Sub UpdateMainUi() Select Case _Config?.Config?.PageFit @@ -444,178 +640,9 @@ Public Class DocumentViewer End Select End Sub +#End Region - Private Sub btnFirstPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonFirstPage.ItemClick - GdViewer.DisplayFirstPage() - End Sub - Private Sub btnPreviousPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonPrevPage.ItemClick - If _ViewerMode = ViewerMode.GDPicture Then - GdViewer.DisplayPreviousPage() - ElseIf _ViewerMode = ViewerMode.RichText Then - Dim oCmd As New PreviousPageCommand(RichEditControl1) - oCmd.Execute() - End If - End Sub - Private Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonNextPage.ItemClick - If _ViewerMode = ViewerMode.GDPicture Then - GdViewer.DisplayNextPage() - ElseIf _ViewerMode = ViewerMode.RichText Then - Dim oCmd As New NextPageCommand(RichEditControl1) - oCmd.Execute() - End If - End Sub - - Private Sub btnLastPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonLastPage.ItemClick - GdViewer.DisplayLastPage() - End Sub - Private Sub tbCurrentPage_Leave(ByVal sender As System.Object, ByVal e As EventArgs) Handles txtCurrentPage.EditValueChanged - Dim page As Integer = 0 - If Integer.TryParse(txtCurrentPage.EditValue, page) Then - If page > 0 And page <= GdViewer.PageCount Then - GdViewer.DisplayPage(page) - UpdateaNavigationToolbar() - End If - End If - End Sub - - Private Sub GdViewer1_PageChanged() Handles GdViewer.PageChanged - UpdateaNavigationToolbar() - End Sub - - Private Sub GdViewer1_AfterZoomChange() Handles GdViewer.AfterZoomChange - UpdateaNavigationToolbar() - If GdViewer.MouseMode = ViewerMouseMode.MouseModeAreaZooming Then - GdViewer.MouseMode = ViewerMouseMode.MouseModePan - End If - End Sub - - Private Sub btnZoomOut_Click(sender As Object, e As EventArgs) Handles buttonZoomOut.ItemClick - If _ViewerMode = ViewerMode.GDPicture Then - GdViewer.ZoomOUT() - ElseIf _ViewerMode = ViewerMode.RichText Then - Dim oCmd As New ZoomOutCommand(RichEditControl1) - oCmd.Execute() - End If - End Sub - - Private Sub btnZoomIn_Click(sender As Object, e As EventArgs) Handles buttonZoomIn.ItemClick - If _ViewerMode = ViewerMode.GDPicture Then - GdViewer.ZoomIN() - ElseIf _ViewerMode = ViewerMode.RichText Then - Dim oCmd As New ZoomInCommand(RichEditControl1) - oCmd.Execute() - End If - End Sub - - Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles buttonPrint.ItemClick - If GdViewer.PageCount = 0 Then - Return - End If - - GdViewer.PrintDialog() - End Sub - - Private Sub btnRotateLeft_Click(sender As Object, e As EventArgs) Handles buttonRotateLeft.ItemClick - GdViewer.Rotate(RotateFlipType.Rotate270FlipNone) - End Sub - - Private Sub btnRotateRight_Click(sender As Object, e As EventArgs) Handles buttonRotateRight.ItemClick - GdViewer.Rotate(RotateFlipType.Rotate90FlipNone) - End Sub - - Private Sub btnFlipX_Click(sender As Object, e As EventArgs) Handles buttonFlipX.ItemClick - GdViewer.Rotate(RotateFlipType.RotateNoneFlipX) - End Sub - - Private Sub btnFlipY_Click(sender As Object, e As EventArgs) Handles buttonFlipY.ItemClick - GdViewer.Rotate(RotateFlipType.RotateNoneFlipY) - End Sub - - Private Sub GdViewer1_TransferEnded(ByVal status As GdPictureStatus, ByVal download As System.Boolean) Handles GdViewer.TransferEnded - GdViewer.Focus() - UpdateMainUi() - End Sub - - Private Sub AddSearchRegion(ByVal occurence As Integer, ByVal leftCoordinate As Single, ByVal topCoordinate As Single, ByVal regionWidth As Single, ByVal regionheight As Single, ByVal ensureVisibility As Boolean) - Dim searchRegion As Integer = GdViewer.AddRegionInches("SearchResult" & occurence, leftCoordinate, topCoordinate, regionWidth, regionheight, ForegroundMixMode.ForegroundMixModeMASKPEN, Color.Yellow) - GdViewer.SetRegionEditable(searchRegion, False) - If ensureVisibility Then - GdViewer.EnsureRegionVisibility(searchRegion) - End If - End Sub - - Private Sub btnSettings_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonSettings.ItemClick - Using frmSettings As New frmViewerSettings(GdViewer) - frmSettings.ShowDialog(Me) - End Using - UpdateaNavigationToolbar() - End Sub - - Private Sub UpdateaNavigationToolbar() - Try - Dim oCurrentZoom As Double = GdViewer.Zoom - Dim oCurrentPage As Integer = GdViewer.CurrentPage - Dim oPageCount As Integer = GdViewer.PageCount - txtCurrentPage.EditValue = oCurrentPage - labelPageCount.Caption = $"/ {oPageCount}" - - If oCurrentPage = oPageCount Then - buttonLastPage.Enabled = False - buttonNextPage.Enabled = False - buttonPrevPage.Enabled = True - buttonFirstPage.Enabled = True - ElseIf oCurrentPage = 1 Then - buttonPrevPage.Enabled = False - buttonFirstPage.Enabled = False - buttonLastPage.Enabled = True - buttonNextPage.Enabled = True - Else - buttonPrevPage.Enabled = True - buttonFirstPage.Enabled = True - buttonLastPage.Enabled = True - buttonNextPage.Enabled = True - End If - Catch ex As Exception - _logger.Error(ex) - End Try - End Sub - - 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 - - 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 FitToPage() - If _ViewerMode = ViewerMode.GDPicture Then - GdViewer.ZoomMode = ViewerZoomMode.ZoomModeFitToViewer - ElseIf _ViewerMode = ViewerMode.RichText Then - Dim oCmd As New FitToPageCommand(RichEditControl1) - oCmd.Execute() - End If - End Sub - - Private Sub FitToWidth() - If _ViewerMode = ViewerMode.GDPicture Then - GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer - ElseIf _ViewerMode = ViewerMode.RichText Then - Dim oCmd As New FitWidthCommand(RichEditControl1) - oCmd.Execute() - End If - 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 End Class diff --git a/Controls.DocumentViewer/DocumentViewer.vbproj b/Controls.DocumentViewer/DocumentViewer.vbproj index faf4d6b4..58b8de26 100644 --- a/Controls.DocumentViewer/DocumentViewer.vbproj +++ b/Controls.DocumentViewer/DocumentViewer.vbproj @@ -114,6 +114,7 @@ + DocumentViewer.vb @@ -172,6 +173,10 @@ + + {6ea0c51f-c2b1-4462-8198-3de0b32b74f8} + Base + {44982f9b-6116-44e2-85d0-f39650b1ef99} Config diff --git a/GUIs.Test.TestGUI/frmDocView.Designer.vb b/GUIs.Test.TestGUI/frmDocView.Designer.vb index cbb52374..48185186 100644 --- a/GUIs.Test.TestGUI/frmDocView.Designer.vb +++ b/GUIs.Test.TestGUI/frmDocView.Designer.vb @@ -24,19 +24,23 @@ Partial Class frmDocView Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel() Me.Button2 = New System.Windows.Forms.Button() + Me.Button3 = New System.Windows.Forms.Button() Me.Button1 = New System.Windows.Forms.Button() Me.TextBox1 = New System.Windows.Forms.TextBox() Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog() Me.DocumentViewer1 = New DigitalData.Controls.DocumentViewer.DocumentViewer() + Me.Button4 = New System.Windows.Forms.Button() Me.Panel1.SuspendLayout() Me.SuspendLayout() ' 'Panel1 ' 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.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.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(1079, 43) @@ -51,9 +55,18 @@ Partial Class frmDocView Me.Button2.Text = "Unload File" 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 ' - Me.Button1.Location = New System.Drawing.Point(864, 10) + Me.Button1.Location = New System.Drawing.Point(542, 10) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 23) Me.Button1.TabIndex = 1 @@ -64,7 +77,7 @@ Partial Class frmDocView ' Me.TextBox1.Location = New System.Drawing.Point(12, 12) 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 ' 'OpenFileDialog1 @@ -73,20 +86,29 @@ Partial Class frmDocView ' 'DocumentViewer1 ' - Me.DocumentViewer1.Dock = System.Windows.Forms.DockStyle.Bottom + Me.DocumentViewer1.Dock = System.Windows.Forms.DockStyle.Fill Me.DocumentViewer1.FileLoaded = False Me.DocumentViewer1.Location = New System.Drawing.Point(0, 43) Me.DocumentViewer1.Name = "DocumentViewer1" Me.DocumentViewer1.Size = New System.Drawing.Size(1079, 463) 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 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(1079, 506) - Me.Controls.Add(Me.Panel1) Me.Controls.Add(Me.DocumentViewer1) + Me.Controls.Add(Me.Panel1) Me.Name = "frmDocView" Me.Text = "frmDocView" Me.Panel1.ResumeLayout(False) @@ -101,4 +123,6 @@ Partial Class frmDocView Friend WithEvents TextBox1 As TextBox Friend WithEvents OpenFileDialog1 As OpenFileDialog Friend WithEvents Button2 As Button + Friend WithEvents Button3 As Button + Friend WithEvents Button4 As Button End Class diff --git a/GUIs.Test.TestGUI/frmDocView.vb b/GUIs.Test.TestGUI/frmDocView.vb index 0769482b..8c723ff1 100644 --- a/GUIs.Test.TestGUI/frmDocView.vb +++ b/GUIs.Test.TestGUI/frmDocView.vb @@ -17,4 +17,13 @@ Public Class frmDocView Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click DocumentViewer1.Done() 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 \ No newline at end of file