WPF 4 touch events receiving the center of a hard gesture

I am using .net 4 beta 2 touch screen libraries, and Im trying to implement the zoom function in my WPF application.

I can make scaling work fine, but I want to zoom in pinch gestures, and I don't see anything in the API on how to do this.

Are there any methods or properties that show the two contacts that are used in the pinch gesture so that I can get their center?

EDIT:

I just explored using the GetIntermediateTouchPoints TouchEventArgs method, which didn't seem to give me what I want.

Thanks a lot Mark

+4
source share
3 answers

It turns out that the properties that I was after were right in front of me.

The Manipulation2DDeltaEventArgs class has the OriginX and OriginX properties that define the center point of the pinch gestures, so Im just using this and all this is good :)

0
source

Assuming you are using the new TouchXxxxEvent routed events, they all accept TouchEventArgs , which has TouchDevice . If you call the GetTouchPoint() method, you can get a TouchPoint that represents the touch point.

More details and sample code from Jaime Rodriguez.

0
source

This answer is for .Net 4 version.

In the case of using the ManipulationDelta event, ManipulationDelta contains the center point of the hard pinch. Coordinates refer to ManipulationDeltaEventArgs.ManipulationContainer , which can be set in the ManipulationStarting event handler.

Code example:

 private void object_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { ... // If this was a multitouch gesture // (like pinch/zoom - indicated by e.DeltaManipulation.Scale) // the following line will get us point between fingers. Point position = e.ManipulationOrigin; ... } 
0
source

Source: https://habr.com/ru/post/1298983/


All Articles