From bc791ef7c88202592c374bb159f0f42d5a0ef6f3 Mon Sep 17 00:00:00 2001 From: punker76 Date: Thu, 3 Mar 2022 11:05:11 +0100 Subject: [PATCH] feat: add new interface to catch the dropped item --- .../DefaultDropHandler.cs | 5 +++++ .../IDragItemCloneable.cs | 3 +++ src/GongSolutions.WPF.DragDrop/IDragItemSource.cs | 14 ++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/GongSolutions.WPF.DragDrop/IDragItemSource.cs diff --git a/src/GongSolutions.WPF.DragDrop/DefaultDropHandler.cs b/src/GongSolutions.WPF.DragDrop/DefaultDropHandler.cs index cf29bbae..4f8d544d 100644 --- a/src/GongSolutions.WPF.DragDrop/DefaultDropHandler.cs +++ b/src/GongSolutions.WPF.DragDrop/DefaultDropHandler.cs @@ -326,6 +326,11 @@ public virtual void Drop(IDropInfo dropInfo) { destinationList.Insert(insertIndex++, obj2Insert); } + + if (obj2Insert is IDragItemSource dragItemSource) + { + dragItemSource.ItemDropped(dropInfo); + } } SelectDroppedItems(dropInfo, objects2Insert); diff --git a/src/GongSolutions.WPF.DragDrop/IDragItemCloneable.cs b/src/GongSolutions.WPF.DragDrop/IDragItemCloneable.cs index b7c94645..8d207428 100644 --- a/src/GongSolutions.WPF.DragDrop/IDragItemCloneable.cs +++ b/src/GongSolutions.WPF.DragDrop/IDragItemCloneable.cs @@ -1,5 +1,8 @@ namespace GongSolutions.Wpf.DragDrop { + /// + /// Supports cloning like the ICloneable interface, which creates a new instance of a class with the same value as an existing instance. + /// public interface IDragItemCloneable { /// diff --git a/src/GongSolutions.WPF.DragDrop/IDragItemSource.cs b/src/GongSolutions.WPF.DragDrop/IDragItemSource.cs new file mode 100644 index 00000000..fcfddb9f --- /dev/null +++ b/src/GongSolutions.WPF.DragDrop/IDragItemSource.cs @@ -0,0 +1,14 @@ +namespace GongSolutions.Wpf.DragDrop +{ + /// + /// Supports methods for models which can be dropped. + /// + public interface IDragItemSource + { + /// + /// Indicates that the item is dropped on the destination list. + /// + /// + void ItemDropped(IDropInfo dropInfo); + } +} \ No newline at end of file