,

Touch and TouchPoint Classes

The low-level interface for touch is the TouchPoint class. Unlike mouse events, the TouchPoint class is designed exclusively for touch without a pointing device in mind. A TouchPoint instance represents a finger touching the screen.

TouchPoint has four read-only properties, described in the following list:

Image ActionRepresents the type of manipulation and can have one of the three following values:

Image DownIndicates that the user has made contact with the screen.

Image MoveIndicates that the touch point has changed position.

Image UpIndicates that the touch point has been removed.

Image PositionRetrieves the X and Y coordinate position of the touch point, as a System.Windows.Point. This point is relative to the top-left corner of the element beneath the touch point.

Image SizeThis is supposed to get the rectangular area that is reported as the touch-point contact area. The value reported on Windows Phone, however, always has a width and height of 1, making it of no use on the phone.

Image TouchDeviceRetrieves the specific device type that produced the touch point. This property allows you to retrieve the UIElement beneath the touch point via its TouchDevice.DirectlyOver property. The TouchDevice.Id property allows you to distinguish between fingers touching the display.

The Touch class is an application-level service used to register for touch events. It contains a single public static member, the FrameReported event. This event is global for your app and is raised whenever a touch event occurs.

To register for touch notifications, you subscribe to the Touch.FrameReported event like so:

Touch.FrameReported += HandleFrameReported;

A handler for the FrameReported event accepts a TouchFrameEventArgs argument, as shown:

void HandleFrameReported(object sender, TouchFrameEventArgs args)
{
.../* method body */
}

A frame is a time slice where one or more touch events have occurred. When the FrameReported event is raised, there may be up to four TouchPoint objects.

TouchFrameEventArgs contains four public members, which are described in the following list:

Image TimeStamp property—An int value that indicates when the touch event occurred.

Image GetPrimaryTouchPoint(UIElement relativeTo)Retrieves the TouchPoint representing the first finger that touched the screen. A UIElement can be specified to make the TouchPoint object’s Position property relative to that element. If a UIElement is not specified (it is null), the returned TouchPoint is relative to the top left of the page.

Image GetTouchPoints(UIElement relativeTo)Retrieves the collection of TouchPoints for the frame. The UIElement parameter works the same as the GetPrimaryTouchPoint. The parameter does not restrict the set of TouchPoints returned; all are returned and only the Position of each TouchPoint is affected.

Image SuspendMousePromotionUntilTouchUp()Prevents touch events from turning into mouse events. See the following section for a more detailed explanation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.47.25