DocumentViewer: Add FileLoaded Property
This commit is contained in:
@@ -31,6 +31,7 @@ Public Class DocumentViewer
|
||||
Private _hide_file_info_from_user As Boolean = False
|
||||
Private _FilePath As String
|
||||
|
||||
|
||||
' List of all created temp files when converting msg files
|
||||
Private _TempFiles As New List(Of String)
|
||||
|
||||
@@ -40,6 +41,8 @@ Public Class DocumentViewer
|
||||
UpdateMainUi()
|
||||
End Sub
|
||||
|
||||
Public Property FileLoaded As Boolean = False
|
||||
|
||||
''' <summary>
|
||||
''' Initialize the Viewer
|
||||
''' </summary>
|
||||
@@ -66,6 +69,8 @@ Public Class DocumentViewer
|
||||
''' </summary>
|
||||
''' <param name="FilePath"></param>
|
||||
Public Sub LoadFile(FilePath As String)
|
||||
FileLoaded = False
|
||||
|
||||
If _licenseKey = String.Empty Then
|
||||
_logger.Warn("License key was not provided. File {0} not loaded.", FilePath)
|
||||
Exit Sub
|
||||
@@ -73,12 +78,19 @@ Public Class DocumentViewer
|
||||
|
||||
_logger.Info("Loading File {0}", FilePath)
|
||||
|
||||
DoLoadFile(FilePath)
|
||||
Dim oFileLoaded = DoLoadFile(FilePath)
|
||||
_FilePath = FilePath
|
||||
|
||||
If oFileLoaded = True Then
|
||||
FileLoaded = True
|
||||
End If
|
||||
|
||||
UpdateMainUi()
|
||||
End Sub
|
||||
|
||||
Public Sub LoadFile(FileName As String, Stream As Stream)
|
||||
FileLoaded = False
|
||||
|
||||
If _licenseKey = String.Empty Then
|
||||
_logger.Warn("License key was not provided. File [{0}] not loaded.", FileName)
|
||||
Exit Sub
|
||||
@@ -88,7 +100,11 @@ Public Class DocumentViewer
|
||||
|
||||
_logger.Info("Loading File [{0}]", FileName)
|
||||
|
||||
DoLoadFile(Stream, oExtension)
|
||||
Dim ofileloaded = DoLoadFile(Stream, oExtension)
|
||||
|
||||
If oFileLoaded = True Then
|
||||
FileLoaded = True
|
||||
End If
|
||||
|
||||
UpdateMainUi()
|
||||
End Sub
|
||||
@@ -114,22 +130,23 @@ Public Class DocumentViewer
|
||||
Dim oExtension As String = oFileInfo.Extension.ToUpper
|
||||
Select Case oExtension.ToUpper
|
||||
Case ".MSG"
|
||||
|
||||
RichEditControl1.CreateNewDocument()
|
||||
|
||||
|
||||
Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
|
||||
RichEditControl1.CreateNewDocument()
|
||||
|
||||
Case ".XLSX", ".XLS", "CSV"
|
||||
SpreadsheetControl1.CreateNewDocument()
|
||||
|
||||
Case Else
|
||||
GdViewer.CloseDocument()
|
||||
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
_logger.Warn($"Unexpected error in FreeFile: {ex.Message}")
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub DoLoadFile(FilePath As String)
|
||||
Private Function DoLoadFile(FilePath As String) As Boolean
|
||||
Try
|
||||
Dim oFileInfo = New IO.FileInfo(FilePath)
|
||||
Dim oExtension As String = oFileInfo.Extension.ToUpper
|
||||
@@ -183,12 +200,15 @@ Public Class DocumentViewer
|
||||
End Select
|
||||
|
||||
UpdateMainUi()
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Sub
|
||||
End Function
|
||||
|
||||
Private Sub DoLoadFile(Stream As Stream, Extension As String)
|
||||
Private Function DoLoadFile(Stream As Stream, Extension As String) As Boolean
|
||||
Try
|
||||
RichEditControl1.Visible = False
|
||||
RichEditControl1.Dock = DockStyle.None
|
||||
@@ -240,10 +260,13 @@ Public Class DocumentViewer
|
||||
End Select
|
||||
|
||||
UpdateMainUi()
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Sub
|
||||
End Function
|
||||
|
||||
Private Function GetSpreadsheetFormat(Extension) As Spreadsheet.DocumentFormat
|
||||
Dim oFormat As Spreadsheet.DocumentFormat = Spreadsheet.DocumentFormat.Undefined
|
||||
@@ -257,7 +280,7 @@ Public Class DocumentViewer
|
||||
Return oFormat
|
||||
End Function
|
||||
|
||||
Private Function GetDocumentFormat(Extension)
|
||||
Private Function GetDocumentFormat(Extension) As XtraRichEdit.DocumentFormat
|
||||
Dim oFormat As XtraRichEdit.DocumentFormat = XtraRichEdit.DocumentFormat.Undefined
|
||||
|
||||
Select Case Extension.ToUpper
|
||||
@@ -444,4 +467,5 @@ Public Class DocumentViewer
|
||||
Private Sub btnSettings_Click(sender As Object, e As XtraBars.ItemClickEventArgs) Handles buttonSettings.ItemClick
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user