replace viewer with gdpicture documentviewer

This commit is contained in:
Jonathan Jenne
2019-11-21 12:11:39 +01:00
parent 96d80e23bd
commit 552101192b
16 changed files with 83 additions and 1408 deletions

View File

@@ -1901,6 +1901,8 @@ Public Class frmIndex
End Sub
Private Sub frmIndex_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Try
DocumentViewer1.Dispose()
ClassWindowLocation.SaveFormLocationSize(Me)
CloseUniversalViewer()
My.Settings.Save()
@@ -1915,7 +1917,7 @@ Public Class frmIndex
If Not workfile.EndsWith("msg") Then
CURRENT_HTML_DOC = ""
If workfile.EndsWith("pdf") Then
Me.PdfViewer1.DocumentFilePath = ""
DocumentViewer1.CloseFile()
My.Settings.SplitterDistance_Viewer = SplitContainer1.SplitterDistance
Else
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("Viewer")
@@ -1950,7 +1952,12 @@ Public Class frmIndex
CURRENT_ISATTACHMENT = False
DropType = ClassDatabase.Execute_Scalar("SELECT HANDLE_TYPE FROM TBGI_FILES_USER WHERE GUID = " & CURRENT_WORKFILE_GUID, MyConnectionString, True)
chkdelete_origin.Visible = False
'DocumentViewer1.Init(LOGCONFIG, "21182889975216572111813147150675976632")
VIEWER_LICENSE = ClassDatabase.Execute_Scalar("SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'", MyConnectionString)
'TODO: Load License from DB
DocumentViewer1.Init(LOGCONFIG, VIEWER_LICENSE)
CURRENT_DROPTYPE = DropType.Replace("|", "")
If DropType = "|DROPFROMFSYSTEM|" Then
chkdelete_origin.Visible = True
@@ -2578,155 +2585,10 @@ Public Class frmIndex
Sub PreviewFile()
Try
Dim Proc As New System.Diagnostics.Process
Me.grpbxMailBody.Visible = False
Me.grpBetreff.Visible = False
Me.pnlPDF.Visible = False
CURRENT_HTML_DOC = ""
Dim workfile As String = CURRENT_WORKFILE.ToLower
'DocumentViewer1.LoadFile(CURRENT_WORKFILE)
If Not workfile.EndsWith("msg") Then
CURRENT_HTML_DOC = ""
If workfile.EndsWith("pdf") Then
Me.SplitContainer1.Panel2Collapsed = False
PdfViewer1.LoadDocument(CURRENT_WORKFILE)
PdfViewer1.ZoomMode = DevExpress.XtraPdfViewer.PdfZoomMode.FitToWidth
pnlPDF.Dock = DockStyle.Fill
SplitContainer1.SplitterDistance = My.Settings.SplitterDistance_Viewer
Me.pnlPDF.Visible = True
Else
Me.SplitContainer1.Panel2Collapsed = True
Select Case Path.GetExtension(CURRENT_WORKFILE)
Case ".docx"
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("winword")
Dim filename As String = Path.GetFileNameWithoutExtension(CURRENT_WORKFILE)
For Each p As Process In pProcess
If p.MainWindowTitle.Contains(filename) Then
p.CloseMainWindow()
End If
Next
Case ".xlsx"
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("excel")
Dim filename As String = Path.GetFileNameWithoutExtension(CURRENT_WORKFILE)
For Each p As Process In pProcess
If p.MainWindowTitle.Contains(filename) Then
p.CloseMainWindow()
End If
Next
Case Else
If My.Settings.DoNot_Show_Documents = False And UniversalViewer_Path <> "" Then
If File.Exists(UniversalViewer_Path) Then
Dim psi As New ProcessStartInfo(UniversalViewer_Path, """" & CURRENT_WORKFILE & """")
Proc.EnableRaisingEvents = True
Proc.StartInfo = psi
Proc.Start()
End If
End If
End Select
End If
Else
Dim tempFilename = My.Computer.FileSystem.GetTempFileName()
Dim tempFilename1 = My.Computer.FileSystem.GetTempFileName()
Try
Me.grpBetreff.Dock = DockStyle.Top
Me.grpbxMailBody.Dock = DockStyle.Fill
'Dim msg_email As New Msg.Message(CURRENT_WORKFILE)
'Dim foo As New Email.Mime.Message(CURRENT_WORKFILE)
Dim msg_email As New Msg.Message()
msg_email.Encoding = Encoding.UTF8
msg_email.Open(CURRENT_WORKFILE)
Dim headers As String = ClassEmailHeaderExtractor.getMessageHeaders(msg_email)
If LogErrorsOnly = False Then ClassLogger.Add(" EMAIL-HEADER: " & headers, False)
'Eine tempfile generieren
Dim name = Path.GetFileNameWithoutExtension(tempFilename)
tempFilename = Path.Combine(Path.GetDirectoryName(tempFilename), name & ".html")
name = Path.GetFileNameWithoutExtension(tempFilename1)
tempFilename1 = Path.Combine(Path.GetDirectoryName(tempFilename1), name & ".msg")
msg_email.Save(tempFilename1)
Dim msg_email_unicode As New Msg.Message(tempFilename1)
TEMP_FILES.Add(tempFilename)
TEMP_FILES.Add(tempFilename1)
If LogErrorsOnly = False Then ClassLogger.Add(" ...tempFilename: " & tempFilename, False)
If LogErrorsOnly = False Then ClassLogger.Add(" ...tempFilename1: " & tempFilename1, False)
'tempfile löschen
If My.Computer.FileSystem.FileExists(tempFilename) Then
My.Computer.FileSystem.DeleteFile(tempFilename)
End If
Dim codepage As Integer = Console.OutputEncoding.CodePage
Dim msg_email_subject As New Msg.Message()
msg_email_subject.Encoding = Encoding.GetEncoding(codepage)
msg_email_subject.Open(CURRENT_WORKFILE)
If msg_email_subject.Subject = "" Then
Me.txtBetreff.Text = "!!No subject in email!!"
Else
If LogErrorsOnly = False Then ClassLogger.Add(" ...subject before converting: '" & msg_email_subject.Subject & "'", False)
Dim betreff = ClassHelper.encode_utf8(msg_email_subject.Subject)
If Not IsNothing(betreff) Then
If ClassHelper.CheckSpecialSigns(betreff) > 0 Then
End If
If LogErrorsOnly = False Then ClassLogger.Add(" ...subject after converting: " & betreff, False)
Me.txtBetreff.Text = betreff
Else
ClassLogger.Add(" ...subject could not be converted to utf8!", False)
Me.txtBetreff.Text = msg_email_subject.Subject
End If
End If
'Try
Dim wFile As System.IO.FileStream
Dim byteData() As Byte
byteData = msg_email_unicode.BodyHtml
If LogErrorsOnly = False Then ClassLogger.Add(" ...byteData HTML finished", False)
' MsgBox(msg_email.InternetCodePage)
' wFile = New FileStream(tempFilename, FileMode.Append)
' wFile.Write(byteData, 0, byteData.Length)
' wFile.Close()
'Catch ex As IOException
' MsgBox(ex.ToString)
'End Try
If IsNothing(msg_email_unicode.BodyHtml) Then
File.WriteAllText(tempFilename, msg_email_unicode.Body, System.Text.Encoding.UTF8)
Else
Dim vOut As String = System.Text.Encoding.UTF8.GetString(msg_email_unicode.BodyHtml)
File.WriteAllText(tempFilename, vOut, System.Text.Encoding.UTF8)
End If
If LogErrorsOnly = False Then ClassLogger.Add(" ...byteData and write to file finished.", False)
Catch ex As Exception
MsgBox("Unexpected Error in getHTML from Email: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
CURRENT_HTML_DOC = tempFilename
Me.tslblWebbrowser.Text = CURRENT_HTML_DOC
WebBrowser.Navigate("file:///" & CURRENT_HTML_DOC)
Me.grpbxMailBody.Visible = True
Me.grpBetreff.Visible = True
Me.SplitContainer1.Panel2Collapsed = False
SplitContainer1.SplitterDistance = My.Settings.SplitterDistance_Viewer
End If
' Dim psi1 As New ProcessStartInfo("""" & CURRENT_WORKFILE & """")
' Proc.EnableRaisingEvents = True
' Proc.StartInfo = psi1
' Proc.Start()
' Me.tslblVorschau.Visible = True
'Else
' End If
DocumentViewer1.LoadFile(CURRENT_WORKFILE)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler in PreviewFile:")
End Try
End Sub
Private Function UnicodeBytesToString(ByVal bytes() As Byte) As String
Return System.Text.Encoding.UTF8.GetString(bytes)
@@ -2783,7 +2645,7 @@ Public Class frmIndex
ElseIf DropType = "|ATTMNTEXTRACTED|" Or DropType = "|OUTLOOK_ATTACHMENT|" Then
'Die temporäre Datei löschen
If CURRENT_WORKFILE.EndsWith("pdf") Then
Me.PdfViewer1.DocumentFilePath = ""
DocumentViewer1.CloseFile()
End If
DeleteFile()
@@ -3016,31 +2878,6 @@ Public Class frmIndex
End Try
End Function
Private Sub PdfViewer1_ZoomChanged(sender As Object, e As DevExpress.XtraPdfViewer.PdfZoomChangedEventArgs)
If Not PdfViewer1.ZoomMode = DevExpress.XtraPdfViewer.PdfZoomMode.Custom Then
'SaveMySettingsValue("PDFViewer_ZoomMode", PdfViewer1.ZoomMode)
'PDFViewer_ZoomMode = PdfViewer1.ZoomMode
End If
End Sub
Private Sub PdfViewer1_DocumentChanged(sender As Object, e As DevExpress.XtraPdfViewer.PdfDocumentChangedEventArgs) Handles PdfViewer1.DocumentChanged
PDF_Pagenumber()
End Sub
Private Sub PdfViewer1_CurrentPageChanged(sender As Object, e As DevExpress.XtraPdfViewer.PdfCurrentPageChangedEventArgs) Handles PdfViewer1.CurrentPageChanged
PDF_Pagenumber()
End Sub
Sub PDF_Pagenumber()
Try
If USER_LANGUAGE = "de-DE" Then
pdfstatuslblPageNumber.Text = "Seite " & PdfViewer1.CurrentPageNumber & "/" & PdfViewer1.PageCount
Else
pdfstatuslblPageNumber.Text = "Page " & PdfViewer1.CurrentPageNumber & "/" & PdfViewer1.PageCount
End If
Catch ex As Exception
End Try
End Sub
Private Function CreateFolderForIndex(myDynamicFolder As String)
Try
Dim ORootFolder As String = Path.GetDirectoryName(CURRENT_NEWFILENAME)