Пример #1
0
        private void Drop(object sender, DragEventArgs e)
        {
            if (TreeArrange.AdornmentTarget(sender) is not {
            } droppedOnElement)
            {
                return;
            }
            if (ExtractDraggedData(e) is not {
            } draggedItem)
            {
                TrySendSupplementalDropMessage(sender, e);
                return;
            }
            if (TreeArrange.FindDraggedItem(droppedOnElement) is not {
            } target || target == draggedItem)
            {
                return;
            }
            if (DroppingItemOnOwnChild(droppedOnElement, draggedItem))
            {
                return;
            }
            if (ListFinder.FindParentListContainingData(droppedOnElement, target) is not {
            } items)
            {
                return;
            }
            e.Handled = true;


            e.Effects = ComputeAdornerType(RelativePosition(e, droppedOnElement), HasChildList(droppedOnElement, draggedItem)) switch
            {
                DropAdornerKind.Top => InsertDroppedItemIntoTarget(items, target, draggedItem, 0),
                DropAdornerKind.Bottom => InsertDroppedItemIntoTarget(items, target, draggedItem, 1),
                _ => InsertDroppedItemIntoTarget(
                    ListFinder.FindChildListToHoldData(droppedOnElement, draggedItem) ?? items, null, draggedItem, 0)
            };
        }
Пример #2
0
 private static bool HasChildList(FrameworkElement droppedOnElement, object droppedData) =>
 ListFinder.FindChildListToHoldData(droppedOnElement, droppedData) is not null;