fix documentviewer in showdialog

This commit is contained in:
Jonathan Jenne
2019-11-18 11:20:45 +01:00
parent b8736ee880
commit 5a370ff72c
9 changed files with 284 additions and 23 deletions

View File

@@ -48,6 +48,11 @@ Public Class DocumentViewer
UpdateMainUi()
End Sub
''' <summary>
''' Initialize the Viewer
''' </summary>
''' <param name="LogConfig">A LogConfig object</param>
''' <param name="LicenseKey">The GDPicture.NET License Key</param>
Public Sub Init(LogConfig As LogConfig, LicenseKey As String)
_logConfig = LogConfig
_logger = LogConfig.GetLogger()
@@ -56,6 +61,18 @@ Public Class DocumentViewer
_licenseManager.RegisterKEY(_licenseKey)
End Sub
''' <summary>
''' Terminate Viewer, freeing up resources and deleting temp files
''' </summary>
Public Sub Done()
DeleteTempFiles()
Dispose()
End Sub
''' <summary>
''' Load a file and display it
''' </summary>
''' <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)
@@ -74,7 +91,20 @@ Public Class DocumentViewer
UpdateMainUi()
End Sub
Public Sub DoLoadFile(FilePath As String)
Public Sub DeleteTempFiles()
For Each oFile In _TempFiles
Try
IO.File.Delete(oFile)
Catch ex As Exception
_logger.Warn("Could not delete temp file {0}", oFile)
End Try
Next
_TempFiles.Clear()
End Sub
Private Sub DoLoadFile(FilePath As String)
Try
Dim oFileInfo = New IO.FileInfo(FilePath)
Dim oExtension As String = oFileInfo.Extension
@@ -497,12 +527,6 @@ Public Class DocumentViewer
End Sub
Private Sub DocumentViewer_Disposed(sender As Object, e As EventArgs) Handles Me.Disposed
For Each oFile In _TempFiles
Try
IO.File.Delete(oFile)
Catch ex As Exception
_logger.Warn("Could not delete temp file {0}", oFile)
End Try
Next
GdViewer.Dispose()
End Sub
End Class