DocumentViewer: Version 1.0.1.0
This commit is contained in:
@@ -3,9 +3,9 @@ Imports System.Globalization
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports Independentsoft.Msg
|
||||
Imports DevExpress.Spreadsheet.DocumentFormat
|
||||
Imports DevExpress.Spreadsheet
|
||||
Imports GdPicture14
|
||||
Imports DevExpress
|
||||
|
||||
Public Class DocumentViewer
|
||||
Private Enum ZoomMode
|
||||
@@ -69,9 +69,7 @@ Public Class DocumentViewer
|
||||
''' Terminate Viewer, freeing up resources and deleting temp files
|
||||
''' </summary>
|
||||
Public Sub Done()
|
||||
_logger.Warn("Called Done, removing temp files")
|
||||
DeleteTempFiles()
|
||||
'Dispose()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
@@ -132,28 +130,37 @@ Public Class DocumentViewer
|
||||
Dim oTempFileName = IO.Path.GetTempFileName()
|
||||
oMime.Save(oTempFileName, True)
|
||||
|
||||
RichEditControl1.LoadDocument(oTempFileName, DevExpress.XtraRichEdit.DocumentFormat.Mht)
|
||||
RichEditControl1.LoadDocument(oTempFileName, XtraRichEdit.DocumentFormat.Mht)
|
||||
|
||||
_TempFiles.Add(oTempFileName)
|
||||
|
||||
RichEditControl1.Visible = True
|
||||
RichEditControl1.Dock = DockStyle.Fill
|
||||
|
||||
Me.infoLabel.Text = "Type: " & "MSG Email File"
|
||||
Case ".EML"
|
||||
RichEditControl1.LoadDocument(FilePath, DevExpress.XtraRichEdit.DocumentFormat.Mht)
|
||||
Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
|
||||
Dim oFormat As XtraRichEdit.DocumentFormat = XtraRichEdit.DocumentFormat.Undefined
|
||||
|
||||
Select Case oExtension.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
|
||||
|
||||
RichEditControl1.LoadDocument(FilePath, oFormat)
|
||||
|
||||
RichEditControl1.Visible = True
|
||||
RichEditControl1.Dock = DockStyle.Fill
|
||||
|
||||
Me.infoLabel.Text = "Type: " & "EML Email File"
|
||||
Case ".XLSX", ".XLS", "CSV"
|
||||
Dim oFormat As DevExpress.Spreadsheet.DocumentFormat = Undefined
|
||||
Dim oFormat As Spreadsheet.DocumentFormat = Spreadsheet.DocumentFormat.Undefined
|
||||
|
||||
Select Case oExtension.ToUpper
|
||||
Case "XLSX" : oFormat = Xlsx
|
||||
Case "XLS" : oFormat = Xls
|
||||
Case "CSV" : oFormat = Csv
|
||||
Case "XLSX" : oFormat = Spreadsheet.DocumentFormat.Xlsx
|
||||
Case "XLS" : oFormat = Spreadsheet.DocumentFormat.Xls
|
||||
Case "CSV" : oFormat = Spreadsheet.DocumentFormat.Csv
|
||||
End Select
|
||||
|
||||
SpreadsheetControl1.LoadDocument(FilePath, oFormat)
|
||||
@@ -164,22 +171,11 @@ Public Class DocumentViewer
|
||||
SpreadsheetControl1.Visible = True
|
||||
SpreadsheetControl1.Dock = DockStyle.Fill
|
||||
|
||||
Me.infoLabel.Text = "Type: " & "Excel/CSV File"
|
||||
Case Else
|
||||
_logger.Info("Displaying file {0}", FilePath)
|
||||
|
||||
mainToolStrip.Visible = True
|
||||
|
||||
GdViewer.DisplayFromFile(FilePath)
|
||||
|
||||
Me.infoLabel.Text = "Type: " & GetDocumentTypeLabel()
|
||||
End Select
|
||||
|
||||
If _hide_file_info_from_user Then
|
||||
statusLabel.Text = String.Empty
|
||||
Else
|
||||
statusLabel.Text = "Path: " & FilePath
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
@@ -197,25 +193,6 @@ Public Class DocumentViewer
|
||||
UpdateMainUi()
|
||||
End Sub
|
||||
|
||||
Private Function GetDocumentTypeLabel() As String
|
||||
Dim result As String = ""
|
||||
Select Case GdViewer.GetDocumentType()
|
||||
Case DocumentType.DocumentTypeBitmap
|
||||
result = "Imagefile"
|
||||
Case DocumentType.DocumentTypeMetaFile
|
||||
result = "Metafile"
|
||||
Case DocumentType.DocumentTypePDF
|
||||
result = "PDF"
|
||||
Case DocumentType.DocumentTypeSVG
|
||||
result = "SVG"
|
||||
Case DocumentType.DocumentTypeTXT
|
||||
result = "textfile"
|
||||
Case DocumentType.DocumentTypeUnknown
|
||||
result = "Unknown"
|
||||
End Select
|
||||
Return result
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Configures the viewer to hide the file path to the end-user.
|
||||
''' </summary>
|
||||
@@ -558,9 +535,4 @@ Public Class DocumentViewer
|
||||
MagnifierToolStripMenuItem.Checked = True
|
||||
GdViewer.Focus()
|
||||
End Sub
|
||||
|
||||
'Private Sub DocumentViewer_Disposed(sender As Object, e As EventArgs) Handles Me.Disposed
|
||||
' _logger.Warn("Disposing GDViewer")
|
||||
' GdViewer.Dispose()
|
||||
'End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user