public virtual void CompleteDrag(DragVisualContext context, bool dragSuccessful) { if (context == null) { return; } context.ClearDragVisual(); }
public override Windows.Foundation.Rect PositionDragHost(DragVisualContext context, Point dragPoint, Point relativeStartPosition) { if (context == null) { return(Rect.Empty); } Rect position = base.PositionDragHost(context, dragPoint, relativeStartPosition); Canvas.SetLeft(context.DragVisualHost, position.X); Canvas.SetTop(context.DragVisualHost, position.Y); return(position); }
public override void CompleteDrag(DragVisualContext context, bool dragSuccessful) { if (context == null) { return; } base.CompleteDrag(context, dragSuccessful); // Check if Adorner is in visual tree (calling this when element is unloaded will throw COM exception). if (this.adorner.Parent != null) { this.adorner.Children.Remove(context.DragVisualHost); } }
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; }
private static Point GetRestrictedDragPoint(DragVisualContext context, Point dragPoint, Point relativeStartPosition) { double x = dragPoint.X - relativeStartPosition.X; double y = dragPoint.Y - relativeStartPosition.Y; switch (context.PositionRestriction) { case DragPositionMode.RailX: y = context.DragStartPosition.Y; break; case DragPositionMode.RailY: x = context.DragStartPosition.X; break; case DragPositionMode.RailXForward: y = context.DragStartPosition.Y; x = Math.Max(0, x); break; case DragPositionMode.RailXBackwards: y = context.DragStartPosition.Y; x = Math.Min(0, x); break; case DragPositionMode.RailYForward: x = context.DragStartPosition.X; y = Math.Max(0, y); break; case DragPositionMode.RailYBackwards: x = context.DragStartPosition.X; y = Math.Min(0, y); break; case DragPositionMode.Free: default: break; } return(new Point(x, y)); }
private static Point GetRestrictedDragPoint(DragVisualContext context, Point dragPoint, Point relativeStartPosition, Thickness maxPositionOffset) { double x = RadMath.CoerceValue(dragPoint.X - relativeStartPosition.X, -maxPositionOffset.Right, maxPositionOffset.Left); double y = RadMath.CoerceValue(dragPoint.Y - relativeStartPosition.Y, -maxPositionOffset.Bottom, maxPositionOffset.Top); switch (context.PositionRestriction) { case DragPositionMode.RailX: y = context.DragStartPosition.Y; break; case DragPositionMode.RailY: x = context.DragStartPosition.X; break; case DragPositionMode.RailXForward: y = context.DragStartPosition.Y; x = Math.Max(0, x); break; case DragPositionMode.RailXBackwards: y = context.DragStartPosition.Y; x = Math.Min(0, x); break; case DragPositionMode.RailYForward: x = context.DragStartPosition.X; y = Math.Max(0, y); break; case DragPositionMode.RailYBackwards: x = context.DragStartPosition.X; y = Math.Min(0, y); break; case DragPositionMode.Free: default: break; } return(new Point(x, y)); }
public virtual Rect PositionDragHost(DragVisualContext context, Point dragPoint, Point relativeStartPosition) { if (context == null) { return(Rect.Empty); } Point restrictedPoint = DragSurfaceBase.GetRestrictedDragPoint(context, dragPoint, relativeStartPosition); if (this.ShouldTruncateToBounds) { restrictedPoint = this.TruncateToBounds(context.DragVisualHost, restrictedPoint); } var rect = new Rect(restrictedPoint, context.DragVisualHost.RenderSize); context.DragVisualHost.Arrange(rect); return(rect); }
private static Point GetRestrictedDragPoint(DragVisualContext context, Point dragPoint, Point relativeStartPosition) { double x = dragPoint.X - relativeStartPosition.X; double y = dragPoint.Y - relativeStartPosition.Y; switch (context.PositionRestriction) { case DragPositionMode.RailX: y = context.DragStartPosition.Y; break; case DragPositionMode.RailY: x = context.DragStartPosition.X; break; case DragPositionMode.Free: default: break; } return(new Point(x, y)); }