protected virtual void ProcessDragOnCurrentDropTarget(IDropTarget dropTarget) { if (dropTarget != this.CurrentDropTarget) { if (this.CurrentDropTarget != null) { this.CurrentDropTarget.DragLeave(this.DraggedElement); this.CurrentDropTarget = null; } if (dropTarget != null) { if (dropTarget.CanDropElement(this.DraggedElement)) { this.CurrentDropTarget = dropTarget; this.CurrentDropTarget.DragEnter(this.DraggedElement); } } } if (this.CurrentDropTarget != null) { // Always use the Mouse Position relative to DraggedElement and not the DraggedContainer this.CurrentDropTarget.DragOver(this.DraggedElement, Mouse.GetPosition(this.CurrentDropTarget as IInputElement)); } }
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"); }
public static IDropTarget GetDropTargetAtPoint( UIElement draggedElement, UIElement dragContainer, MouseEventArgs e, out Nullable <Point> dropTargetPosition, out IDropTarget lastFoundDropTarget) { dropTargetPosition = null; lastFoundDropTarget = null; if (dragContainer == null) { return(null); } IDropTarget dropTarget = null; Point pointToDragContainer = e.GetPosition(dragContainer); IInputElement hitTest = dragContainer.InputHitTest(pointToDragContainer); if (hitTest != null) { DependencyObject parent = hitTest as DependencyObject; while (parent != null) { dropTarget = parent as IDropTarget; if (dropTarget != null) { lastFoundDropTarget = dropTarget; if (dropTarget.CanDropElement(draggedElement)) { dropTargetPosition = pointToDragContainer; break; } } dropTarget = null; parent = Xceed.Utils.Wpf.TreeHelper.GetParent(parent); } } return(dropTarget); }
protected virtual void ProcessDragOnCurrentDropTarget( IDropTarget dropTarget ) { if( dropTarget != this.CurrentDropTarget ) { if( this.CurrentDropTarget != null ) { this.CurrentDropTarget.DragLeave( this.DraggedElement ); this.CurrentDropTarget = null; } if( dropTarget != null ) { if( dropTarget.CanDropElement( this.DraggedElement ) ) { this.CurrentDropTarget = dropTarget; this.CurrentDropTarget.DragEnter( this.DraggedElement ); } } } if( this.CurrentDropTarget != null ) { // Always use the Mouse Position relative to DraggedElement and not the DraggedContainer this.CurrentDropTarget.DragOver( this.DraggedElement, Mouse.GetPosition( this.CurrentDropTarget as IInputElement ) ); } }