WPF multi-touch Development: Inertia effects (inertia)

Source: Internet
Author: User
Tags touch

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, Make it have the inertia characteristic.

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.

Video Address: http://static.youku.com/v1.0.0122/v/swf/qplayer.swf?VideoIDS=XMTk4MjUyNDAw&embedid= Mti1ljy5lje0nc4zngi0otu2mzewmaj3d3cuy25ibg9ncy5jb20cl2duawvszwuvyxjjagl2zs8ymdewlza4lze5l211bhrplxrvdwnolwluzxj0aweuahrtb A==&showad=0

SOURCE Download Address: http://public.blu.livefilestore.com/y1pA8pt32bGc_1znfRppqLoDSS7hKRAougUyNOv2NOkG_ N-ea4vzyytwkokn5xc7e3abor2yywwr1cbutogq3mpgg/wpfinertia.zip?download&psid=1



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.