From 87b442d896a6e8fb46fba9d6e1c1238b3b001e82 Mon Sep 17 00:00:00 2001 From: Developer01 Date: Fri, 18 Jul 2025 15:43:21 +0200 Subject: [PATCH] DocumentViewer back to richtextedit --- .../DocumentViewer.Designer.vb | 12 +++++++ Controls.DocumentViewer/DocumentViewer.vb | 11 +++++-- .../My Project/AssemblyInfo.vb | 2 +- GUIs.Test.TestGUI/frmDocView.Designer.vb | 31 +++++++++---------- GUIs.Test.TestGUI/frmDocView.vb | 11 ++++--- 5 files changed, 43 insertions(+), 24 deletions(-) diff --git a/Controls.DocumentViewer/DocumentViewer.Designer.vb b/Controls.DocumentViewer/DocumentViewer.Designer.vb index d8f7669a..d835097a 100644 --- a/Controls.DocumentViewer/DocumentViewer.Designer.vb +++ b/Controls.DocumentViewer/DocumentViewer.Designer.vb @@ -63,6 +63,7 @@ Partial Class DocumentViewer Me.SpreadsheetControl1 = New DevExpress.XtraSpreadsheet.SpreadsheetControl() Me.PrintDocument1 = New System.Drawing.Printing.PrintDocument() Me.lbFileNotLoaded = New DevExpress.XtraEditors.LabelControl() + Me.RichEditControl1 = New DevExpress.XtraRichEdit.RichEditControl() CType(Me.BarManager1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.RepositoryItemTextEdit2, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.RepositoryItemTextEdit3, System.ComponentModel.ISupportInitialize).BeginInit() @@ -450,10 +451,20 @@ Partial Class DocumentViewer Me.lbFileNotLoaded.Text = "Die Datei konnte nicht geladen werden" Me.lbFileNotLoaded.Visible = False ' + 'RichEditControl1 + ' + Me.RichEditControl1.Location = New System.Drawing.Point(571, 238) + Me.RichEditControl1.MenuManager = Me.BarManager1 + Me.RichEditControl1.Name = "RichEditControl1" + Me.RichEditControl1.Size = New System.Drawing.Size(400, 200) + Me.RichEditControl1.TabIndex = 5 + Me.RichEditControl1.Visible = False + ' 'DocumentViewer ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.RichEditControl1) Me.Controls.Add(Me.lbFileNotLoaded) Me.Controls.Add(Me.SpreadsheetControl1) Me.Controls.Add(Me.GdViewer) @@ -514,4 +525,5 @@ Partial Class DocumentViewer Friend WithEvents lbFileNotLoaded As DevExpress.XtraEditors.LabelControl Friend WithEvents btnSearch As DevExpress.XtraBars.BarButtonItem Friend WithEvents btnSearch2 As DevExpress.XtraBars.BarButtonItem + Friend WithEvents RichEditControl1 As DevExpress.XtraRichEdit.RichEditControl End Class diff --git a/Controls.DocumentViewer/DocumentViewer.vb b/Controls.DocumentViewer/DocumentViewer.vb index 3cf38d66..4db5ed8d 100644 --- a/Controls.DocumentViewer/DocumentViewer.vb +++ b/Controls.DocumentViewer/DocumentViewer.vb @@ -23,6 +23,7 @@ Public Class DocumentViewer Private Enum ViewerMode GDPicture Excel + Richtext End Enum Private Enum FileLoadMode @@ -124,8 +125,6 @@ Public Class DocumentViewer ''' Public Sub LoadFile(FilePath As String) FileLoaded = False - we - If _licenseKey = String.Empty Then _logger.Warn("License key was not provided. File {0} not loaded.", FilePath) Exit Sub @@ -442,6 +441,8 @@ Public Class DocumentViewer Select Case Extension.ToUpper Case "CSV" _ViewerMode = ViewerMode.Excel + Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT" + _ViewerMode = ViewerMode.RichText Case Else _ViewerMode = ViewerMode.GDPicture End Select @@ -472,7 +473,9 @@ Public Class DocumentViewer lbFileNotLoaded.Visible = False SpreadsheetControl1.Visible = False + RichEditControl1.Visible = False SpreadsheetControl1.Dock = DockStyle.None + RichEditControl1.Dock = DockStyle.None Select Case oExtension.ToUpper Case ".CSV" @@ -484,7 +487,11 @@ Public Class DocumentViewer SpreadsheetControl1.Visible = True SpreadsheetControl1.Dock = DockStyle.Fill + Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT" + RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(oExtension)) + RichEditControl1.Visible = True + RichEditControl1.Dock = DockStyle.Fill Case Else GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter diff --git a/Controls.DocumentViewer/My Project/AssemblyInfo.vb b/Controls.DocumentViewer/My Project/AssemblyInfo.vb index 36fdccbd..f1fdc4e4 100644 --- a/Controls.DocumentViewer/My Project/AssemblyInfo.vb +++ b/Controls.DocumentViewer/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + diff --git a/GUIs.Test.TestGUI/frmDocView.Designer.vb b/GUIs.Test.TestGUI/frmDocView.Designer.vb index 71c94244..3fa4cad5 100644 --- a/GUIs.Test.TestGUI/frmDocView.Designer.vb +++ b/GUIs.Test.TestGUI/frmDocView.Designer.vb @@ -1,9 +1,9 @@ - _ + Partial Class frmDocView Inherits System.Windows.Forms.Form 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -20,7 +20,7 @@ Partial Class frmDocView '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. - _ + Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel() Me.Button2 = New System.Windows.Forms.Button() @@ -28,7 +28,7 @@ Partial Class frmDocView Me.Button4 = New System.Windows.Forms.Button() Me.Button3 = New System.Windows.Forms.Button() Me.Button1 = New System.Windows.Forms.Button() - Me.TextBox1 = New System.Windows.Forms.TextBox() + Me.txtfilepath = New System.Windows.Forms.TextBox() Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog() Me.MyDocumentViewer = New DigitalData.Controls.DocumentViewer.DocumentViewer() Me.Panel1.SuspendLayout() @@ -41,7 +41,7 @@ Partial Class frmDocView Me.Panel1.Controls.Add(Me.Button4) Me.Panel1.Controls.Add(Me.Button3) Me.Panel1.Controls.Add(Me.Button1) - Me.Panel1.Controls.Add(Me.TextBox1) + Me.Panel1.Controls.Add(Me.txtfilepath) Me.Panel1.Dock = System.Windows.Forms.DockStyle.Top Me.Panel1.Location = New System.Drawing.Point(0, 0) Me.Panel1.Name = "Panel1" @@ -93,25 +93,25 @@ Partial Class frmDocView Me.Button1.Text = "Open File" Me.Button1.UseVisualStyleBackColor = True ' - 'TextBox1 + 'txtfilepath ' - Me.TextBox1.Location = New System.Drawing.Point(12, 12) - Me.TextBox1.Name = "TextBox1" - Me.TextBox1.Size = New System.Drawing.Size(524, 20) - Me.TextBox1.TabIndex = 0 + Me.txtfilepath.Location = New System.Drawing.Point(12, 12) + Me.txtfilepath.Name = "txtfilepath" + Me.txtfilepath.Size = New System.Drawing.Size(524, 20) + Me.txtfilepath.TabIndex = 0 ' 'OpenFileDialog1 ' Me.OpenFileDialog1.FileName = "OpenFileDialog1" ' - 'DocumentViewer1 + 'MyDocumentViewer ' Me.MyDocumentViewer.Dock = System.Windows.Forms.DockStyle.Fill Me.MyDocumentViewer.FileLoaded = False Me.MyDocumentViewer.Location = New System.Drawing.Point(0, 43) - Me.MyDocumentViewer.Name = "DocumentViewer1" + Me.MyDocumentViewer.Name = "MyDocumentViewer" Me.MyDocumentViewer.Size = New System.Drawing.Size(1079, 463) - Me.MyDocumentViewer.TabIndex = 0 + Me.MyDocumentViewer.TabIndex = 2 ' 'frmDocView ' @@ -127,14 +127,13 @@ Partial Class frmDocView Me.ResumeLayout(False) End Sub - - Friend WithEvents MyDocumentViewer As DigitalData.Controls.DocumentViewer.DocumentViewer Friend WithEvents Panel1 As Panel Friend WithEvents Button1 As Button - Friend WithEvents TextBox1 As TextBox + Friend WithEvents txtfilepath As TextBox Friend WithEvents OpenFileDialog1 As OpenFileDialog Friend WithEvents Button2 As Button Friend WithEvents Button3 As Button Friend WithEvents Button4 As Button Friend WithEvents Button5 As Button + Friend WithEvents MyDocumentViewer As DigitalData.Controls.DocumentViewer.DocumentViewer End Class diff --git a/GUIs.Test.TestGUI/frmDocView.vb b/GUIs.Test.TestGUI/frmDocView.vb index 858c266a..64366cab 100644 --- a/GUIs.Test.TestGUI/frmDocView.vb +++ b/GUIs.Test.TestGUI/frmDocView.vb @@ -8,13 +8,13 @@ Public Class frmDocView Private Const GDPICTURE_KEY = "kG1Qf9PwmqgR8aDmIW2zI_ebj48RzqAJegRxcystEmkbTGQqfkNBdFOXIb6C_A00Ra8zZkrHdfjqzOPXK7kgkF2YDhvrqKfqh4WDug2vOt0qO31IommzkANSuLjZ4zmraoubyEVd25rE3veQ2h_j7tGIoH_LyIHmy24GaXsxdG0yCzIBMdiLbMMMDwcPY-809KeZ83Grv76OVhFvcbBWyYc251vou1N-kGg5_ZlHDgfWoY85gTLRxafjD3KS_i9ARW4BMiy36y8n7UP2jN8kGRnW_04ubpFtfjJqvtsrP_J9D0x7bqV8xtVtT5JI6dpKsVTiMgDCrIcoFSo5gCC1fw9oUopX4TDCkBQttO4-WHBlOeq9dG5Yb0otonVmJKaQA2tP6sMR-lZDs3ql_WI9t91yPWgpssrJUxSHDd27_LMTH_owJIqkF3NOJd9mYQuAv22oNKFYbH8e41pVKb8cT33Y9CgcQ_sy6YDA5PTuIRi67mjKge_nD9rd0IN213Ir9M_EFWqg9e4haWzIdHXQUo0md70kVhPX4UIH_BKJnxEEnFfoFRNMh77bB0N4jkcBEHPl-ghOERv8dOztf4vCnNpzzWvcLD2cqWIm6THy8XGGq9h4hp8aEreRleSMwv9QQAC7mjLwhQ1rBYkpUHlpTjhTLnMwHknl6HH0Z6zzmsgkRKVyfquv94Pd7QbQfZrRka0ss_48pf9p8hAywEn81Q==" Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click - If String.IsNullOrEmpty(TextBox1.Text) Then + If String.IsNullOrEmpty(txtfilepath.Text) Then If OpenFileDialog1.ShowDialog() = DialogResult.OK Then - TextBox1.Text = OpenFileDialog1.FileName - MyDocumentViewer.LoadFile(TextBox1.Text) + txtfilepath.Text = OpenFileDialog1.FileName + MyDocumentViewer.LoadFile(txtfilepath.Text) End If Else - MyDocumentViewer.LoadFile(TextBox1.Text) + MyDocumentViewer.LoadFile(txtfilepath.Text) End If End Sub @@ -30,6 +30,7 @@ Public Class frmDocView Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click MyDocumentViewer.Done() + txtfilepath.Text = "" End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click @@ -46,7 +47,7 @@ Public Class frmDocView licenseManager.RegisterKEY(GDPICTURE_KEY) Dim oPDFConverter = New PDFConverter(LogConfig) - Dim oResult = oPDFConverter.ConvertPDFADocumentToPDFDocument(TextBox1.Text, TextBox1.Text & ".cloned.pdf") + Dim oResult = oPDFConverter.ConvertPDFADocumentToPDFDocument(txtfilepath.Text, txtfilepath.Text & ".cloned.pdf") If oResult = True Then MsgBox("Document was successfully cloned!")