Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions GongSolutions.Wpf.DragDrop/DefaultDropHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ public class DefaultDropHandler : IDropTarget
public virtual void DragOver(IDropInfo dropInfo)
{
if (CanAcceptData(dropInfo)) {
// when source is the same as the target set the move effect otherwise set the copy effect
var moveData = dropInfo.DragInfo.VisualSource == dropInfo.VisualTarget
|| !dropInfo.KeyStates.HasFlag(dropInfo.DragInfo.DragDropCopyKeyState)
|| dropInfo.DragInfo.VisualSourceItem is TabItem
|| dropInfo.DragInfo.VisualSourceItem is TreeViewItem
|| dropInfo.DragInfo.VisualSourceItem is MenuItem
|| dropInfo.DragInfo.VisualSourceItem is ListBoxItem;
dropInfo.Effects = moveData ? DragDropEffects.Move : DragDropEffects.Copy;
// default should always the move action/effect
var copyData = (dropInfo.DragInfo.DragDropCopyKeyState != default(DragDropKeyStates)) && dropInfo.KeyStates.HasFlag(dropInfo.DragInfo.DragDropCopyKeyState)
//&& (dropInfo.DragInfo.VisualSource != dropInfo.VisualTarget)
&& !(dropInfo.DragInfo.SourceItem is HeaderedContentControl)
&& !(dropInfo.DragInfo.SourceItem is HeaderedItemsControl)
&& !(dropInfo.DragInfo.SourceItem is ListBoxItem);
dropInfo.Effects = copyData ? DragDropEffects.Copy : DragDropEffects.Move;
var isTreeViewItem = dropInfo.InsertPosition.HasFlag(RelativeInsertPosition.TargetItemCenter) && dropInfo.VisualTargetItem is TreeViewItem;
dropInfo.DropTargetAdorner = isTreeViewItem ? DropTargetAdorners.Highlight : DropTargetAdorners.Insert;
}
Expand All @@ -53,14 +52,13 @@ public virtual void Drop(IDropInfo dropInfo)
var destinationList = dropInfo.TargetCollection.TryGetList();
var data = ExtractData(dropInfo.Data);

// when source is the same as the target remove the data from source and fix the insertion index
var moveData = dropInfo.DragInfo.VisualSource == dropInfo.VisualTarget
|| !dropInfo.KeyStates.HasFlag(dropInfo.DragInfo.DragDropCopyKeyState)
|| dropInfo.DragInfo.VisualSourceItem is TabItem
|| dropInfo.DragInfo.VisualSourceItem is TreeViewItem
|| dropInfo.DragInfo.VisualSourceItem is MenuItem
|| dropInfo.DragInfo.VisualSourceItem is ListBoxItem;
if (moveData)
// default should always the move action/effect
var copyData = (dropInfo.DragInfo.DragDropCopyKeyState != default(DragDropKeyStates)) && dropInfo.KeyStates.HasFlag(dropInfo.DragInfo.DragDropCopyKeyState)
//&& (dropInfo.DragInfo.VisualSource != dropInfo.VisualTarget)
&& !(dropInfo.DragInfo.SourceItem is HeaderedContentControl)
&& !(dropInfo.DragInfo.SourceItem is HeaderedItemsControl)
&& !(dropInfo.DragInfo.SourceItem is ListBoxItem);
if (!copyData)
{
var sourceList = dropInfo.DragInfo.SourceCollection.TryGetList();

Expand Down