예제 #1
0
 /// <summary>
 /// Calculates total and most recent change in scale
 /// </summary>
 /// <param name="previous"></param>
 protected void CalculateScales(PinchEventArgs previous)
 {
     if (previous != null && Touches.Length > 1 && previous.Touches.Length > 1)
     {
         Distance = GetDistance(previous);
     }
     else if (Touches.Length > 1)
     {
         Distance = GetDistance();
     }
     else if (previous != null)
     {
         Distance = previous.Distance;
     }
     else
     {
         Distance = 0.0;
     }
     if (previous == null)
     {
         DeltaScale = 1.0;
         TotalScale = 1.0;
         return;
     }
     if (Touches.Length != previous.Touches.Length)
     {
         DeltaScale = 1.0;
         TotalScale = previous.TotalScale;
         return;
     }
     DeltaScale = Distance / previous.Distance;
     TotalScale = previous.TotalScale * DeltaScale;
 }
예제 #2
0
 /// <summary>
 /// Updates properties from the values from another instance
 /// </summary>
 /// <param name="source"></param>
 public void ValueFrom(PinchEventArgs source)
 {
     base.ValueFrom(source);
     Distance   = source.Distance;
     DeltaScale = source.DeltaScale;
     TotalScale = source.TotalScale;
 }
예제 #3
0
        double GetDistance(PinchEventArgs previous)
        {
            var deltaX   = (previous.Touches[1].X + Touches[1].X) / 2.0 - (previous.Touches[0].X + Touches[0].X) / 2.0;
            var deltaY   = (previous.Touches[1].Y + Touches[1].Y) / 2.0 - (previous.Touches[0].Y + Touches[0].Y) / 2.0;
            var distance = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);

            return(distance);
        }
예제 #4
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="source"></param>
 /// <param name="newListener"></param>
 public PinchEventArgs(PinchEventArgs source = null, Listener newListener = null) : base(source, newListener)
 {
     if (source != null)
     {
         Distance   = source.Distance;
         DeltaScale = source.DeltaScale;
         TotalScale = source.TotalScale;
     }
 }
예제 #5
0
 internal PinchEventArgs Diff(PinchEventArgs lastArgs)
 {
     return(new PinchEventArgs {
         Cancelled = Cancelled,
         Handled = Handled,
         ViewPosition = ViewPosition,
         Touches = Touches,
         Listener = Listener,
         Distance = Distance,
         TotalScale = TotalScale,
         DeltaScale = TotalScale / lastArgs.TotalScale
     });
 }