Ejemplo n.º 1
0
        public static DropHitTestResults HitTest(FrameworkElement element, Point point)
        {
            DropHitTestResults dropHitTestResults = DropHitTestResults.None;

            if (element != null)
            {
                double actualWidth  = element.ActualWidth;
                double actualHeight = element.ActualHeight;
                if (point.X >= 0.0 && point.X < actualWidth && (point.Y >= 0.0 && point.Y < actualHeight))
                {
                    if (point.Y < actualHeight / 2.0)
                    {
                        dropHitTestResults |= DropHitTestResults.UpperHalf;
                    }
                    else
                    {
                        dropHitTestResults |= DropHitTestResults.LowerHalf;
                    }
                    if (point.Y > actualHeight / 4.0 && point.Y < actualHeight * 3.0 / 4.0)
                    {
                        dropHitTestResults |= DropHitTestResults.CenterHalf;
                    }
                }
            }
            return(dropHitTestResults);
        }
Ejemplo n.º 2
0
 public override void OnDragEnter(DragEventArgs e)
 {
     base.OnDragEnter(e);
     this.LastHitTestResult = this.HitTestResult;
     if (this.DropTarget != null)
     {
         this.HitTestResult = ListItemDragDropHandler.HitTest(this.DropTarget, e.GetPosition((IInputElement)this.DropTarget));
     }
     else
     {
         this.HitTestResult = DropHitTestResults.None;
     }
 }
Ejemplo n.º 3
0
 public override void OnDragOver(DragEventArgs e)
 {
     base.OnDragOver(e);
     this.LastHitTestResult = this.HitTestResult;
     if (this.DropTarget != null)
     {
         this.HitTestResult = ListItemDragDropHandler.HitTest(this.DropTarget, e.GetPosition((IInputElement)this.DropTarget));
         if (this.hoverHelper == null)
         {
             return;
         }
         this.hoverHelper.HandleMouseMove(Mouse.GetPosition((IInputElement)this.DropTarget), (this.HitTestResult & DropHitTestResults.CenterHalf) != DropHitTestResults.None);
     }
     else
     {
         this.HitTestResult = DropHitTestResults.None;
     }
 }
Ejemplo n.º 4
0
 public override void OnDragLeave(DragEventArgs e)
 {
     this.LastHitTestResult = this.HitTestResult = DropHitTestResults.None;
     base.OnDragLeave(e);
 }