コード例 #1
0
        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));
            }
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        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);
        }
コード例 #4
0
    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 ) );
      }
    }