bool System.IEquatable <System.Windows.Input.TouchPoint> .Equals(System.Windows.Input.TouchPoint other) { return(default(bool)); }
/// <summary>Raises a <see cref="ReceivedTouch"/> event for the given touch data.</summary> /// <param name="point">Touch data to be passed into the event. Will be ignored if set to null.</param> /// <param name="timestamp">The date and time when the touch occurred.</param> private void RaiseReceivedTouchEventUsing(System.Windows.Input.TouchPoint point, DateTimeOffset timestamp) { // Validate. if (point == null) { return; } // Fetch the pointer/finger's unique integer ID. int pointerId = (point.TouchDevice != null) ? point.TouchDevice.Id : 0; // Fetch the touch phase. Corona.WinRT.Interop.Input.TouchPhase phase; switch (point.Action) { case System.Windows.Input.TouchAction.Move: phase = Corona.WinRT.Interop.Input.TouchPhase.Moved; break; case System.Windows.Input.TouchAction.Up: phase = Corona.WinRT.Interop.Input.TouchPhase.Ended; break; case System.Windows.Input.TouchAction.Down: default: phase = Corona.WinRT.Interop.Input.TouchPhase.Began; break; } // If a touch point began outside of the control, then ignore all of its "moved" and "ended" events. if ((phase != Corona.WinRT.Interop.Input.TouchPhase.Began) && (fLastHandledTouchPoints.ContainsKey(pointerId) == false)) { return; } // Determine if the touch point is within the UI control's bounds. bool isWithinBounds = true; if (point.TouchDevice.DirectlyOver != fUIEventSource) { // One last special check. // If we're providing input event for a page, then allow touch event for a fullscreen background grid control. var page = fUIEventSource as Microsoft.Phone.Controls.PhoneApplicationPage; var backgroundGrid = point.TouchDevice.DirectlyOver as System.Windows.Controls.DrawingSurfaceBackgroundGrid; if ((page == null) || (backgroundGrid == null)) { isWithinBounds = false; } } // Handle touch points outside of the UI control's bounds. if (isWithinBounds == false) { if ((phase == Corona.WinRT.Interop.Input.TouchPhase.Ended) || (phase == Corona.WinRT.Interop.Input.TouchPhase.Canceled)) { // The touch action has ended. Use the last valid point received within the UI control's bounds. fLastHandledTouchPoints.TryGetValue(pointerId, out point); } else { // Ignore touch moves that happened outside of the UI control. return; } } // Update our collection of last received touch points within the UI control's bounds. if ((phase == Corona.WinRT.Interop.Input.TouchPhase.Ended) || (phase == Corona.WinRT.Interop.Input.TouchPhase.Canceled)) { fLastHandledTouchPoints.Remove(pointerId); } else { fLastHandledTouchPoints[pointerId] = point; } // Fetch the event table. var eventTokenTable = ReceivedTouchEventTokenTable.GetOrCreateEventRegistrationTokenTable( ref fReceivedTouchEventTokenTable).InvocationList; if (eventTokenTable == null) { return; } // Convert the touch coordinates to pixels. double scaleFactor = (double)System.Windows.Application.Current.Host.Content.ScaleFactor / 100.0; double pixelPointX = Math.Round(point.Position.X * scaleFactor, MidpointRounding.AwayFromZero); double pixelPointY = Math.Round(point.Position.Y * scaleFactor, MidpointRounding.AwayFromZero); // Store the touch coordinate and timestamp to Corona's touch point type. Corona.WinRT.Interop.Input.TouchPoint coronaTouchPoint; coronaTouchPoint.X = pixelPointX; coronaTouchPoint.Y = pixelPointY; coronaTouchPoint.Timestamp = timestamp; // Raise a "ReceivedTouch" event. var eventArgs = new Corona.WinRT.Interop.Input.TouchEventArgs(pointerId, phase, coronaTouchPoint); eventTokenTable(null, eventArgs); }