WPF multi-touch Development: Inertia effects (inertia)

Source: Internet
Author: User
Keywords initial 1000 can through this
Tags added code development example moving multi-touch name screen

From the previous example, you can see that if you move your finger away from the screen while the picture is moving, the picture stops immediately, in which case WPF provides another inertia effect (inertia). It allows the UI unit to move more physically, more realistically, and more smoothly.

On the basis of the preceding code, additional manipulationinertiastarting events need to be added for <Canvas>.

<canvas x:name= "TouchPad" background= "Gray"
Manipulationstarting= "Image_manipulationstarting"
Manipulationdelta= "Image_manipulationdelta"
Manipulationcompleted= "Image_manipulationcompleted"
manipulationinertiastarting= "Image_manipulationinertiastarting" >

Image_manipulationinertiastarting event content as follows code, respectively, Translationbehavior, Expansionbehavior, rotationbehavior settings, So that it has inertia characteristics.

private void Image_manipulationinertiastarting (object sender,
Manipulationinertiastartingeventargs e)
{
E.translationbehavior = new Inertiatranslationbehavior ();
e.translationbehavior.initialvelocity = e.initialvelocities.linearvelocity;
e.translationbehavior.desireddeceleration = 10.0 * 96.0/(1000.0 * 1000.0);

E.expansionbehavior = new Inertiaexpansionbehavior ();
e.expansionbehavior.initialvelocity = e.initialvelocities.expansionvelocity;
E.expansionbehavior.desireddeceleration = 0.1 * 96/1000.0 * 1000.0;

E.rotationbehavior = new Inertiarotationbehavior ();
e.rotationbehavior.initialvelocity = e.initialvelocities.angularvelocity;
E.rotationbehavior.desireddeceleration = 720/(1000.0 * 1000.0);
Program Demo

The following video can be seen in the manipulation, the picture has an inertial effect.

Related articles

1. WPF multi-touch Development: Windows 7 installs multi-touch screen simulator
2. WPF multi-touch Development: Basic touchscreen operation (Raw Touch)
3. WPF multi-touch Development: Advanced Touch screen operation (manipulation)

SOURCE Download: Wpfinertia.zip
Related Article

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.