diff --git a/GUIs.Common/Common.vbproj b/GUIs.Common/Common.vbproj index d805878c..b3864e58 100644 --- a/GUIs.Common/Common.vbproj +++ b/GUIs.Common/Common.vbproj @@ -194,6 +194,10 @@ {81cac44f-3711-4c8f-ae98-e02a7448782a} ZooFlow + + {5EFAEF9B-90B9-4F05-9F70-F79AD77FFF86} + Windows + diff --git a/GUIs.Common/Constants.vb b/GUIs.Common/Constants.vb index ba999971..84b11578 100644 --- a/GUIs.Common/Constants.vb +++ b/GUIs.Common/Constants.vb @@ -2,7 +2,5 @@ Public Const NO_ROW_HANDLE = -1 Public Shared ReadOnly MESSAGE_TOO_MANY_SEARCHES = "You have more than three searches configured. This Window will only show the first three result lists!" - Public Shared ReadOnly MESSAGE_ERROR_IN_SEARCHES = $"An error occurred while executing searches or no searches were found!{vbNewLine} - Please check the SQL Queries for errors and if the correct connection was configured.{vbNewLine}{vbNewLine} - For more information check the Logfile." + Public Shared ReadOnly MESSAGE_ERROR_IN_SEARCHES = $"An error occurred while executing searches or no searches were found!{vbNewLine}Please check the SQL Queries for errors and if the correct connection was configured.{vbNewLine}{vbNewLine}For more information check the Logfile." End Class diff --git a/GUIs.Common/DocumentPropertyMenu/DocumentPropertyMenu.vb b/GUIs.Common/DocumentPropertyMenu/DocumentPropertyMenu.vb index 12faa925..0ae360ca 100644 --- a/GUIs.Common/DocumentPropertyMenu/DocumentPropertyMenu.vb +++ b/GUIs.Common/DocumentPropertyMenu/DocumentPropertyMenu.vb @@ -1,29 +1,61 @@ -Imports System.Windows.Forms +Imports System.Runtime.InteropServices +Imports System.Windows.Forms Imports DevExpress.Utils.Menu Imports DigitalData.Modules.Logging +Imports DigitalData.Modules.Windows.NativeMethods +Imports DigitalData.Modules.Windows.File Imports DigitalData.Modules.ZooFlow Public Class DocumentPropertyMenu Private ReadOnly _Logger As Logger Private ReadOnly _LogConfig As LogConfig Private ReadOnly _Environment As Environment + Private ReadOnly _File As Modules.Windows.File Private ReadOnly _FilePath As String Private ReadOnly _ObjectId As Long + Public Const OPEN_FILE As String = "Datei öffnen" + Public Const OPEN_DIRECTORY As String = "Ordner öffnen" + Public Const COPY_PATH As String = "Dateipfad kopieren" + Public Const OPEN_PROPERTIES As String = "Eigenschaften" + Public Sub New(LogConfig As LogConfig, Environment As Environment, FilePath As String, Optional ObjectId As Long = 0) _LogConfig = LogConfig _Logger = LogConfig.GetLogger() _Environment = Environment _FilePath = FilePath _ObjectId = ObjectId + _File = New Modules.Windows.File(LogConfig) End Sub - Public Function GetMenuItems() As List(Of DXMenuItem) - Dim oOpenFile = New DXMenuItem("Datei öffnen", AddressOf OpenFile_Click) - Dim oOpenFolder = New DXMenuItem("Ordner öffnen", AddressOf OpenFolder_Click) - Dim oCopyPath = New DXMenuItem("Pfad kopieren", AddressOf CopyPath_Click) - Dim oProperties = New DXMenuItem("Eigenschaften", AddressOf Properties_Click) + Public Function GetMenuItems(IsLegacy As Boolean) As List(Of DXMenuItem) + If IsLegacy Then + Return GetLegacyMenuItems() + Else + Return GetIDBMenuItems() + End If + End Function + + Public Function GetIDBMenuItems() As List(Of DXMenuItem) + Dim oOpenFile = New DXMenuItem(OPEN_FILE, AddressOf OpenFile_Click) + Dim oOpenFolder = New DXMenuItem(OPEN_DIRECTORY, AddressOf OpenFolder_Click) + Dim oCopyPath = New DXMenuItem(COPY_PATH, AddressOf CopyPath_Click) + Dim oProperties = New DXMenuItem(OPEN_PROPERTIES, AddressOf Properties_Click) + + Return New List(Of DXMenuItem) From { + oOpenFile, + oOpenFolder, + oCopyPath, + oProperties + } + End Function + + Public Function GetLegacyMenuItems() As List(Of DXMenuItem) + Dim oOpenFile = New DXMenuItem(OPEN_FILE, AddressOf OpenFile_Click) + Dim oOpenFolder = New DXMenuItem(OPEN_DIRECTORY, AddressOf OpenFolder_Click) + Dim oCopyPath = New DXMenuItem(COPY_PATH, AddressOf CopyPath_Click) + Dim oProperties = New DXMenuItem(OPEN_PROPERTIES, AddressOf Properties_Click_Legacy) Return New List(Of DXMenuItem) From { oOpenFile, @@ -34,7 +66,7 @@ Public Class DocumentPropertyMenu End Function Public Sub Properties_Click(sender As Object, e As EventArgs) - If _ObjectId = 0 Then + If TestObjectIdExists(OPEN_PROPERTIES) Then Exit Sub End If @@ -42,28 +74,50 @@ Public Class DocumentPropertyMenu oPropertyDialog.Show() End Sub - Public Sub CopyPath_Click(sender As Object, e As EventArgs) - If IO.File.Exists(_FilePath) Then - Clipboard.SetText(_FilePath) - Else - MessageBox.Show($"Datei {_FilePath} existiert nicht oder wurde verschoben!", "Dateipfad kopieren", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) + Public Sub Properties_Click_Legacy(sender As Object, e As EventArgs) + If TestPathExists(OPEN_PROPERTIES) = False Then + Exit Sub End If + + _File.OpenFileProperties(_FilePath) + End Sub + + Public Sub CopyPath_Click(sender As Object, e As EventArgs) + Clipboard.SetText(_FilePath) End Sub Public Sub OpenFile_Click(sender As Object, e As EventArgs) - If IO.File.Exists(_FilePath) Then - Process.Start(_FilePath) - Else - MessageBox.Show($"Datei {_FilePath} existiert nicht oder wurde verschoben!", "Datei öffnen", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) + If TestPathExists(OPEN_FILE) = False Then + Exit Sub End If + + Process.Start(_FilePath) End Sub Public Sub OpenFolder_Click(sender As Object, e As EventArgs) - If IO.File.Exists(_FilePath) Then - Dim oDirectory = IO.Path.GetDirectoryName(_FilePath) - Process.Start(oDirectory) - Else - MessageBox.Show($"Datei {_FilePath} existiert nicht oder wurde verschoben!", "Ordner öffnen", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) + If TestPathExists(OPEN_DIRECTORY) = False Then + Exit Sub End If + + Dim oDirectory = IO.Path.GetDirectoryName(_FilePath) + Process.Start(oDirectory) End Sub + + Private Function TestPathExists(Title As String) As Boolean + If IO.File.Exists(_FilePath) = False Then + MessageBox.Show($"Datei {_FilePath} existiert nicht oder wurde verschoben!", Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) + Return False + Else + Return True + End If + End Function + + Private Function TestObjectIdExists(Title As String) As Boolean + If _ObjectId = 0 Then + MessageBox.Show($"Objekt {_ObjectId} existiert nicht oder wurde verschoben!", Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) + Return False + Else + Return True + End If + End Function End Class diff --git a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb index 0590ab5e..8e8fce6a 100644 --- a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb +++ b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb @@ -598,7 +598,7 @@ Public Class frmDocumentResultList e.Menu.Items.Clear() - For Each oItem In oMenu.GetMenuItems() + For Each oItem In oMenu.GetMenuItems(_IsLegacy) e.Menu.Items.Add(oItem) Next End If