简体   繁体   English

如何在Silverlight WP7中限制捏手势?

[英]How to limit Pinch gesture in Silverlight WP7?

I'm implementing the pinch gesture in my application using GestureListener in silverlight. 我在Silverlight中使用GestureListener在应用程序中实现捏手势。 The problem I'm running into is placing a limit on scaling that occurs when a user pinches an object. 我遇到的问题是对用户捏物体时发生的缩放进行限制。

In XNA it's pretty straighforward because everytime the update method is call you can check the scale of the object at its current point and determine wheter to increase, decrease, or do nothing with the object. 在XNA中,这很简单,因为每次调用update方法时,您都可以检查对象在其当前点的大小,并确定对对象进行增加,减少或什么都不做。

In Silverlight though I'm trying to check against a limit but my code is only running after the gesture is complete. 在Silverlight中,尽管我试图检查一个限制,但是我的代码仅在手势完成后才运行。 So the user still has the ability to scale past the limit I set and then it flickers back to the limited scale again after they release the pinch. 因此,用户仍然可以缩放超出我设置的限制,然后在松开捏合后,它会再次闪回到有限的缩放比例。 Anyone know how to impose a limit on the scaling? 有人知道如何对缩放比例施加限制吗?

There are three events involved in the pinch gesture: 捏手势涉及三个事件:

  • PinchStarted 捏开始
  • PinchDelta 品奇达
  • PinchCompleted 捏完成

Try handling the PinchDelta instead of PinchCompleted to get updates while the user is doing the gesture. 尝试在用户执行手势时处理PinchDelta而不是PinchCompleted以获得更新。 Then just refuse to make your object bigger. 然后只是拒绝使您的对象更大。

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

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