From b3d32c83f557eb9ae152f46e7a7793f92a79529d Mon Sep 17 00:00:00 2001 From: chs499 Date: Fri, 27 Sep 2013 13:45:29 +0200 Subject: [PATCH 1/2] Added handling for canceled dragDrop operation. --- GongSolutions.Wpf.DragDrop (NET4).sln | 4 ++-- GongSolutions.Wpf.DragDrop/DefaultDragHandler.cs | 4 ++++ GongSolutions.Wpf.DragDrop/DragDrop.cs | 3 ++- GongSolutions.Wpf.DragDrop/IDragSource.cs | 6 ++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/GongSolutions.Wpf.DragDrop (NET4).sln b/GongSolutions.Wpf.DragDrop (NET4).sln index 9fff4f05..f6c804cd 100644 --- a/GongSolutions.Wpf.DragDrop (NET4).sln +++ b/GongSolutions.Wpf.DragDrop (NET4).sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C1D14F10-00C7-4BE6-9A49-D2B5C950DE34}" ProjectSection(SolutionItems) = preProject - GongSolutions.Wpf.DragDrop.vsmdi = GongSolutions.Wpf.DragDrop.vsmdi + GongSolutions.Wpf.DragDrop (NET4)1.vsmdi = GongSolutions.Wpf.DragDrop (NET4)1.vsmdi LocalTestRun.testrunconfig = LocalTestRun.testrunconfig EndProjectSection EndProject @@ -19,7 +19,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NorthwindExample (NET4)", " EndProject Global GlobalSection(TestCaseManagementSettings) = postSolution - CategoryFile = GongSolutions.Wpf.DragDrop.vsmdi + CategoryFile = GongSolutions.Wpf.DragDrop (NET4)1.vsmdi EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/GongSolutions.Wpf.DragDrop/DefaultDragHandler.cs b/GongSolutions.Wpf.DragDrop/DefaultDragHandler.cs index b448b18c..dc98bac7 100644 --- a/GongSolutions.Wpf.DragDrop/DefaultDragHandler.cs +++ b/GongSolutions.Wpf.DragDrop/DefaultDragHandler.cs @@ -24,5 +24,9 @@ public virtual void StartDrag(IDragInfo dragInfo) public virtual void Dropped(IDropInfo dropInfo) { } + + public virtual void DragCancelled() + { + } } } \ No newline at end of file diff --git a/GongSolutions.Wpf.DragDrop/DragDrop.cs b/GongSolutions.Wpf.DragDrop/DragDrop.cs index f285e86b..c26483c3 100644 --- a/GongSolutions.Wpf.DragDrop/DragDrop.cs +++ b/GongSolutions.Wpf.DragDrop/DragDrop.cs @@ -633,7 +633,8 @@ private static void DragSource_PreviewMouseMove(object sender, MouseEventArgs e) try { m_DragInProgress = true; - System.Windows.DragDrop.DoDragDrop(m_DragInfo.VisualSource, data, m_DragInfo.Effects); + var result = System.Windows.DragDrop.DoDragDrop(m_DragInfo.VisualSource, data, m_DragInfo.Effects); + if (result == DragDropEffects.None) dragHandler.DragCancelled(); } finally { m_DragInProgress = false; } diff --git a/GongSolutions.Wpf.DragDrop/IDragSource.cs b/GongSolutions.Wpf.DragDrop/IDragSource.cs index e134a5c2..1f9146de 100644 --- a/GongSolutions.Wpf.DragDrop/IDragSource.cs +++ b/GongSolutions.Wpf.DragDrop/IDragSource.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Windows; namespace GongSolutions.Wpf.DragDrop { @@ -32,5 +33,10 @@ public interface IDragSource /// Information about the drop. /// void Dropped(IDropInfo dropInfo); + + /// + /// Notifies the drag handler that a drag has been aborted. + /// + void DragCancelled(); } } \ No newline at end of file From 01907763ed563a8bd7431588af39f89e98ca8a97 Mon Sep 17 00:00:00 2001 From: chs499 Date: Fri, 27 Sep 2013 13:55:15 +0200 Subject: [PATCH 2/2] Reverted accidentally made changes to solution file. --- GongSolutions.Wpf.DragDrop (NET4).sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GongSolutions.Wpf.DragDrop (NET4).sln b/GongSolutions.Wpf.DragDrop (NET4).sln index f6c804cd..6021d95a 100644 --- a/GongSolutions.Wpf.DragDrop (NET4).sln +++ b/GongSolutions.Wpf.DragDrop (NET4).sln @@ -19,7 +19,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NorthwindExample (NET4)", " EndProject Global GlobalSection(TestCaseManagementSettings) = postSolution - CategoryFile = GongSolutions.Wpf.DragDrop (NET4)1.vsmdi + CategoryFile = GongSolutions.Wpf.DragDrop (NET4).vsmdi EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU