TestGUI: Work on Annotations
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 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,201 +160,6 @@ Public Class DocumentViewer
|
||||
End Try
|
||||
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>
|
||||
''' Configures the viewer to hide the file path to the end-user.
|
||||
''' </summary>
|
||||
@@ -377,74 +195,41 @@ Public Class DocumentViewer
|
||||
SetViewOnly(ViewOnly)
|
||||
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
|
||||
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
|
||||
#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
|
||||
@@ -553,6 +338,12 @@ Public Class DocumentViewer
|
||||
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
|
||||
@@ -583,17 +374,103 @@ Public Class DocumentViewer
|
||||
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()
|
||||
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 btnFitPage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitPage.ItemClick
|
||||
FitToPage()
|
||||
_Config.Config.PageFit = Config.PageFitSetting.FitPage
|
||||
_Config.Save()
|
||||
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 Sub FitToPage()
|
||||
If _ViewerMode = ViewerMode.GDPicture Then
|
||||
@@ -613,9 +490,159 @@ Public Class DocumentViewer
|
||||
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
|
||||
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.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 Region
|
||||
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user