documentviewer: Version 1.0.1.0
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
Imports System.Globalization
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports Independentsoft.Msg
|
||||
Imports DevExpress.Spreadsheet.DocumentFormat
|
||||
Imports DevExpress.Spreadsheet
|
||||
Imports GdPicture14
|
||||
|
||||
Public Class DocumentViewer
|
||||
@@ -16,7 +19,6 @@ Public Class DocumentViewer
|
||||
ZoomFitHeight
|
||||
End Enum
|
||||
|
||||
Private _docPath As String
|
||||
Private _currentSearchOccurence As Integer = 0
|
||||
Private _toggleGamma As Boolean = True
|
||||
Private _licenseKey As String = String.Empty
|
||||
@@ -74,22 +76,22 @@ Public Class DocumentViewer
|
||||
''' <summary>
|
||||
''' Load a file and display it
|
||||
''' </summary>
|
||||
''' <param name="filepath"></param>
|
||||
Public Sub LoadFile(filepath As String)
|
||||
''' <param name="FilePath"></param>
|
||||
Public Sub LoadFile(FilePath As String)
|
||||
If _licenseKey = String.Empty Then
|
||||
_logger.Warn("License key was not provided. File {0} not loaded.", filepath)
|
||||
_logger.Warn("License key was not provided. File {0} not loaded.", FilePath)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
|
||||
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
|
||||
|
||||
_logger.Info("Loading File {0}", filepath)
|
||||
_logger.Info("Loading File {0}", FilePath)
|
||||
|
||||
DoLoadFile(filepath)
|
||||
DoLoadFile(FilePath)
|
||||
|
||||
If _view_only Then
|
||||
statusLabel.Text = _docPath
|
||||
statusLabel.Text = FilePath
|
||||
End If
|
||||
|
||||
UpdateMainUi()
|
||||
@@ -116,9 +118,17 @@ Public Class DocumentViewer
|
||||
Dim oFileInfo = New IO.FileInfo(FilePath)
|
||||
Dim oExtension As String = oFileInfo.Extension.ToUpper
|
||||
|
||||
RichEditControl1.Visible = False
|
||||
RichEditControl1.Dock = DockStyle.None
|
||||
|
||||
SpreadsheetControl1.Visible = False
|
||||
SpreadsheetControl1.Dock = DockStyle.None
|
||||
|
||||
mainToolStrip.Visible = False
|
||||
|
||||
Select Case oExtension.ToUpper
|
||||
Case ".MSG"
|
||||
Dim oMsg As New Independentsoft.Msg.Message(FilePath)
|
||||
Dim oMsg As New Message(FilePath)
|
||||
' TODO: Improve Encoding, maybe convert based on encoding
|
||||
oMsg.Encoding = System.Text.Encoding.UTF32
|
||||
Dim oMime = oMsg.ConvertToMimeMessage()
|
||||
@@ -136,15 +146,30 @@ Public Class DocumentViewer
|
||||
|
||||
RichEditControl1.Visible = True
|
||||
RichEditControl1.Dock = DockStyle.Fill
|
||||
|
||||
Case ".XLSX", ".XLS", "CSV"
|
||||
Dim oFormat As DevExpress.Spreadsheet.DocumentFormat = Undefined
|
||||
|
||||
Select Case oExtension.ToUpper
|
||||
Case "XLSX" : oFormat = Xlsx
|
||||
Case "XLS" : oFormat = Xls
|
||||
Case "CSV" : oFormat = Csv
|
||||
End Select
|
||||
|
||||
SpreadsheetControl1.LoadDocument(FilePath, oFormat)
|
||||
|
||||
Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
|
||||
oRange.AutoFitColumns()
|
||||
|
||||
SpreadsheetControl1.Visible = True
|
||||
SpreadsheetControl1.Dock = DockStyle.Fill
|
||||
|
||||
Case Else
|
||||
_docPath = FilePath
|
||||
_logger.Info("Displaying file {0}", FilePath)
|
||||
|
||||
_logger.Info("Displaying file {0}", _docPath)
|
||||
mainToolStrip.Visible = True
|
||||
|
||||
GdViewer.DisplayFromFile(_docPath)
|
||||
|
||||
RichEditControl1.Visible = False
|
||||
RichEditControl1.Dock = DockStyle.None
|
||||
GdViewer.DisplayFromFile(FilePath)
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
|
||||
Reference in New Issue
Block a user