Windows Phone (17) manipulationdelta event

Source: Internet
Author: User

The manipulationdelta event is triggered when the touch position changes. For example, you can change the image position based on the position where the user moves on the touch screen, to zoom in and out the image. The use case here is

<! -- Contentpanel-place other content here --> <grid X: Name = "contentpanel" grid. row = "1" margin = "12, 0, 12, 0"> <Image Source = "1.jpg" X: name = "imgscale" width = "200" Height = "200" manipulationdelta = "imgscale_manipulationdelta"> </image> </GRID>

Effect:

 

From the above we can see that we reference an image and set the manipulationdelta event. The implementation of this event is:

Private void imgscale_manipulationdelta (Object sender, manipulationdeltaeventargs e) {image els = sender as image; compositetransform Ct = new compositetransform (); Ct. translatex = 0; If (E. deltamanipulation. scale. x! = 0 | E. deltamanipulation. Scale. y! = 0) {double maxone = math. max (E. deltamanipulation. scale. y, E. deltamanipulation. scale. x); Ct. scalex * = maxone; Ct. scaley * = maxone;} // E. isinertial this. pagetitle. TEXT = "Move, X:" + E. manipulationorigin. x. tostring () + "\ NY:" + E. manipulationorigin. y. tostring (); Ct. translatex = E. deltamanipulation. translation. x; Ct. translatey = E. deltamanipulation. translation. y; els. rendertransform = CT; E. handled = true ;}

The above code despise: Get the ellipse object that has been used in the XAML, instantiate a new compositetransform object, and determine whether the scaling ratio is null. If not, determine which proportion is large on the X axis and Y axis, take the greater one as the scaling ratio, and then implement the corresponding displacement. Here we use the following knowledge points:

 

Sender as [element class] gets the element of this event

 

 

E. deltamanipulation for recent changes

 

E. deltamanipulation. scale official: Get the amount adjusted by the operation as the multiplier (my understanding: Get the moving value and use it as the zoom-in ratio), you can continue to point out the corresponding X, Y value

E. deltamanipulation. Translation: obtains the size of moving by touch. You can continue to point out the corresponding x and y values.

 

E. manipulationorigin obtains the start point of the operation. You can continue to calculate the corresponding x and y values.

 

E. isinertial: determines whether it occurs during inertial motion.
Manipulationdelta event, introduced in the previous article, you will find that a lot of text will exceed the area that the text can bear. At this time, you can determine that the text transformation effect is far beyond the real area. If it exceeds, then E. complete (); ends the touch event

E. cumulativemanipulation obtains accumulative operation changes, similar to historical records.

E. manipulationcontainer: the container that obtains the coordinates of the Operation definition, and the sender as [element class]. For example, the container of the Code listed above is an image

 

If you move the mouse horizontally to the right, the effect is:

 

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.