public override bool OnTouchEvent(Android.Views.MotionEvent e) { double x = (e.GetX() * LayoutElement.Width) / this.Width; double y = (e.GetY() * LayoutElement.Height) / this.Height; switch (e.Action) { case Android.Views.MotionEventActions.Down: HandleTouchStart(x, y); startX = x; startY = y; break; case Android.Views.MotionEventActions.Move: if (LayoutElement.Dragging) { LayoutElement.HandleTouch(x, y); } break; case Android.Views.MotionEventActions.Up: if (currentDraggable != null && ((currentDraggable.Status == DragState.None || currentDraggable.Status == DragState.Started) || BelowTapThreshold(x, y))) { if (currentDraggable.TapEnabled) { currentDraggable.OnTapped(); } currentDraggable = null; } if (LayoutElement.Dragging) { MessagingCenter.Send <DragAndDropLayoutRenderer, bool>(this, "IsDragging", false); LayoutElement.StopDragging(); LayoutElement.Dragging = false; currentDraggable = null; } break; default: break; } return(true); }
public override void TouchesEnded(Foundation.NSSet touches, UIEvent evt) { base.TouchesEnded(touches, evt); if (currentDraggable != null && (currentDraggable.Status == DragState.None || currentDraggable.Status == DragState.Started)) { if (currentDraggable.TapEnabled) { currentDraggable.OnTapped(); } currentDraggable = null; } if (LayoutElement.Dragging) { LayoutElement.StopDragging(); LayoutElement.Dragging = false; dragMightStart = false; currentDraggable = null; } }