예제 #1
0
        private void DragVisualHost_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            if (this.capturePending)
            {
                this.capturePending = false;
                if (!this.EnsurePoinerCapture(e))
                {
                    return;
                }
            }

            var dragPoint = e.GetCurrentPoint(this.dragSurface.RootElement).Position;

            this.dragVisualBounds    = this.dragSurface.PositionDragHost(this.dragVisualContext, dragPoint, this.relativeStartPosition);
            this.restrictedDragPoint = this.GetRestrictedPosition(dragPoint, this.dragVisualContext.PositionRestriction);

            IDragDropElement newTarget = this.hitTestStrategy.GetTarget(this.dragVisualBounds, this.restrictedDragPoint);

            if (this.targetElement != newTarget)
            {
                this.OnDragLeave();

                this.targetElement = newTarget;

                this.OnDragEnter();
            }
            else
            {
                this.OnDragOver();
            }

            this.OnDragging();
        }
예제 #2
0
        public DragDropOperation(DragStartingContext startContext, IDragDropElement source, DragPositionMode positionMode, Pointer pointer, Point startClickPosition, Point relativeStartPosition)
        {
            this.sourceElement = source;

            this.dragSurface     = startContext.DragSurface;
            this.dragContext     = new DragContext(startContext.Payload, this);
            this.hitTestStrategy = startContext.HitTestStrategy ?? new DragHitTestStrategy(this.dragSurface.RootElement);

            this.dragVisualContext = this.dragSurface.CreateDragContext();
            this.dragVisualContext.DragStartPosition   = new Point(startClickPosition.X - relativeStartPosition.X - startContext.DragVisual.Margin.Left, startClickPosition.Y - relativeStartPosition.Y - startContext.DragVisual.Margin.Top);
            this.dragVisualContext.PositionRestriction = positionMode;

            this.dragVisualContext.PrepareDragVisual(startContext.DragVisual);

            this.startDragPosition     = startClickPosition;
            this.relativeStartPosition = relativeStartPosition;

            this.InitializeVisual();

            this.dragVisualContext.DragVisualHost.PointerMoved       += this.DragVisualHost_PointerMoved;
            this.dragVisualContext.DragVisualHost.PointerReleased    += this.DragVisualHost_PointerReleased;
            this.dragVisualContext.DragVisualHost.PointerCaptureLost += this.DragVisualHost_PointerCaptureLost;

            if (pointer != null && this.dragVisualContext.DragVisualHost.CapturePointer(pointer))
            {
                this.capturedPointer        = pointer;
                this.originalFocusedElement = FocusManager.GetFocusedElement() as Control;
                if (this.originalFocusedElement != null)
                {
                    this.originalFocusState = this.originalFocusedElement.FocusState;
                }
                ((Control)this.dragVisualContext.DragVisualHost).Focus(FocusState.Programmatic);
            }
            else if (pointer != null)
            {
                this.CancelDrag();
            }
            else
            {
                this.capturePending = true;
            }

            this.dragSurface.RootElement.KeyDown += this.RootElement_KeyDown;
        }
 public ReorderListViewItemHitTestStrategy(IDragDropElement source, UIElement rootElement)
     : base(rootElement)
 {
     this.source = source;
 }
예제 #4
0
 public ColumnHeaderHittestStrategy(IDragDropElement source, UIElement rootElement)
     : base(rootElement)
 {
     this.source = source;
 }