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

View File

@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Independentsoft.Msg" publicKeyToken="76be97fe952f1ec7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.570.17147" newVersion="2.0.570.17147" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -22,21 +22,12 @@ Partial Class Form1
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.DocumentViewer1 = New DigitalData.Controls.DocumentViewer.DocumentViewer()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog()
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'DocumentViewer1
'
Me.DocumentViewer1.Dock = System.Windows.Forms.DockStyle.Bottom
Me.DocumentViewer1.Location = New System.Drawing.Point(0, 66)
Me.DocumentViewer1.Name = "DocumentViewer1"
Me.DocumentViewer1.Size = New System.Drawing.Size(800, 384)
Me.DocumentViewer1.TabIndex = 0
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(12, 12)
@ -74,15 +65,12 @@ Partial Class Form1
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.DocumentViewer1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents DocumentViewer1 As DigitalData.Controls.DocumentViewer.DocumentViewer
Friend WithEvents TextBox1 As TextBox
Friend WithEvents OpenFileDialog1 As OpenFileDialog
Friend WithEvents Button1 As Button

View File

@ -1,6 +1,8 @@
Imports DigitalData.Modules.Logging
Public Class Form1
Private oSubform As Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim oResult = OpenFileDialog1.ShowDialog()
@ -10,7 +12,8 @@ Public Class Form1
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
DocumentViewer1.LoadFile(TextBox1.Text)
oSubform.FilePath = TextBox1.Text
oSubform.ShowDialog()
Catch ex As Exception
MsgBox(ex.Message)
End Try
@ -19,6 +22,12 @@ Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim oKey = "0467389434974657969312056"
Dim oLogConfig As New LogConfig(LogConfig.PathType.CurrentDirectory)
DocumentViewer1.Init(oLogConfig, oKey)
oSubform = New Form2(oLogConfig, oKey)
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
End Sub
End Class

View File

@ -0,0 +1,49 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form2
Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Wird vom Windows Form-Designer benötigt.
Private components As System.ComponentModel.IContainer
'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.DocumentViewer1 = New DigitalData.Controls.DocumentViewer.DocumentViewer()
Me.SuspendLayout()
'
'DocumentViewer1
'
Me.DocumentViewer1.Dock = System.Windows.Forms.DockStyle.Fill
Me.DocumentViewer1.Location = New System.Drawing.Point(0, 0)
Me.DocumentViewer1.Name = "DocumentViewer1"
Me.DocumentViewer1.Size = New System.Drawing.Size(800, 450)
Me.DocumentViewer1.TabIndex = 0
'
'Form2
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(800, 450)
Me.Controls.Add(Me.DocumentViewer1)
Me.Name = "Form2"
Me.Text = "Form2"
Me.ResumeLayout(False)
End Sub
Friend WithEvents DocumentViewer1 As DigitalData.Controls.DocumentViewer.DocumentViewer
End Class

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,40 @@
Imports System.ComponentModel
Imports DigitalData.Modules.Logging
Public Class Form2
Public FilePath As String
Private Key As String
Private LogConfig As LogConfig
Private Logger As Logger
Public Sub New(LogConfig As LogConfig, Key As String)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
Me.LogConfig = LogConfig
Me.Key = Key
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Logger = LogConfig.GetLogger
Logger.Info("DocumentViewer Form Loaded")
DocumentViewer1.Init(LogConfig, Key)
DocumentViewer1.LoadFile(FilePath)
Logger.Info("File Loaded")
End Sub
Private Sub Form2_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
Logger.Info("Form closed")
End Sub
Private Sub Form2_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
DocumentViewer1.Done()
Logger.Info("Form closing")
End Sub
End Class

View File

@ -56,10 +56,19 @@
<Reference Include="Independentsoft.Msg">
<HintPath>P:\Visual Studio Projekte\Bibliotheken\MSG .NET\Bin\14_11_19_MIME_UTF_ENCODING\Independentsoft.Msg.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.6.8\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
@ -88,6 +97,12 @@
<DependentUpon>Form1.vb</DependentUpon>
<SubType>Form</SubType>
</Compile>
<Compile Include="Form2.Designer.vb">
<DependentUpon>Form2.vb</DependentUpon>
</Compile>
<Compile Include="Form2.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
@ -108,6 +123,9 @@
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form2.resx">
<DependentUpon>Form2.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
@ -126,6 +144,7 @@
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Modules.Logging\Logging.vbproj">

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.6.8" targetFramework="net461" />
</packages>