Projektbereinigung: Entfernung alter Module und Ressourcen
Mehrere Module (`ChatAddUser`, `ChatControl`, `ChatNewConv`) und deren zugehörige Dateien wurden vollständig aus dem Projekt entfernt. Dies umfasst Designer-, Ressourcen- und Projektdateien sowie Backup-Dateien. Zusätzlich wurden nicht mehr benötigte Bilder, Lizenzdateien (`licenses.licx`), Konfigurationsdateien (`app.config`, `packages.config`) und generierte Dateien entfernt. Die Abhängigkeiten in `App.config` wurden aktualisiert, und neue Bibliotheken wie `System.Threading.Tasks.Extensions` wurden hinzugefügt. Eine Methode in `Annotations.vb` wurde angepasst, um Änderungen in der zugrunde liegenden API zu berücksichtigen. Diese Änderungen sind Teil einer umfassenden Bereinigung und Modernisierung des Projekts.
This commit is contained in:
@@ -33,7 +33,7 @@ Public Class DocumentViewer
|
||||
|
||||
Public ReadOnly Property PdfViewer As GdViewer
|
||||
Get
|
||||
Return GdViewer
|
||||
Return MyGDPViewer
|
||||
End Get
|
||||
End Property
|
||||
|
||||
@@ -69,7 +69,19 @@ Public Class DocumentViewer
|
||||
' Ensure search is initialized once the control (and GdViewer) exists
|
||||
EnsureSearchInitialized()
|
||||
UpdateMainUi()
|
||||
UpdateNoFileSelectedLabel(FileLoaded)
|
||||
End Sub
|
||||
|
||||
Private Sub DocumentViewer_FileLoadedChanged(ByVal sender As Object, ByVal isLoaded As Boolean) Handles Me.FileLoadedChanged
|
||||
UpdateNoFileSelectedLabel(isLoaded)
|
||||
End Sub
|
||||
|
||||
Private Sub UpdateNoFileSelectedLabel(ByVal isLoaded As Boolean)
|
||||
If lbFileNotLoaded IsNot Nothing Then
|
||||
lbFileNotLoaded.Visible = Not isLoaded
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'hallo
|
||||
Public Class ToolbarSettings
|
||||
Public Property ShowPrintButton As Boolean = True
|
||||
@@ -82,7 +94,24 @@ Public Class DocumentViewer
|
||||
Public Property ShowSettingButton As Boolean = True
|
||||
End Class
|
||||
|
||||
Public Property FileLoaded As Boolean = False
|
||||
Private _fileLoaded As Boolean = False
|
||||
|
||||
Public Event FileLoadedChanged(ByVal sender As Object, ByVal isLoaded As Boolean)
|
||||
|
||||
Public Property FileLoaded As Boolean
|
||||
Get
|
||||
Return _fileLoaded
|
||||
End Get
|
||||
Set(ByVal value As Boolean)
|
||||
If _fileLoaded = value Then
|
||||
Return
|
||||
End If
|
||||
|
||||
_fileLoaded = value
|
||||
RaiseEvent FileLoadedChanged(Me, _fileLoaded)
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property Viewer_ForceTemporaryMode As Boolean = False
|
||||
Public ReadOnly Property AnnotationsSaved As Boolean
|
||||
Get
|
||||
@@ -128,8 +157,8 @@ Public Class DocumentViewer
|
||||
' Create the Search helper only when both the log config and the GdViewer control exist
|
||||
Private Sub EnsureSearchInitialized()
|
||||
Try
|
||||
If _Search Is Nothing AndAlso _logConfig IsNot Nothing AndAlso GdViewer IsNot Nothing Then
|
||||
_Search = New Search(_logConfig, GdViewer)
|
||||
If _Search Is Nothing AndAlso _logConfig IsNot Nothing AndAlso MyGDPViewer IsNot Nothing Then
|
||||
_Search = New Search(_logConfig, MyGDPViewer)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_logger?.Error(ex)
|
||||
@@ -139,7 +168,7 @@ Public Class DocumentViewer
|
||||
''' <summary>
|
||||
''' Load a file from a path and display it
|
||||
''' </summary>
|
||||
Public Sub LoadFile(FilePath As String)
|
||||
Public Sub LoadFile_FromPath(FilePath As String)
|
||||
FileLoaded = False
|
||||
If _licenseKey = String.Empty Then
|
||||
_logger.Warn("License key was not provided. File {0} not loaded.", FilePath)
|
||||
@@ -151,6 +180,10 @@ Public Class DocumentViewer
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' Reset state from previous file
|
||||
_ViewOverride = ""
|
||||
_ViewerMode = ViewerMode.GDPicture ' Default mode
|
||||
|
||||
_FilePath = FilePath
|
||||
_FileLoadMode = FileLoadMode.File
|
||||
_FileInfo = New FileInfo(FilePath)
|
||||
@@ -164,10 +197,12 @@ Public Class DocumentViewer
|
||||
''' <summary>
|
||||
''' Load a file from a stream and display it
|
||||
''' </summary>
|
||||
Public Sub LoadFile(FileName As String, Stream As Stream)
|
||||
Public Sub LoadFile_FromStream(FileName As String, Stream As Stream)
|
||||
FileLoaded = False
|
||||
|
||||
|
||||
' Reset state from previous file
|
||||
_ViewOverride = ""
|
||||
_ViewerMode = ViewerMode.GDPicture ' Default mode
|
||||
|
||||
Dim oExtension As String = FileName.Substring(FileName.LastIndexOf("."))
|
||||
|
||||
@@ -175,9 +210,8 @@ Public Class DocumentViewer
|
||||
_FileLoadMode = FileLoadMode.Stream
|
||||
|
||||
_logger.Info("Loading file [{0}] from Stream", FileName)
|
||||
FileLoaded = DoLoadFile(Stream, oExtension)
|
||||
|
||||
SetViewerMode(oExtension)
|
||||
FileLoaded = DoLoadFileExtension(Stream, oExtension)
|
||||
UpdateMainUi()
|
||||
End Sub
|
||||
|
||||
@@ -210,7 +244,7 @@ Public Class DocumentViewer
|
||||
Dim oOpacity = 1.0F
|
||||
Dim oRotation = 0.0F
|
||||
|
||||
GdViewer.AddTextAnnotationInteractive(pText, oFontColor, oFontFamily, oFontStyle, oFontSize, Fill:=True, oBorderColor, oBackColor, oOpacity, oRotation)
|
||||
MyGDPViewer.AddTextAnnotationInteractive(pText, oFontColor, oFontFamily, oFontStyle, oFontSize, Fill:=True, oBorderColor, oBackColor, oOpacity, oRotation)
|
||||
_AnnotationsPending = True
|
||||
|
||||
Return True
|
||||
@@ -219,11 +253,11 @@ Public Class DocumentViewer
|
||||
Public Function Save() As Boolean
|
||||
Dim oSaveResult As GdPictureStatus = GdPictureStatus.OK
|
||||
|
||||
If GdViewer.BurnAnnotationsToPage(True, False) = GdPictureStatus.OK Then
|
||||
If MyGDPViewer.BurnAnnotationsToPage(True, False) = GdPictureStatus.OK Then
|
||||
If _FileLoadMode = FileLoadMode.Stream Then
|
||||
oSaveResult = GdViewer.SaveDocumentToPDF(_FileStream)
|
||||
oSaveResult = MyGDPViewer.SaveDocumentToPDF(_FileStream)
|
||||
Else
|
||||
oSaveResult = GdViewer.SaveDocumentToPDF(_FilePath)
|
||||
oSaveResult = MyGDPViewer.SaveDocumentToPDF(_FilePath)
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -238,9 +272,9 @@ Public Class DocumentViewer
|
||||
Public Sub CloseDocument()
|
||||
Try
|
||||
' Null-sicher schließen
|
||||
If GdViewer IsNot Nothing Then
|
||||
If MyGDPViewer IsNot Nothing Then
|
||||
Try
|
||||
GdViewer.CloseDocument()
|
||||
MyGDPViewer.CloseDocument()
|
||||
Catch exInner As Exception
|
||||
_logger?.Warn("Fehler beim Schließen von GdViewer")
|
||||
_logger?.Error(exInner)
|
||||
@@ -252,10 +286,11 @@ Public Class DocumentViewer
|
||||
_FileInfo = Nothing
|
||||
_FilePath = Nothing
|
||||
_FileStream = Nothing
|
||||
|
||||
FileLoaded = False
|
||||
UpdateMainUi()
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
FileLoaded = False
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -301,112 +336,142 @@ Public Class DocumentViewer
|
||||
#Region "Form Events"
|
||||
|
||||
Private Sub btnFitWidth_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitWidth.ItemClick
|
||||
FitToWidth()
|
||||
_Config.Config.PageFit = Config.PageFitSetting.FitWidth
|
||||
_Config.Save()
|
||||
Select Case _ViewerMode
|
||||
Case ViewerMode.GDPicture
|
||||
FitToWidth()
|
||||
_Config.Config.PageFit = Config.PageFitSetting.FitWidth
|
||||
_Config.Save()
|
||||
Case ViewerMode.Richtext
|
||||
RichEditControl1.ActiveView.ZoomFactor = 1.0F
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub btnFitPage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFitPage.ItemClick
|
||||
FitToPage()
|
||||
_Config.Config.PageFit = Config.PageFitSetting.FitPage
|
||||
_Config.Save()
|
||||
Select Case _ViewerMode
|
||||
Case ViewerMode.GDPicture
|
||||
FitToPage()
|
||||
_Config.Config.PageFit = Config.PageFitSetting.FitPage
|
||||
_Config.Save()
|
||||
Case ViewerMode.Richtext
|
||||
RichEditControl1.ActiveView.ZoomFactor = 1.0F
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub btnOpen_Click(sender As Object, e As EventArgs)
|
||||
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
|
||||
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
|
||||
FitToWidth()
|
||||
MyGDPViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
|
||||
|
||||
If OpenFileDialog.ShowDialog() = DialogResult.OK Then
|
||||
GdViewer.DisplayFromFile(OpenFileDialog.FileName)
|
||||
MyGDPViewer.DisplayFromFile(OpenFileDialog.FileName)
|
||||
End If
|
||||
|
||||
GdViewer.Focus()
|
||||
ShowGdViewer()
|
||||
MyGDPViewer.Focus()
|
||||
UpdateMainUi()
|
||||
End Sub
|
||||
Private Sub BtnFirstPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonFirstPage.ItemClick
|
||||
GdViewer.DisplayFirstPage()
|
||||
MyGDPViewer.DisplayFirstPage()
|
||||
End Sub
|
||||
|
||||
Private Sub BtnPreviousPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonPrevPage.ItemClick
|
||||
GdViewer.DisplayPreviousPage()
|
||||
MyGDPViewer.DisplayPreviousPage()
|
||||
End Sub
|
||||
|
||||
Private Sub BtnNextPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonNextPage.ItemClick
|
||||
GdViewer.DisplayNextPage()
|
||||
MyGDPViewer.DisplayNextPage()
|
||||
End Sub
|
||||
|
||||
Private Sub BtnLastPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonLastPage.ItemClick
|
||||
GdViewer.DisplayLastPage()
|
||||
MyGDPViewer.DisplayLastPage()
|
||||
End Sub
|
||||
|
||||
Private Sub TbCurrentPage_Leave(ByVal sender As System.Object, ByVal e As EventArgs) Handles txtCurrentPage.EditValueChanged
|
||||
Dim page As Integer = 0
|
||||
If Integer.TryParse(txtCurrentPage.EditValue, page) Then
|
||||
If page > 0 And page <= GdViewer.PageCount Then
|
||||
GdViewer.DisplayPage(page)
|
||||
If page > 0 And page <= MyGDPViewer.PageCount Then
|
||||
MyGDPViewer.DisplayPage(page)
|
||||
UpdateaNavigationToolbar()
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub GdViewer1_PageChanged() Handles GdViewer.PageChanged
|
||||
Private Sub GdViewer1_PageChanged() Handles MyGDPViewer.PageChanged
|
||||
UpdateaNavigationToolbar()
|
||||
End Sub
|
||||
|
||||
Private Sub GdViewer1_AfterZoomChange() Handles GdViewer.AfterZoomChange
|
||||
Private Sub GdViewer1_AfterZoomChange() Handles MyGDPViewer.AfterZoomChange
|
||||
UpdateaNavigationToolbar()
|
||||
If GdViewer.MouseMode = ViewerMouseMode.MouseModeAreaZooming Then
|
||||
GdViewer.MouseMode = ViewerMouseMode.MouseModePan
|
||||
If MyGDPViewer.MouseMode = ViewerMouseMode.MouseModeAreaZooming Then
|
||||
MyGDPViewer.MouseMode = ViewerMouseMode.MouseModePan
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub btnZoomOut_Click(sender As Object, e As EventArgs) Handles buttonZoomOut.ItemClick
|
||||
GdViewer.ZoomOUT()
|
||||
Select Case _ViewerMode
|
||||
Case ViewerMode.GDPicture
|
||||
MyGDPViewer.ZoomOUT()
|
||||
Case ViewerMode.Richtext
|
||||
Dim oView As DevExpress.XtraRichEdit.RichEditView = RichEditControl1.ActiveView
|
||||
oView.ZoomFactor = Math.Max(0.1F, oView.ZoomFactor - 0.1F)
|
||||
RichEditControl1.Refresh()
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub btnZoomIn_Click(sender As Object, e As EventArgs) Handles buttonZoomIn.ItemClick
|
||||
GdViewer.ZoomIN()
|
||||
Select Case _ViewerMode
|
||||
Case ViewerMode.GDPicture
|
||||
MyGDPViewer.ZoomIN()
|
||||
Case ViewerMode.Richtext
|
||||
Dim oView As DevExpress.XtraRichEdit.RichEditView = RichEditControl1.ActiveView
|
||||
oView.ZoomFactor = Math.Min(4.0F, oView.ZoomFactor + 0.1F)
|
||||
RichEditControl1.Refresh()
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles buttonPrint.ItemClick
|
||||
If GdViewer.PageCount = 0 Then
|
||||
Return
|
||||
End If
|
||||
|
||||
GdViewer.PrintDialog()
|
||||
Select Case _ViewerMode
|
||||
Case ViewerMode.GDPicture
|
||||
If MyGDPViewer.PageCount = 0 Then Return
|
||||
MyGDPViewer.PrintDialog()
|
||||
Case ViewerMode.Richtext
|
||||
Using oPrintDialog As New PrintDialog()
|
||||
If oPrintDialog.ShowDialog(Me) = DialogResult.OK Then
|
||||
RichEditControl1.Print()
|
||||
End If
|
||||
End Using
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub BtnRotateLeft_Click(sender As Object, e As EventArgs) Handles buttonRotateLeft.ItemClick
|
||||
GdViewer.Rotate(RotateFlipType.Rotate270FlipNone)
|
||||
MyGDPViewer.Rotate(RotateFlipType.Rotate270FlipNone)
|
||||
End Sub
|
||||
|
||||
Private Sub BtnRotateRight_Click(sender As Object, e As EventArgs) Handles buttonRotateRight.ItemClick
|
||||
GdViewer.Rotate(RotateFlipType.Rotate90FlipNone)
|
||||
MyGDPViewer.Rotate(RotateFlipType.Rotate90FlipNone)
|
||||
End Sub
|
||||
|
||||
Private Sub btnFlipX_Click(sender As Object, e As EventArgs) Handles buttonFlipX.ItemClick
|
||||
GdViewer.Rotate(RotateFlipType.RotateNoneFlipX)
|
||||
MyGDPViewer.Rotate(RotateFlipType.RotateNoneFlipX)
|
||||
End Sub
|
||||
|
||||
Private Sub btnFlipY_Click(sender As Object, e As EventArgs) Handles buttonFlipY.ItemClick
|
||||
GdViewer.Rotate(RotateFlipType.RotateNoneFlipY)
|
||||
MyGDPViewer.Rotate(RotateFlipType.RotateNoneFlipY)
|
||||
End Sub
|
||||
|
||||
Private Sub GdViewer1_TransferEnded(ByVal status As GdPictureStatus, ByVal download As System.Boolean) Handles GdViewer.TransferEnded
|
||||
GdViewer.Focus()
|
||||
Private Sub GdViewer1_TransferEnded(ByVal status As GdPictureStatus, ByVal download As System.Boolean) Handles MyGDPViewer.TransferEnded
|
||||
MyGDPViewer.Focus()
|
||||
UpdateMainUi()
|
||||
End Sub
|
||||
|
||||
Private Sub AddSearchRegion(ByVal occurence As Integer, ByVal leftCoordinate As Single, ByVal topCoordinate As Single, ByVal regionWidth As Single, ByVal regionheight As Single, ByVal ensureVisibility As Boolean)
|
||||
Dim searchRegion As Integer = GdViewer.AddRegionInches("SearchResult" & occurence, leftCoordinate, topCoordinate, regionWidth, regionheight, ForegroundMixMode.ForegroundMixModeMASKPEN, Color.Yellow)
|
||||
GdViewer.SetRegionEditable(searchRegion, False)
|
||||
Dim searchRegion As Integer = MyGDPViewer.AddRegionInches("SearchResult" & occurence, leftCoordinate, topCoordinate, regionWidth, regionheight, ForegroundMixMode.ForegroundMixModeMASKPEN, Color.Yellow)
|
||||
MyGDPViewer.SetRegionEditable(searchRegion, False)
|
||||
If ensureVisibility Then
|
||||
GdViewer.EnsureRegionVisibility(searchRegion)
|
||||
MyGDPViewer.EnsureRegionVisibility(searchRegion)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub BtnSettings_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonSettings.ItemClick
|
||||
Using frmSettings As New frmViewerSettings(GdViewer)
|
||||
Using frmSettings As New frmViewerSettings(MyGDPViewer)
|
||||
frmSettings.ShowDialog(Me)
|
||||
End Using
|
||||
UpdateaNavigationToolbar()
|
||||
@@ -420,9 +485,9 @@ Public Class DocumentViewer
|
||||
|
||||
Private Sub UpdateaNavigationToolbar()
|
||||
Try
|
||||
Dim oCurrentZoom As Double = GdViewer.Zoom
|
||||
Dim oCurrentPage As Integer = GdViewer.CurrentPage
|
||||
Dim oPageCount As Integer = GdViewer.PageCount
|
||||
Dim oCurrentZoom As Double = MyGDPViewer.Zoom
|
||||
Dim oCurrentPage As Integer = MyGDPViewer.CurrentPage
|
||||
Dim oPageCount As Integer = MyGDPViewer.PageCount
|
||||
txtCurrentPage.EditValue = oCurrentPage
|
||||
labelPageCount.Caption = $"/ {oPageCount}"
|
||||
|
||||
@@ -463,13 +528,14 @@ Public Class DocumentViewer
|
||||
_ViewerMode = ViewerMode.Richtext
|
||||
Else
|
||||
Select Case Extension.ToUpper
|
||||
Case "CSV"
|
||||
Case ".CSV"
|
||||
_ViewerMode = ViewerMode.Excel
|
||||
'Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
|
||||
' _ViewerMode = ViewerMode.RichText
|
||||
Case ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
|
||||
_ViewerMode = ViewerMode.Richtext
|
||||
Case Else
|
||||
_ViewerMode = ViewerMode.GDPicture
|
||||
End Select
|
||||
_logger.Debug("Viewermode set to [{0}] based on extension [{1}]", _ViewerMode, Extension)
|
||||
End If
|
||||
End Sub
|
||||
Private Sub FreeFile()
|
||||
@@ -484,112 +550,167 @@ Public Class DocumentViewer
|
||||
SpreadsheetControl1.CreateNewDocument()
|
||||
Case Else
|
||||
_logger.Debug("Closing GDPicture Viewer")
|
||||
GdViewer.CloseDocument()
|
||||
MyGDPViewer.CloseDocument()
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
_logger.Warn($"Unexpected error in FreeFile: {ex.Message}")
|
||||
End Try
|
||||
End Sub
|
||||
'Private Function DoLoadFile(FilePath As String, Optional ViewOverride As String = "") As Boolean
|
||||
' Try
|
||||
' lblInfo.Visible = False
|
||||
' Dim oFileInfo = New FileInfo(FilePath)
|
||||
' Dim oExtension As String = oFileInfo.Extension.ToUpper
|
||||
|
||||
' lbFileNotLoaded.Visible = False
|
||||
|
||||
' SpreadsheetControl1.Visible = False
|
||||
' RichEditControl1.Visible = False
|
||||
|
||||
' SpreadsheetControl1.Dock = DockStyle.None
|
||||
' RichEditControl1.Dock = DockStyle.None
|
||||
|
||||
' Dim override_Spreadsheet As Boolean = False
|
||||
' If oExtension.ToLower = ".xlsx" Then
|
||||
' If oFileInfo.Length > 15000 Then
|
||||
' _logger.Info("Override")
|
||||
' override_Spreadsheet = True
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' If ViewOverride = "Richtext" Then
|
||||
' RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(oExtension))
|
||||
' RichEditControl1.Visible = True
|
||||
' GdViewer.Visible = False
|
||||
' RichEditControl1.Dock = DockStyle.Fill
|
||||
' _ViewOverride = "Richtext"
|
||||
' _ViewerMode = ViewerMode.Richtext
|
||||
' lblInfo.Visible = True
|
||||
' lblInfo.Text = "This docx-file contains a generic error and will be displayed in a reduced viewer. Please try to open the file in WORD"
|
||||
' ElseIf override_Spreadsheet = True Then
|
||||
' Dim oFormat = GetSpreadsheetFormat(oExtension)
|
||||
' SpreadsheetControl1.LoadDocument(FilePath, oFormat)
|
||||
|
||||
' Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
|
||||
' oRange.AutoFitColumns()
|
||||
|
||||
' SpreadsheetControl1.Visible = True
|
||||
' GdViewer.Visible = False
|
||||
' SpreadsheetControl1.Dock = DockStyle.Fill
|
||||
' Else
|
||||
' _ViewOverride = ""
|
||||
' Select Case oExtension.ToUpper
|
||||
' Case ".CSV"
|
||||
' Dim oFormat = GetSpreadsheetFormat(oExtension)
|
||||
' SpreadsheetControl1.LoadDocument(FilePath, oFormat)
|
||||
|
||||
' Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
|
||||
' oRange.AutoFitColumns()
|
||||
|
||||
' SpreadsheetControl1.Visible = True
|
||||
' GdViewer.Visible = False
|
||||
' SpreadsheetControl1.Dock = DockStyle.Fill
|
||||
|
||||
' 'Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
|
||||
' ' RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(oExtension))
|
||||
|
||||
' ' RichEditControl1.Visible = True
|
||||
' ' GdViewer.Visible = False
|
||||
' ' RichEditControl1.Dock = DockStyle.Fill
|
||||
' Case Else
|
||||
' Select Case oExtension.ToUpper
|
||||
' Case ".EML", ".DOC", ".DOCX", ".XLS", ".XLSX", ".ODT", ".RTF", ".TXT"
|
||||
' GdViewer.ForceTemporaryMode = False
|
||||
' End Select
|
||||
|
||||
' GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
|
||||
' GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
|
||||
' If Viewer_ForceTemporaryMode = True Then
|
||||
' GdViewer.ForceTemporaryMode = True
|
||||
' End If
|
||||
|
||||
' GdViewer.AnnotationDropShadow = True
|
||||
' GdViewer.BackColor = Color.White
|
||||
|
||||
' Dim oGDPState As GdPicture14.GdPictureStatus = GdViewer.DisplayFromFile(FilePath)
|
||||
' If oGDPState <> GdPictureStatus.OK Then
|
||||
' _logger.Warn($"GdPictureStatus is [{oGDPState}]")
|
||||
' If oExtension.ToUpper = ".DOCX" And oGDPState = GdPictureStatus.GenericError Then
|
||||
' DoLoadFile(FilePath, "Richtext")
|
||||
' Else
|
||||
' Dim oFileName = IO.Path.GetFileName(FilePath)
|
||||
' lbFileNotLoaded.Text = String.Format("Datei konnte nicht geladen werden:{0}{1}", vbCrLf, oFileName)
|
||||
' lbFileNotLoaded.Visible = True
|
||||
' End If
|
||||
|
||||
' Else
|
||||
' If GdViewer.Visible = False Then
|
||||
' GdViewer.Visible = True
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' End Select
|
||||
' End If
|
||||
' If _ViewOverride = "Richtext" Then
|
||||
' _ViewerMode = ViewerMode.Richtext
|
||||
' End If
|
||||
|
||||
|
||||
' Return True
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Return False
|
||||
' End Try
|
||||
'End Function
|
||||
Private Function DoLoadFile(FilePath As String, Optional ViewOverride As String = "") As Boolean
|
||||
Try
|
||||
lblInfo.Visible = False
|
||||
If Not EnsureViewerReady() Then
|
||||
_logger?.Warn("GdViewer control is not initialized yet. Delaying load.")
|
||||
Return False
|
||||
End If
|
||||
_logger.Debug("Starting DoLoadFile with path [{0}] and view override [{1}]", FilePath, ViewOverride)
|
||||
Dim oFileInfo = New FileInfo(FilePath)
|
||||
Dim oExtension As String = oFileInfo.Extension.ToUpper
|
||||
Dim oExtension = oFileInfo.Extension.ToUpper
|
||||
|
||||
' Reset UI state
|
||||
HideAllViewers()
|
||||
lbFileNotLoaded.Visible = False
|
||||
lblInfo.Visible = False
|
||||
|
||||
SpreadsheetControl1.Visible = False
|
||||
RichEditControl1.Visible = False
|
||||
|
||||
SpreadsheetControl1.Dock = DockStyle.None
|
||||
RichEditControl1.Dock = DockStyle.None
|
||||
|
||||
Dim override_Spreadsheet As Boolean = False
|
||||
If oExtension.ToLower = ".xlsx" Then
|
||||
If oFileInfo.Length > 15000 Then
|
||||
_logger.Info("Override")
|
||||
override_Spreadsheet = True
|
||||
End If
|
||||
End If
|
||||
|
||||
If ViewOverride = "Richtext" Then
|
||||
RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(oExtension))
|
||||
RichEditControl1.Visible = True
|
||||
GdViewer.Visible = False
|
||||
RichEditControl1.Dock = DockStyle.Fill
|
||||
_ViewOverride = "Richtext"
|
||||
_ViewerMode = ViewerMode.Richtext
|
||||
lblInfo.Visible = True
|
||||
lblInfo.Text = "This docx-file contains a generic error and will be displayed in a reduced viewer. Please try to open the file in WORD"
|
||||
ElseIf override_Spreadsheet = True Then
|
||||
Dim oFormat = GetSpreadsheetFormat(oExtension)
|
||||
SpreadsheetControl1.LoadDocument(FilePath, oFormat)
|
||||
|
||||
Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
|
||||
oRange.AutoFitColumns()
|
||||
|
||||
SpreadsheetControl1.Visible = True
|
||||
GdViewer.Visible = False
|
||||
SpreadsheetControl1.Dock = DockStyle.Fill
|
||||
' Determine viewer mode and load file
|
||||
If ViewOverride = "Richtext" OrElse _ViewerMode = ViewerMode.Richtext Then
|
||||
_logger.Info("Loading Richtext file: {0}", FilePath)
|
||||
Return LoadRichtextFile(FilePath, oExtension)
|
||||
ElseIf _ViewerMode = ViewerMode.Excel OrElse oExtension = ".CSV" OrElse (oExtension = ".XLSX" AndAlso oFileInfo.Length > 15000) Then
|
||||
_logger.Debug("Loading Spreadsheet file: {0}", FilePath)
|
||||
Return LoadSpreadsheetFile(FilePath, oExtension)
|
||||
Else
|
||||
_ViewOverride = ""
|
||||
Select Case oExtension.ToUpper
|
||||
Case ".CSV"
|
||||
Dim oFormat = GetSpreadsheetFormat(oExtension)
|
||||
SpreadsheetControl1.LoadDocument(FilePath, oFormat)
|
||||
|
||||
Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
|
||||
oRange.AutoFitColumns()
|
||||
|
||||
SpreadsheetControl1.Visible = True
|
||||
GdViewer.Visible = False
|
||||
SpreadsheetControl1.Dock = DockStyle.Fill
|
||||
|
||||
'Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT"
|
||||
' RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(oExtension))
|
||||
|
||||
' RichEditControl1.Visible = True
|
||||
' GdViewer.Visible = False
|
||||
' RichEditControl1.Dock = DockStyle.Fill
|
||||
Case Else
|
||||
Select Case oExtension.ToUpper
|
||||
Case ".EML", ".DOC", ".DOCX", ".XLS", ".XLSX", ".ODT", ".RTF", ".TXT"
|
||||
GdViewer.ForceTemporaryMode = False
|
||||
End Select
|
||||
|
||||
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
|
||||
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
|
||||
If Viewer_ForceTemporaryMode = True Then
|
||||
GdViewer.ForceTemporaryMode = True
|
||||
End If
|
||||
|
||||
GdViewer.AnnotationDropShadow = True
|
||||
GdViewer.BackColor = Color.White
|
||||
|
||||
Dim oGDPState As GdPicture14.GdPictureStatus = GdViewer.DisplayFromFile(FilePath)
|
||||
If oGDPState <> GdPictureStatus.OK Then
|
||||
_logger.Warn($"GdPictureStatus is [{oGDPState}]")
|
||||
If oExtension.ToUpper = ".DOCX" And oGDPState = GdPictureStatus.GenericError Then
|
||||
DoLoadFile(FilePath, "Richtext")
|
||||
Else
|
||||
Dim oFileName = IO.Path.GetFileName(FilePath)
|
||||
lbFileNotLoaded.Text = String.Format("Datei konnte nicht geladen werden:{0}{1}", vbCrLf, oFileName)
|
||||
lbFileNotLoaded.Visible = True
|
||||
End If
|
||||
|
||||
Else
|
||||
If GdViewer.Visible = False Then
|
||||
GdViewer.Visible = True
|
||||
End If
|
||||
End If
|
||||
|
||||
End Select
|
||||
End If
|
||||
If _ViewOverride = "Richtext" Then
|
||||
_ViewerMode = ViewerMode.Richtext
|
||||
Return LoadGdPictureFile(FilePath, oExtension)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub HideAllViewers()
|
||||
SpreadsheetControl1.Visible = False
|
||||
SpreadsheetControl1.Dock = DockStyle.None
|
||||
RichEditControl1.Visible = False
|
||||
RichEditControl1.Dock = DockStyle.None
|
||||
HideGdViewer()
|
||||
End Sub
|
||||
|
||||
Private Function LoadRichtextFile(FilePath As String, Extension As String) As Boolean
|
||||
Try
|
||||
RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(Extension))
|
||||
RichEditControl1.Visible = True
|
||||
RichEditControl1.Dock = DockStyle.Fill
|
||||
_ViewOverride = "Richtext"
|
||||
_ViewerMode = ViewerMode.Richtext
|
||||
lblInfo.Visible = True
|
||||
lblInfo.Text = "This docx-file contains a generic error and will be displayed in a reduced viewer. Please try to open the file in WORD"
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
@@ -597,27 +718,96 @@ Public Class DocumentViewer
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function LoadSpreadsheetFile(FilePath As String, Extension As String) As Boolean
|
||||
Try
|
||||
_logger.Debug("Loading Spreadsheet: {0}", FilePath)
|
||||
Dim oFormat = GetSpreadsheetFormat(Extension)
|
||||
SpreadsheetControl1.LoadDocument(FilePath, oFormat)
|
||||
|
||||
Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
|
||||
oRange.AutoFitColumns()
|
||||
|
||||
SpreadsheetControl1.Visible = True
|
||||
SpreadsheetControl1.Dock = DockStyle.Fill
|
||||
_ViewerMode = ViewerMode.Excel
|
||||
_ViewOverride = ""
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function LoadGdPictureFile(FilePath As String, Extension As String) As Boolean
|
||||
Try
|
||||
_logger.Debug("Loading GdPicture: {0}", FilePath)
|
||||
|
||||
' Set force temporary mode for specific file types
|
||||
Select Case Extension
|
||||
Case ".EML", ".DOC", ".DOCX", ".XLS", ".XLSX", ".ODT", ".RTF", ".TXT"
|
||||
MyGDPViewer.ForceTemporaryMode = True
|
||||
_logger.Info("ForceTemporaryMode enabled for extension [{0}]", Extension)
|
||||
End Select
|
||||
|
||||
MyGDPViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
|
||||
If Viewer_ForceTemporaryMode Then
|
||||
MyGDPViewer.ForceTemporaryMode = True
|
||||
End If
|
||||
MyGDPViewer.AnnotationDropShadow = True
|
||||
|
||||
Dim oGDPState = MyGDPViewer.DisplayFromFile(FilePath)
|
||||
|
||||
If oGDPState <> GdPictureStatus.OK Then
|
||||
_logger.Warn("GdPictureStatus: {0}", oGDPState)
|
||||
|
||||
' Fallback to Richtext for corrupted DOCX
|
||||
If Extension = ".DOCX" AndAlso oGDPState = GdPictureStatus.GenericError Then
|
||||
HideGdViewer()
|
||||
Return LoadRichtextFile(FilePath, Extension)
|
||||
Else
|
||||
ShowFileNotLoadedError(FilePath)
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
|
||||
ShowGdViewer()
|
||||
_ViewerMode = ViewerMode.GDPicture
|
||||
_ViewOverride = ""
|
||||
Return True
|
||||
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
ShowFileNotLoadedError(FilePath)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub ShowFileNotLoadedError(FilePath As String)
|
||||
Dim oFileName = IO.Path.GetFileName(FilePath)
|
||||
lbFileNotLoaded.Text = String.Format("Datei konnte nicht geladen werden:{0}{1}", vbCrLf, oFileName)
|
||||
lbFileNotLoaded.Visible = True
|
||||
HideGdViewer()
|
||||
End Sub
|
||||
' Ensures the embedded GdViewer control exists and is added to the visual tree
|
||||
Private Function EnsureViewerReady() As Boolean
|
||||
Try
|
||||
' If the control field is Nothing (e.g., designer not yet created), try to lazy-create and add it
|
||||
If GdViewer Is Nothing Then
|
||||
If MyGDPViewer Is Nothing Then
|
||||
' Attempt to find an existing instance by name in Controls collection
|
||||
Dim existing = Me.Controls.OfType(Of GdPicture14.GdViewer)().FirstOrDefault()
|
||||
If existing IsNot Nothing Then
|
||||
' Assign the designer field via reflection if needed, otherwise use it directly
|
||||
GdViewer = existing
|
||||
MyGDPViewer = existing
|
||||
Else
|
||||
' Last resort: create a new viewer and add it
|
||||
Dim viewer = New GdPicture14.GdViewer()
|
||||
viewer.Dock = DockStyle.Fill
|
||||
Me.Controls.Add(viewer)
|
||||
GdViewer = viewer
|
||||
MyGDPViewer = viewer
|
||||
End If
|
||||
End If
|
||||
|
||||
Return GdViewer IsNot Nothing
|
||||
Return MyGDPViewer IsNot Nothing
|
||||
Catch ex As Exception
|
||||
_logger?.Error(ex)
|
||||
Return False
|
||||
@@ -625,19 +815,35 @@ Public Class DocumentViewer
|
||||
End Function
|
||||
|
||||
Private Sub FitToPage()
|
||||
If Not GdViewer Is Nothing Then
|
||||
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeFitToViewer
|
||||
If Not MyGDPViewer Is Nothing Then
|
||||
MyGDPViewer.ZoomMode = ViewerZoomMode.ZoomModeFitToViewer
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub FitToWidth()
|
||||
If Not GdViewer Is Nothing Then
|
||||
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
|
||||
If Not MyGDPViewer Is Nothing Then
|
||||
MyGDPViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function DoLoadFile(Stream As Stream, Extension As String) As Boolean
|
||||
Private Sub ShowGdViewer()
|
||||
If MyGDPViewer IsNot Nothing Then
|
||||
MyGDPViewer.Dock = DockStyle.Fill
|
||||
MyGDPViewer.Visible = True
|
||||
MyGDPViewer.MouseWheelMode = ViewerMouseWheelMode.MouseWheelModeVerticalScroll
|
||||
FitToWidth()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub HideGdViewer()
|
||||
If MyGDPViewer IsNot Nothing Then
|
||||
MyGDPViewer.Visible = False
|
||||
MyGDPViewer.Dock = DockStyle.None
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function DoLoadFileExtension(Stream As Stream, Extension As String) As Boolean
|
||||
|
||||
Try
|
||||
|
||||
@@ -648,30 +854,21 @@ Public Class DocumentViewer
|
||||
|
||||
Case ".CSV"
|
||||
SpreadsheetControl1.LoadDocument(Stream, GetSpreadsheetFormat(Extension))
|
||||
|
||||
Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange()
|
||||
oRange.AutoFitColumns()
|
||||
|
||||
SpreadsheetControl1.Visible = True
|
||||
SpreadsheetControl1.Dock = DockStyle.Fill
|
||||
|
||||
Case Else
|
||||
If Not GdViewer Is Nothing Then
|
||||
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
|
||||
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
|
||||
If Not MyGDPViewer Is Nothing Then
|
||||
MyGDPViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
|
||||
If Viewer_ForceTemporaryMode = True Then
|
||||
GdViewer.ForceTemporaryMode = True
|
||||
MyGDPViewer.ForceTemporaryMode = True
|
||||
End If
|
||||
GdViewer.AnnotationDropShadow = True
|
||||
|
||||
GdViewer.DisplayFromStream(Stream)
|
||||
MyGDPViewer.AnnotationDropShadow = True
|
||||
MyGDPViewer.DisplayFromStream(Stream)
|
||||
ShowGdViewer()
|
||||
End If
|
||||
|
||||
|
||||
End Select
|
||||
|
||||
UpdateMainUi()
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
@@ -696,13 +893,12 @@ Public Class DocumentViewer
|
||||
SpreadsheetControl1.Dock = DockStyle.Fill
|
||||
|
||||
Case Else
|
||||
GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer
|
||||
GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
|
||||
GdViewer.ForceTemporaryMode = True
|
||||
GdViewer.AnnotationDropShadow = True
|
||||
|
||||
GdViewer.DisplayFromStream(Stream)
|
||||
MyGDPViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter
|
||||
MyGDPViewer.ForceTemporaryMode = True
|
||||
MyGDPViewer.AnnotationDropShadow = True
|
||||
|
||||
MyGDPViewer.DisplayFromStream(Stream)
|
||||
ShowGdViewer()
|
||||
End Select
|
||||
|
||||
UpdateMainUi()
|
||||
@@ -750,6 +946,9 @@ Public Class DocumentViewer
|
||||
End Function
|
||||
|
||||
Private Sub UpdateMainUi()
|
||||
If Not IsNothing(_logger) Then
|
||||
_logger.Info("Updating main UI for viewer mode [{0}]", _ViewerMode)
|
||||
End If
|
||||
|
||||
Select Case _Config?.Config?.PageFit
|
||||
Case Config.PageFitSetting.FitPage
|
||||
@@ -811,7 +1010,28 @@ Public Class DocumentViewer
|
||||
btnNextHighlight.Visibility = ToVisibility(False)
|
||||
btnPrevHighlight.Visibility = ToVisibility(False)
|
||||
Case Else
|
||||
ToolbarDocumentViewer.Visible = False
|
||||
ToolbarDocumentViewer.Visible = True
|
||||
|
||||
buttonPrint.Visibility = XtraBars.BarItemVisibility.Always
|
||||
buttonFitWidth.Visibility = XtraBars.BarItemVisibility.Always
|
||||
buttonFitPage.Visibility = XtraBars.BarItemVisibility.Always
|
||||
buttonZoomIn.Visibility = XtraBars.BarItemVisibility.Always
|
||||
buttonZoomOut.Visibility = XtraBars.BarItemVisibility.Always
|
||||
buttonRotateLeft.Visibility = XtraBars.BarItemVisibility.Never
|
||||
buttonRotateRight.Visibility = XtraBars.BarItemVisibility.Never
|
||||
buttonFlipX.Visibility = XtraBars.BarItemVisibility.Never
|
||||
buttonFlipY.Visibility = XtraBars.BarItemVisibility.Never
|
||||
buttonSettings.Visibility = XtraBars.BarItemVisibility.Never
|
||||
txtSearch.Visibility = XtraBars.BarItemVisibility.Never
|
||||
btnSearch2.Visibility = XtraBars.BarItemVisibility.Never
|
||||
btnNextHighlight.Visibility = XtraBars.BarItemVisibility.Never
|
||||
btnPrevHighlight.Visibility = XtraBars.BarItemVisibility.Never
|
||||
buttonFirstPage.Visibility = XtraBars.BarItemVisibility.Never
|
||||
buttonPrevPage.Visibility = XtraBars.BarItemVisibility.Never
|
||||
buttonNextPage.Visibility = XtraBars.BarItemVisibility.Never
|
||||
buttonLastPage.Visibility = XtraBars.BarItemVisibility.Never
|
||||
txtCurrentPage.Visibility = XtraBars.BarItemVisibility.Never
|
||||
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
|
||||
Reference in New Issue
Block a user