From 0bce1b82de0e8e55da1e380112bfa2d600078cea Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 10 Feb 2021 11:48:18 +0100 Subject: [PATCH] Common/DocumentResultList: Add Dragdrop from Window to outside, check for rights on doubleclick --- .../frmDocumentResultList.Designer.vb | 23 +++++---- .../frmDocumentResultList.vb | 50 ++++++++++++++++--- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb b/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb index e106fce6..ce4fc7c8 100644 --- a/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb +++ b/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb @@ -86,7 +86,7 @@ Partial Class frmDocumentResultList Me.RibbonControl.ShowApplicationButton = DevExpress.Utils.DefaultBoolean.[False] Me.RibbonControl.ShowPageHeadersMode = DevExpress.XtraBars.Ribbon.ShowPageHeadersMode.Hide Me.RibbonControl.ShowToolbarCustomizeItem = False - Me.RibbonControl.Size = New System.Drawing.Size(1189, 132) + Me.RibbonControl.Size = New System.Drawing.Size(1189, 131) Me.RibbonControl.StatusBar = Me.RibbonStatusBar Me.RibbonControl.Toolbar.ShowCustomizeItem = False ' @@ -192,6 +192,7 @@ Partial Class frmDocumentResultList ' 'labelCriticalError ' + Me.labelCriticalError.Alignment = DevExpress.XtraBars.BarItemLinkAlignment.Right Me.labelCriticalError.Caption = "Critical Error" Me.labelCriticalError.Id = 14 Me.labelCriticalError.ImageOptions.SvgImage = CType(resources.GetObject("labelCriticalError.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage) @@ -205,13 +206,13 @@ Partial Class frmDocumentResultList ' 'labelWarning ' + Me.labelWarning.Alignment = DevExpress.XtraBars.BarItemLinkAlignment.Right Me.labelWarning.Caption = "Warning" Me.labelWarning.Id = 15 Me.labelWarning.ImageOptions.SvgImage = CType(resources.GetObject("labelWarning.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage) Me.labelWarning.ItemAppearance.Normal.BackColor = System.Drawing.Color.White Me.labelWarning.ItemAppearance.Normal.Options.UseBackColor = True Me.labelWarning.Name = "labelWarning" - Me.labelWarning.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph Me.labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.OnlyInCustomizing ' 'RibbonPage1 @@ -248,10 +249,10 @@ Partial Class frmDocumentResultList Me.RibbonStatusBar.ItemLinks.Add(Me.labelResultCount) Me.RibbonStatusBar.ItemLinks.Add(Me.labelCriticalError) Me.RibbonStatusBar.ItemLinks.Add(Me.labelWarning) - Me.RibbonStatusBar.Location = New System.Drawing.Point(0, 647) + Me.RibbonStatusBar.Location = New System.Drawing.Point(0, 649) Me.RibbonStatusBar.Name = "RibbonStatusBar" Me.RibbonStatusBar.Ribbon = Me.RibbonControl - Me.RibbonStatusBar.Size = New System.Drawing.Size(1189, 24) + Me.RibbonStatusBar.Size = New System.Drawing.Size(1189, 22) ' 'SplitContainerControl1 ' @@ -263,7 +264,7 @@ Partial Class frmDocumentResultList Me.SplitContainerControl1.Panel1.Text = "Panel1" Me.SplitContainerControl1.Panel2.Controls.Add(Me.SplitContainerControl2) Me.SplitContainerControl1.Panel2.Text = "Panel2" - Me.SplitContainerControl1.Size = New System.Drawing.Size(762, 515) + Me.SplitContainerControl1.Size = New System.Drawing.Size(762, 518) Me.SplitContainerControl1.SplitterPosition = 382 Me.SplitContainerControl1.TabIndex = 2 Me.SplitContainerControl1.Text = "SplitContainerControl1" @@ -275,7 +276,7 @@ Partial Class frmDocumentResultList Me.GridControl1.MainView = Me.GridView1 Me.GridControl1.MenuManager = Me.RibbonControl Me.GridControl1.Name = "GridControl1" - Me.GridControl1.Size = New System.Drawing.Size(382, 515) + Me.GridControl1.Size = New System.Drawing.Size(382, 518) Me.GridControl1.TabIndex = 0 Me.GridControl1.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridView1}) ' @@ -316,7 +317,7 @@ Partial Class frmDocumentResultList Me.SplitContainerControl2.Panel1.Text = "Panel1" Me.SplitContainerControl2.Panel2.Controls.Add(Me.GridControl3) Me.SplitContainerControl2.Panel2.Text = "Panel2" - Me.SplitContainerControl2.Size = New System.Drawing.Size(370, 515) + Me.SplitContainerControl2.Size = New System.Drawing.Size(370, 518) Me.SplitContainerControl2.SplitterPosition = 223 Me.SplitContainerControl2.TabIndex = 0 Me.SplitContainerControl2.Text = "SplitContainerControl2" @@ -361,7 +362,7 @@ Partial Class frmDocumentResultList Me.GridControl3.MainView = Me.GridView3 Me.GridControl3.MenuManager = Me.RibbonControl Me.GridControl3.Name = "GridControl3" - Me.GridControl3.Size = New System.Drawing.Size(370, 282) + Me.GridControl3.Size = New System.Drawing.Size(370, 285) Me.GridControl3.TabIndex = 0 Me.GridControl3.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridView3}) ' @@ -390,13 +391,13 @@ Partial Class frmDocumentResultList 'SplitContainerControl3 ' Me.SplitContainerControl3.Dock = System.Windows.Forms.DockStyle.Fill - Me.SplitContainerControl3.Location = New System.Drawing.Point(0, 132) + Me.SplitContainerControl3.Location = New System.Drawing.Point(0, 131) Me.SplitContainerControl3.Name = "SplitContainerControl3" Me.SplitContainerControl3.Panel1.Controls.Add(Me.SplitContainerControl1) Me.SplitContainerControl3.Panel1.Text = "Panel1" Me.SplitContainerControl3.Panel2.Controls.Add(Me.DocumentViewer1) Me.SplitContainerControl3.Panel2.Text = "Panel2" - Me.SplitContainerControl3.Size = New System.Drawing.Size(1189, 515) + Me.SplitContainerControl3.Size = New System.Drawing.Size(1189, 518) Me.SplitContainerControl3.SplitterPosition = 762 Me.SplitContainerControl3.TabIndex = 5 Me.SplitContainerControl3.Text = "SplitContainerControl3" @@ -407,7 +408,7 @@ Partial Class frmDocumentResultList Me.DocumentViewer1.FileLoaded = False Me.DocumentViewer1.Location = New System.Drawing.Point(0, 0) Me.DocumentViewer1.Name = "DocumentViewer1" - Me.DocumentViewer1.Size = New System.Drawing.Size(417, 515) + Me.DocumentViewer1.Size = New System.Drawing.Size(417, 518) Me.DocumentViewer1.TabIndex = 0 ' 'XtraSaveFileDialog diff --git a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb index 2ba0f184..38f93e0e 100644 --- a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb +++ b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb @@ -1,4 +1,5 @@ Imports System.ComponentModel +Imports System.Drawing Imports System.IO Imports System.Windows.Forms Imports DevExpress.Utils @@ -575,7 +576,7 @@ Public Class frmDocumentResultList Dim oRow = GetActiveRow() If oRow IsNot Nothing Then - Dim oFilename = oRow.Item(COLUMN_FILEPATH) + Dim oFilename = _DocumentInfo.FullPath Dim oDirectory = IO.Path.GetDirectoryName(oFilename) Process.Start(oDirectory) End If @@ -602,7 +603,7 @@ Public Class frmDocumentResultList Dim oRow = GetActiveRow() If oRow IsNot Nothing Then - Dim oFilename = oRow.Item(COLUMN_FILEPATH) + Dim oFilename = _DocumentInfo.FullPath Clipboard.SetText(oFilename) End If Catch ex As Exception @@ -657,7 +658,9 @@ Public Class frmDocumentResultList End Sub Private Sub GridControl_DoubleClick(sender As Object, e As EventArgs) Handles GridControl1.DoubleClick, GridControl2.DoubleClick, GridControl3.DoubleClick - OpenFile() + If _DocumentInfo IsNot Nothing And _DocumentInfo.AccessRight > Rights.AccessRight.VIEW_ONLY Then + OpenFile() + End If End Sub Private Sub GridView_PopupMenuShowing(sender As Object, e As PopupMenuShowingEventArgs) _ @@ -668,7 +671,7 @@ Public Class frmDocumentResultList If e.MenuType = GridMenuType.Row Then Dim oRowHandle = e.HitInfo.RowHandle Dim oRow As DataRow = oView.GetDataRow(oRowHandle) - Dim oFilepath As String = oRow.Item(COLUMN_FILEPATH) + Dim oFilepath As String = _DocumentInfo.FullPath Dim oObjectId As Long = oRow.Item(COLUMN_DOCID) Dim oMenu As New DocumentPropertyMenu(_LogConfig, _Environment, _IDBClient, oFilepath, oObjectId) @@ -749,8 +752,8 @@ Public Class frmDocumentResultList If Not IsNothing(_ActiveGrid) Then Try Dim oFile = GetDevexpressGrid_LayoutName(_ActiveGrid.MainView) - If IO.File.Exists(oFile) Then - IO.File.Delete(oFile) + If File.Exists(oFile) Then + File.Delete(oFile) End If UpdateGridData() Catch ex As Exception @@ -762,4 +765,39 @@ Public Class frmDocumentResultList Private Sub frmDocumentResultList_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing GridViewSave_Layout(_ActiveGrid.MainView) End Sub + + Private _DragBoxFromMouseDown As Rectangle + Private _ScreenOffset As Point + + Private Sub GridView1_MouseDown(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseDown + If sender.FocusedRowHandle >= 0 Then + Dim oDragSize As Size = SystemInformation.DragSize + + _DragBoxFromMouseDown = New Rectangle(New Point(e.X - (oDragSize.Width / 2), + e.Y - (oDragSize.Height / 2)), oDragSize) + + Else + _DragBoxFromMouseDown = Rectangle.Empty + End If + End Sub + + Private Sub GridView1_MouseUp(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseUp + _DragBoxFromMouseDown = Rectangle.Empty + End Sub + + Private Sub GridView1_MouseMove(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseMove + If e.Button AndAlso e.Button = MouseButtons.Left Then + If _DragBoxFromMouseDown <> Rectangle.Empty And Not _DragBoxFromMouseDown.Contains(e.X, e.Y) Then + If _DocumentInfo IsNot Nothing AndAlso _DocumentInfo.AccessRight > Rights.AccessRight.VIEW_ONLY Then + _ScreenOffset = SystemInformation.WorkingArea.Location + + Dim oFullPath As String = _DocumentInfo.FullPath + Dim oFiles As String() = {oFullPath} + Dim oData As New DataObject(DataFormats.FileDrop, oFiles) + + sender.GridControl.DoDragDrop(oData, DragDropEffects.All) + End If + End If + End If + End Sub End Class \ No newline at end of file