public static Point[] GetTouches(MotionEvent.PointerCoords[] coords, Android.Views.View view, int[] startLocation) { //System.Diagnostics.Debug.WriteLine("c0=["+current.GetX()+","+current.GetY()+"]"); int[] viewLocation = { 0, 0 }; view?.GetLocationInWindow(viewLocation); int pointerCount = coords.Length; var array = new Point[pointerCount]; for (int i = 0; i < pointerCount; i++) { array[i] = DIP.ToPoint((double)(coords[i].X + viewLocation[0] - startLocation[0]), (double)(coords[i].Y + viewLocation[1] - startLocation[1])); //System.Diagnostics.Debug.WriteLine ("i=["+i+"] pc=["+pointerCoords.X+", "+pointerCoords.Y+"] a=["+array[i]+"]"); } return(array); }
public static Point[] GetTouches(MotionEvent current, Android.Views.View view, int[] startLocation) { //System.Diagnostics.Debug.WriteLine("c0=["+current.GetX()+","+current.GetY()+"]"); int[] viewLocation = { 0, 0 }; try { view?.GetLocationInWindow(viewLocation); } catch (System.Exception) { return(new Point[] { }); } var pointerCoords = new MotionEvent.PointerCoords(); int pointerCount = current.PointerCount; var array = new Point[pointerCount]; for (int i = 0; i < pointerCount; i++) { current.GetPointerCoords(i, pointerCoords); array[i] = DIP.ToPoint((double)(pointerCoords.X + viewLocation[0] - startLocation[0]), (double)(pointerCoords.Y + viewLocation[1] - startLocation[1])); //System.Diagnostics.Debug.WriteLine ("i=["+i+"] pc=["+pointerCoords.X+", "+pointerCoords.Y+"] a=["+array[i]+"]"); } return(array); }