GUIs.Common: Add Legacy File Properties to context menu

This commit is contained in:
Jonathan Jenne 2020-12-15 13:22:42 +01:00
parent a5075cc7f4
commit acbd5c82be
4 changed files with 81 additions and 25 deletions

View File

@ -194,6 +194,10 @@
<Project>{81cac44f-3711-4c8f-ae98-e02a7448782a}</Project> <Project>{81cac44f-3711-4c8f-ae98-e02a7448782a}</Project>
<Name>ZooFlow</Name> <Name>ZooFlow</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\Windows\Windows.vbproj">
<Project>{5EFAEF9B-90B9-4F05-9F70-F79AD77FFF86}</Project>
<Name>Windows</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />

View File

@ -2,7 +2,5 @@
Public Const NO_ROW_HANDLE = -1 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_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} 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."
Please check the SQL Queries for errors and if the correct connection was configured.{vbNewLine}{vbNewLine}
For more information check the Logfile."
End Class End Class

View File

@ -1,29 +1,61 @@
Imports System.Windows.Forms Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports DevExpress.Utils.Menu Imports DevExpress.Utils.Menu
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Windows.NativeMethods
Imports DigitalData.Modules.Windows.File
Imports DigitalData.Modules.ZooFlow Imports DigitalData.Modules.ZooFlow
Public Class DocumentPropertyMenu Public Class DocumentPropertyMenu
Private ReadOnly _Logger As Logger Private ReadOnly _Logger As Logger
Private ReadOnly _LogConfig As LogConfig Private ReadOnly _LogConfig As LogConfig
Private ReadOnly _Environment As Environment Private ReadOnly _Environment As Environment
Private ReadOnly _File As Modules.Windows.File
Private ReadOnly _FilePath As String Private ReadOnly _FilePath As String
Private ReadOnly _ObjectId As Long 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) Public Sub New(LogConfig As LogConfig, Environment As Environment, FilePath As String, Optional ObjectId As Long = 0)
_LogConfig = LogConfig _LogConfig = LogConfig
_Logger = LogConfig.GetLogger() _Logger = LogConfig.GetLogger()
_Environment = Environment _Environment = Environment
_FilePath = FilePath _FilePath = FilePath
_ObjectId = ObjectId _ObjectId = ObjectId
_File = New Modules.Windows.File(LogConfig)
End Sub End Sub
Public Function GetMenuItems() As List(Of DXMenuItem) Public Function GetMenuItems(IsLegacy As Boolean) As List(Of DXMenuItem)
Dim oOpenFile = New DXMenuItem("Datei öffnen", AddressOf OpenFile_Click) If IsLegacy Then
Dim oOpenFolder = New DXMenuItem("Ordner öffnen", AddressOf OpenFolder_Click) Return GetLegacyMenuItems()
Dim oCopyPath = New DXMenuItem("Pfad kopieren", AddressOf CopyPath_Click) Else
Dim oProperties = New DXMenuItem("Eigenschaften", AddressOf Properties_Click) 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 { Return New List(Of DXMenuItem) From {
oOpenFile, oOpenFile,
@ -34,7 +66,7 @@ Public Class DocumentPropertyMenu
End Function End Function
Public Sub Properties_Click(sender As Object, e As EventArgs) Public Sub Properties_Click(sender As Object, e As EventArgs)
If _ObjectId = 0 Then If TestObjectIdExists(OPEN_PROPERTIES) Then
Exit Sub Exit Sub
End If End If
@ -42,28 +74,50 @@ Public Class DocumentPropertyMenu
oPropertyDialog.Show() oPropertyDialog.Show()
End Sub End Sub
Public Sub CopyPath_Click(sender As Object, e As EventArgs) Public Sub Properties_Click_Legacy(sender As Object, e As EventArgs)
If IO.File.Exists(_FilePath) Then If TestPathExists(OPEN_PROPERTIES) = False Then
Clipboard.SetText(_FilePath) Exit Sub
Else
MessageBox.Show($"Datei {_FilePath} existiert nicht oder wurde verschoben!", "Dateipfad kopieren", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If End If
_File.OpenFileProperties(_FilePath)
End Sub
Public Sub CopyPath_Click(sender As Object, e As EventArgs)
Clipboard.SetText(_FilePath)
End Sub End Sub
Public Sub OpenFile_Click(sender As Object, e As EventArgs) Public Sub OpenFile_Click(sender As Object, e As EventArgs)
If IO.File.Exists(_FilePath) Then If TestPathExists(OPEN_FILE) = False Then
Process.Start(_FilePath) Exit Sub
Else
MessageBox.Show($"Datei {_FilePath} existiert nicht oder wurde verschoben!", "Datei öffnen", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If End If
Process.Start(_FilePath)
End Sub End Sub
Public Sub OpenFolder_Click(sender As Object, e As EventArgs) Public Sub OpenFolder_Click(sender As Object, e As EventArgs)
If IO.File.Exists(_FilePath) Then If TestPathExists(OPEN_DIRECTORY) = False Then
Dim oDirectory = IO.Path.GetDirectoryName(_FilePath) Exit Sub
Process.Start(oDirectory)
Else
MessageBox.Show($"Datei {_FilePath} existiert nicht oder wurde verschoben!", "Ordner öffnen", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If End If
Dim oDirectory = IO.Path.GetDirectoryName(_FilePath)
Process.Start(oDirectory)
End Sub 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 End Class

View File

@ -598,7 +598,7 @@ Public Class frmDocumentResultList
e.Menu.Items.Clear() e.Menu.Items.Clear()
For Each oItem In oMenu.GetMenuItems() For Each oItem In oMenu.GetMenuItems(_IsLegacy)
e.Menu.Items.Add(oItem) e.Menu.Items.Add(oItem)
Next Next
End If End If