繁体   English   中英

WPF 4触摸事件获得捏手势的中心

[英]WPF 4 touch events getting the center of a pinch gesture

我正在使用.net 4 beta 2触摸库,我试图在我的WPF应用程序中实现缩放功能。

我可以让缩放工作正常,但我想要的是放大捏手势的中心,我在API中看不到有关如何实现这一点的任何内容。

是否有一些方法或属性暴露了在捏手势中使用的2个联系人,以便我可以获得它们的中心?

编辑:

我刚刚调查使用TouchEventArgsGetIntermediateTouchPoints方法,它似乎没有给我我想要的东西。

非常感谢马克

这个答案适用于.Net 4发布版本。

在使用ManipulationDelta事件的情况下, ManipulationDeltaEventArgs.ManipulationOrigin包含捏合手势的中心点。 坐标相对于ManipulationDeltaEventArgs.ManipulationContainer ,可以在ManipulationStarting事件的处理程序中设置。

示例代码:

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;
    ...
}

假设您正在使用新的TouchXxxxEvent路由事件,它们都采用具有TouchDevice属性的TouchEventArgs 如果调用其GetTouchPoint()方法,则可以获得代表触摸点的TouchPoint

Jaime Rodriguez的更多细节和示例代码

事实证明,我所追求的属性一直都在我面前。

Manipulation2DDeltaEventArgs类具有OriginXOriginX属性,这些属性特定于捏手势的中心点,所以我只是使用它并且它的一切都很好:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM