private void SetCurrentDropTarget(IDropTarget value, RelativePoint mousePosition, bool raiseDragEvents)
        {
            if (value == m_currentDropTarget)
            {
                return;
            }

            var element = this.DraggedElement;

            if (m_currentDropTarget != null)
            {
                if (raiseDragEvents)
                {
                    m_currentDropTarget.DragLeave(element);
                }

                m_currentDropTarget = null;
            }

            if ((value != null) && value.CanDropElement(element, mousePosition))
            {
                m_currentDropTarget = value;

                if (raiseDragEvents)
                {
                    m_currentDropTarget.DragEnter(element);
                }
            }

            this.OnPropertyChanged("CurrentDropTarget");
        }
Exemplo n.º 2
0
        static void SendDragAndDropEvent(IDragAndDropEvent evt, List <ISelectable> selection, IDropTarget dropTarget, ISelection dragSource)
        {
            if (dropTarget == null)
            {
                return;
            }

            EventBase e = evt as EventBase;

            if (e.eventTypeId == DragExitedEvent.TypeId())
            {
                dropTarget.DragExited();
            }
            else if (e.eventTypeId == DragEnterEvent.TypeId())
            {
                dropTarget.DragEnter(evt as DragEnterEvent, selection, dropTarget, dragSource);
            }
            else if (e.eventTypeId == DragLeaveEvent.TypeId())
            {
                dropTarget.DragLeave(evt as DragLeaveEvent, selection, dropTarget, dragSource);
            }

            if (!dropTarget.CanAcceptDrop(selection))
            {
                return;
            }

            if (e.eventTypeId == DragPerformEvent.TypeId())
            {
                dropTarget.DragPerform(evt as DragPerformEvent, selection, dropTarget, dragSource);
            }
            else if (e.eventTypeId == DragUpdatedEvent.TypeId())
            {
                dropTarget.DragUpdated(evt as DragUpdatedEvent, selection, dropTarget, dragSource);
            }
        }