Finger Dance (I): My theory of multi-touch in WP7

Source: Internet
Author: User
Tags silverlight

Unlike the WM system, WP7 uses capacitive screens and supports multi-touch. I thought it was self-built with multi-touch, but after trying, I found that the system was not automatically implemented. Instead, programmers must implement it on their own. After several days of exploration. I have some knowledge about multi-touch.

After several days of exploration, we found several ways to achieve touch. Note: It is a touch. Do not add more points. One is Silverlight's low-level touch screen events, which are similar to low-level events on xNa. In addition, there are three processing events of the uielement class in the higher level: manipulationstarted, manipulationdelta, and manipulationcompleted.

Let's talk about the basic knowledge of contacts:

Multi-point touch allows multiple fingers to touch the screen at the same time. Each finger (the maximum number of fingers) on the screen is a touch point. The main touch point refers to the finger that touches the screen without other fingers touching the screen without pressing the mouse button.

Touch the screen with one finger. This is the main touch point. When the first finger is still touching the screen, place the second finger on the screen. Obviously, the second finger is not the main touch point. But now I still put the second finger on the screen, raised the first finger, and then put it back on the screen. Is this the main touch point? No, none of them. The main touch point only appears when no other finger touches the screen.

The primary touch point maps to a touch point that is not promoted to the mouse. In actual multi-touch applications, you should be careful not to rely on the main touch points, because users usually do not pay attention to the specific meaning of the first touch.


(1) Silverlight low-level touch screen events

This event registers a touch framereported event: (you can register it in pageloaded)

Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);


Then, use touch_framereported to handle contacts:

Void touch_framereported (Object sender, touchframeeventargs ARGs) {// The first finger contact point, that is, the main touch point touchpoint primarytouchpoint = args. getprimarytouchpoint (null); // this time is not allowed to be promoted to a mouse event, that is, when processing touch, if (primarytouchpoint! = NULL & primarytouchpoint. Action = touchaction. Down) {args. suspendmousepromotionuntiltouchup ();}}

In the touchpoint of the code above, a member is a touchdevice member with an ID. This shows that the current one is touched by that finger, that is, if one finger is placed on the screen, an ID will be generated once, And the ID will be destroyed once it is left. Generally, the ID of the main touch point is 0, and the ID generated by the second finger is 1 and the third is 2. If both are left, the count starts from 0.

All the touch points can be obtained here, not just the main touch points. The returned result is the touchpointcollection.

TouchPointCollection touchPoints = arg.GetTouchPoints(null);


By querying the touchpoint, We can get all the information about the touch point. For example, if there is an action Member, we can know whether the finger is moving or pressing or raising it. Position allows you to know the coordinates of your fingers on the screen. Through ID, you can know which contacts start with the same finger.


In addition, this framereported registration event is for the program, not for the page. If you want to not use these touch methods on other pages, you can cancel the registration event when the page leaves.


(2) Silverlight Advanced event-the manipulation event of uielement.

Manipulationstarted, manipulationdelta, and manipulationcompleted are the three events. In short, the first is the start, that is, the start touch, and the second is the drag, which is equivalent to touchpoint. Action = touchaction. Move. The third is stop, that is, the finger leaves the screen. These three events are easy to use. Unlike low-level touch screens that handle events. You have to determine which control touchpoint. touchdevice. directlyover is. However, after multiple tests (real machine test, HTC
T8788), it is found that this so-called Advanced event only accepts the first contact, that is, the main touch point. If it is not the main touch point, it will not work. However, according to Microsoft's practice, advanced events are actually the encapsulation of low-level events, and it is impossible to support multi-touch. There is no detailed explanation for viewing the Internet. It means that the implementation of multi-point and single point is only the difference in processing parameters. If anyone knows, please give an example. Thank you!

However, these three events are convenient to handle the touch of controls, special touch actions, and other special things.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.