Common/DocumentResultList: Rewrite of Context menu
This commit is contained in:
@@ -3,9 +3,11 @@ Imports System.Drawing
|
||||
Imports System.IO
|
||||
Imports System.Windows.Forms
|
||||
Imports DevExpress.Utils
|
||||
Imports DevExpress.XtraBars
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DevExpress.XtraGrid.Columns
|
||||
Imports DevExpress.XtraGrid.Menu
|
||||
Imports DevExpress.XtraGrid.Views.BandedGrid
|
||||
Imports DevExpress.XtraGrid.Views.Base
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
@@ -28,6 +30,13 @@ Public Class frmDocumentResultList
|
||||
Private COLUMN_DOCID As String = "DocID"
|
||||
Private COLUMN_ICON As String = "ICON"
|
||||
|
||||
' Constants
|
||||
Private Const OPEN_FILE As String = "Datei öffnen"
|
||||
Private Const OPEN_DIRECTORY As String = "Ordner öffnen"
|
||||
Private Const COPY_FILE_PATH As String = "Dateipfad kopieren"
|
||||
Private Const COPY_FOLDER_PATH As String = "Ordnerpfad kopieren"
|
||||
Private Const OPEN_PROPERTIES As String = "Eigenschaften"
|
||||
|
||||
Private Const FILE_OPEN_TIMER_INTERVAL As Integer = 500
|
||||
|
||||
' Helper Classes
|
||||
@@ -41,6 +50,7 @@ Public Class frmDocumentResultList
|
||||
Private _Helpers As DocumentResultList
|
||||
Private _Filesystem As DigitalData.Modules.Filesystem.File
|
||||
Private _GridBuilder As GridBuilder
|
||||
Private _File As Modules.Windows.File
|
||||
|
||||
' Runtime variables
|
||||
Private _IsLoading As Boolean = True
|
||||
@@ -54,6 +64,7 @@ Public Class frmDocumentResultList
|
||||
Private WithEvents _FileOpenTimer As New Timer
|
||||
Private _OpenDocuments As New DocumentResultCache(50000000)
|
||||
Private _CurrentDocument As DocumentResultInfo = Nothing
|
||||
Private _CurrentDocumentId As Long = Nothing
|
||||
Private _Language As String
|
||||
|
||||
Private Property OperationMode As IResultForm.Mode Implements IResultForm.OperationMode
|
||||
@@ -78,11 +89,8 @@ Public Class frmDocumentResultList
|
||||
_Filesystem = New Modules.Filesystem.File(_LogConfig)
|
||||
_GridBuilder = New GridBuilder(New List(Of GridView) From {GridView1, GridView2, GridView3})
|
||||
_Environment = Environment
|
||||
_Logger.Debug("DocumentResultlist: Environment loaded")
|
||||
_Params = Params
|
||||
_Logger.Debug("DocumentResultlist: Params loaded")
|
||||
_ResultLists = Params.Results
|
||||
_Logger.Debug("DocumentResultlist: Params.Results loaded")
|
||||
_Language = Utils.NotNull(_Environment.User.Language, State.UserState.LANG_EN_US)
|
||||
End Sub
|
||||
|
||||
@@ -582,7 +590,7 @@ Public Class frmDocumentResultList
|
||||
If _Config IsNot Nothing And _IsLoading = False Then
|
||||
_Config.Config.SplitContainer2Horizontal = SwitchDetailContainerHorizontal.Checked
|
||||
End If
|
||||
End Sub
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItemExportGrid1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemExportGrid1.ItemClick
|
||||
Dim oActiveGrid = GetActiveGridControl()
|
||||
@@ -707,8 +715,9 @@ Public Class frmDocumentResultList
|
||||
Private Sub OpenFile()
|
||||
Try
|
||||
If _CurrentDocument IsNot Nothing Then
|
||||
Dim oFilename = _CurrentDocument.FullPath
|
||||
DocumentPropertyMenu_FileOpened(Me, oFilename)
|
||||
Process.Start(New ProcessStartInfo With {
|
||||
.FileName = _CurrentDocument.FullPath
|
||||
})
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
@@ -716,51 +725,51 @@ Public Class frmDocumentResultList
|
||||
End Sub
|
||||
|
||||
Private Sub CopyFileName()
|
||||
Try
|
||||
Dim oRow = GetActiveRow()
|
||||
Try
|
||||
Dim oRow = GetActiveRow()
|
||||
|
||||
If oRow IsNot Nothing Then
|
||||
Dim oFilename = _CurrentDocument.FullPath
|
||||
Clipboard.SetText(oFilename)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
If oRow IsNot Nothing Then
|
||||
Dim oFilename = _CurrentDocument.FullPath
|
||||
Clipboard.SetText(oFilename)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub OpenProperties()
|
||||
Try
|
||||
Dim oRow = GetActiveRow()
|
||||
Private Sub OpenProperties()
|
||||
Try
|
||||
Dim oRow = GetActiveRow()
|
||||
|
||||
If oRow IsNot Nothing Then
|
||||
Dim oObjectId = oRow.Item(COLUMN_DOCID)
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _IDBClient, oObjectId)
|
||||
oPropertyDialog.Show()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
If oRow IsNot Nothing Then
|
||||
Dim oObjectId = oRow.Item(COLUMN_DOCID)
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _IDBClient, oObjectId)
|
||||
oPropertyDialog.Show()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub GridView1_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView1.ColumnFilterChanged
|
||||
Dim oRowCount = sender.RowCount
|
||||
UpdateGridHeader(_ResultLists, 0, oRowCount)
|
||||
End Sub
|
||||
Private Sub GridView1_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView1.ColumnFilterChanged
|
||||
Dim oRowCount = sender.RowCount
|
||||
UpdateGridHeader(_ResultLists, 0, oRowCount)
|
||||
End Sub
|
||||
|
||||
Private Sub GridView2_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView2.ColumnFilterChanged
|
||||
Dim oRowCount = sender.RowCount
|
||||
UpdateGridHeader(_ResultLists, 1, oRowCount)
|
||||
End Sub
|
||||
Private Sub GridView2_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView2.ColumnFilterChanged
|
||||
Dim oRowCount = sender.RowCount
|
||||
UpdateGridHeader(_ResultLists, 1, oRowCount)
|
||||
End Sub
|
||||
|
||||
Private Sub GridView3_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView3.ColumnFilterChanged
|
||||
Dim oRowCount = sender.RowCount
|
||||
UpdateGridHeader(_ResultLists, 2, oRowCount)
|
||||
End Sub
|
||||
Private Sub GridView3_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView3.ColumnFilterChanged
|
||||
Dim oRowCount = sender.RowCount
|
||||
UpdateGridHeader(_ResultLists, 2, oRowCount)
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonBack.ItemClick
|
||||
ShouldReturnToPreviousForm = True
|
||||
Close()
|
||||
End Sub
|
||||
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonBack.ItemClick
|
||||
ShouldReturnToPreviousForm = True
|
||||
Close()
|
||||
End Sub
|
||||
|
||||
Private Sub frmDocumentResultList_Closing(sender As Object, e As CancelEventArgs) Handles Me.FormClosing
|
||||
Try
|
||||
@@ -777,48 +786,15 @@ Public Class frmDocumentResultList
|
||||
End Sub
|
||||
|
||||
Private Sub GridControl_DoubleClick(sender As Object, e As EventArgs) Handles GridControl1.DoubleClick, GridControl2.DoubleClick, GridControl3.DoubleClick
|
||||
If _CurrentDocument IsNot Nothing AndAlso _CurrentDocument.AccessRight > Rights.AccessRight.VIEW_ONLY Then
|
||||
OpenFile()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub GridView_PopupMenuShowing(sender As Object, e As PopupMenuShowingEventArgs) _
|
||||
Handles GridView2.PopupMenuShowing, GridView3.PopupMenuShowing, GridView1.PopupMenuShowing
|
||||
Try
|
||||
Dim oView As GridView = sender
|
||||
|
||||
If e.MenuType = GridMenuType.Row Then
|
||||
Dim oRowHandle = e.HitInfo.RowHandle
|
||||
Dim oRow As DataRow = oView.GetDataRow(oRowHandle)
|
||||
Dim oFilepath As String = _CurrentDocument.FullPath
|
||||
Dim oObjectId As Long = oRow.Item(COLUMN_DOCID)
|
||||
Dim oMenu As New DocumentPropertyMenu(_LogConfig, _Environment, _IDBClient, oFilepath, oObjectId)
|
||||
|
||||
e.Menu.Items.Clear()
|
||||
|
||||
For Each oItem In oMenu.GetMenuItems(OperationMode, _CurrentDocument.AccessRight)
|
||||
e.Menu.Items.Add(oItem)
|
||||
Next
|
||||
|
||||
AddHandler oMenu.FileOpened, AddressOf DocumentPropertyMenu_FileOpened
|
||||
' AddHandler oMenu.FileClosed, AddressOf DocumentPropertyMenu_FileClosed
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MsgBox("Unexpected Error while preparing context menu", MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub DocumentPropertyMenu_FileOpened(sender As Object, FilePath As String)
|
||||
Dim oProcess = Process.Start(New ProcessStartInfo With {
|
||||
.FileName = FilePath
|
||||
})
|
||||
If _CurrentDocument IsNot Nothing AndAlso _CurrentDocument.AccessRight > Rights.AccessRight.VIEW_ONLY Then
|
||||
OpenFile()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub Show_CriticalError(Message As String)
|
||||
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||
labelCriticalError.Caption = Message
|
||||
End Sub
|
||||
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||
labelCriticalError.Caption = Message
|
||||
End Sub
|
||||
|
||||
Public Sub Show_Warning(Message As String)
|
||||
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||
@@ -844,8 +820,6 @@ Public Class frmDocumentResultList
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private _DragBoxFromMouseDown As Rectangle
|
||||
Private _ScreenOffset As Point
|
||||
|
||||
@@ -885,4 +859,109 @@ Public Class frmDocumentResultList
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub GridView_PopupMenuShowing(sender As Object, e As PopupMenuShowingEventArgs) _
|
||||
Handles GridView2.PopupMenuShowing, GridView3.PopupMenuShowing, GridView1.PopupMenuShowing
|
||||
Try
|
||||
Dim oView As GridView = sender
|
||||
|
||||
If e.MenuType = GridMenuType.Row Then
|
||||
Dim oRowHandle = e.HitInfo.RowHandle
|
||||
Dim oRow As DataRow = oView.GetDataRow(oRowHandle)
|
||||
Dim oObjectId As Long = oRow.Item(COLUMN_DOCID)
|
||||
Dim oPoint As Point = oView.GridControl.PointToScreen(e.HitInfo.HitPoint)
|
||||
Dim oRight As Rights.AccessRight = _CurrentDocument.AccessRight
|
||||
|
||||
_CurrentDocumentId = oObjectId
|
||||
|
||||
If OperationMode = IResultForm.Mode.WithAppServer Then
|
||||
If oRight = Rights.AccessRight.FULL Or oRight = Rights.AccessRight.VIEW_EXPORT Then
|
||||
MenuFullAccess_IDB.ShowPopup(oPoint)
|
||||
Else
|
||||
MenuViewAccess_IDB.ShowPopup(oPoint)
|
||||
End If
|
||||
|
||||
Else
|
||||
MenuFullAccess_EDM.ShowPopup(oPoint)
|
||||
End If
|
||||
Else
|
||||
_CurrentDocumentId = Nothing
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MsgBox("Unexpected Error while preparing context menu", MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function TestPathExists(pTitle As String) As Boolean
|
||||
If IO.File.Exists(_CurrentDocument.FullPath) = False Then
|
||||
MessageBox.Show($"Datei {_CurrentDocument.FullPath} existiert nicht oder wurde verschoben!", pTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function TestObjectIdExists(pObjectId As Long, pTitle As String) As Boolean
|
||||
If pObjectId = 0 Then
|
||||
MessageBox.Show($"Objekt {pObjectId} existiert nicht oder wurde verschoben!", pTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Sub MenuItemPropertiesIDB_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesIDB.ItemClick
|
||||
If TestObjectIdExists(_CurrentDocumentId, OPEN_PROPERTIES) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _IDBClient, _CurrentDocumentId)
|
||||
oPropertyDialog.Show()
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemPropertiesECM_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesECM.ItemClick
|
||||
If TestPathExists(OPEN_PROPERTIES) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
_File.OpenFileProperties(_CurrentDocument.FullPath)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFileOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFileOpen.ItemClick
|
||||
If TestPathExists(OPEN_FILE) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Try
|
||||
Process.Start(New ProcessStartInfo With {
|
||||
.FileName = _CurrentDocument.FullPath
|
||||
})
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFolderOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFolderOpen.ItemClick
|
||||
If TestPathExists(OPEN_DIRECTORY) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oArgs As String = $"/e, /select, ""{_CurrentDocument.FullPath}"""
|
||||
Dim oInfo As New ProcessStartInfo() With {
|
||||
.Arguments = oArgs,
|
||||
.FileName = "explorer"
|
||||
}
|
||||
|
||||
Process.Start(oInfo)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFilepathCopyIDB_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFilepathCopy.ItemClick
|
||||
Clipboard.SetText(_CurrentDocument.FullPath)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFolderpathCopyECM_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFolderpathCopy.ItemClick
|
||||
Dim oFolderPath = IO.Path.GetDirectoryName(_CurrentDocument.FullPath)
|
||||
Clipboard.SetText(oFolderPath)
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user