/// <summary> /// constructor /// </summary> /// <param name="source"></param> /// <param name="newListener"></param> public BaseGestureEventArgs(BaseGestureEventArgs source = null, Listener newListener = null) { if (source != null) { Listener = newListener ?? source.Listener; Cancelled = source.Cancelled; if (Listener != null) { WindowTouches = new Point[source.WindowTouches.Length]; ElementTouches = new Point[source.WindowTouches.Length]; for (int i = 0; i < source.WindowTouches.Length; i++) { WindowTouches[i] = source.WindowTouches[i]; ElementTouches[i] = Listener.Element.PointInElementCoord(source.ElementTouches[i], newListener.Element); } ElementPosition = VisualElementExtensions.CoordTransform(Listener.Element, source.ElementPosition, newListener.Element); } else { WindowTouches = (Point[])source.WindowTouches.Clone(); ElementTouches = (Point[])source.ElementTouches.Clone(); ElementPosition = source.ElementPosition; } } }
/// <summary> /// Updates properties of this instance with values from an other instance /// </summary> /// <param name="other"></param> public void ValueFrom(BaseGestureEventArgs other) { Handled = other.Handled; _center = other._center; Listener = other.Listener; Cancelled = other.Cancelled; ViewPosition = other.ViewPosition; Touches = other.Touches; }
/// <summary> /// Updates properties of this instance with values from an other instance /// </summary> /// <param name="other"></param> public void ValueFrom(BaseGestureEventArgs other) { Handled = other.Handled; _center = other._center; Listener = other.Listener; Cancelled = other.Cancelled; ElementPosition = other.ElementPosition; ElementTouches = other.ElementTouches; WindowTouches = other.WindowTouches; }
/// <summary> /// Equal test /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(BaseGestureEventArgs other) { if (other == null) return false; if (WindowTouches == null && other.WindowTouches == null) return true; if (WindowTouches.Length != other.WindowTouches.Length) return false; for (int i = 0; i < WindowTouches.Length; i++) if (!Equals(WindowTouches[i], other?.WindowTouches[i])) return false; return true; }
/// <summary> /// Equal test /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(BaseGestureEventArgs other) { if (other == null) { return(false); } if (Touches == null && other.Touches == null) { return(true); } if (Touches.Length != other.Touches.Length) { return(false); } for (int i = 0; i < Touches.Length; i++) { if (!Equals(Touches[i], other?.Touches[i])) { return(false); } } return(true); }
/// <summary> /// calculates the distance traversed since last sample /// </summary> /// <param name="previous"></param> protected void CalculateDistances(BaseGestureEventArgs previous) //, Point locationAtStart) { if (previous == null) { DeltaDistance = new Point(0.0, 0.0); TotalDistance = new Point(0.0, 0.0); return; } DeltaDistance = Center(WindowTouches).Subtract(Center(previous.WindowTouches)); if (previous is PanEventArgs previousPan) { if (WindowTouches.Length != previous.WindowTouches.Length) { DeltaDistance = new Point(0.0, 0.0); TotalDistance = previousPan.TotalDistance; return; } TotalDistance = previousPan.TotalDistance.Add(DeltaDistance); } else { TotalDistance = DeltaDistance; } }