为 Surface 控件的 OnContactDown 事件添加延迟
我们使用 Controls.PreviewContactDown、PreviewContactUp 和 PreviewContactChanged 事件来捕获在 Surface 上放置、移除和移动的标记项目,这在 Surface 附带的模拟器应用程序中效果很好。
在实际的 Surface 上,如果您移动标记的项目太快,相机实际上会失去标记的焦点,假设它已被删除,然后在它停止移动时重新捕获它。这为我们的客户提供了非常糟糕的体验。
我建议的是一种覆盖或创建一个新事件的方法,该事件将响应标记的项目事件,但直到延迟后才触发事件处理程序...即,如果触发“ContactUp”,则等待 100 毫秒,然后执行事件处理程序。理想情况下,我们只能使用备用附加属性来定义这些事件处理程序,即
<Panel local:TagDown="TagDownEventHandler" />
如果我们可以让它使用 ICommand 对象而不是事件处理程序,那就更好了。
We're using the Controls.PreviewContactDown, PreviewContactUp, and PreviewContactChanged events to capture tagged items being placed, removed, and moved on the Surface, which works great in the Simulator application that comes with the surface.
On an actual Surface if you moved a tagged item too quickly the cameras actually lose focus of the tag, assume it was removed, and then re-capture it when it stops moving. That provides a pretty poor experience for our clients.
What I'm proposing is a way to override or create a new event that would respond to tagged item events, but not fire the event handler until after a delay... i.e. if "ContactUp" is fired, wait 100ms and THEN execute the event handler. Ideally we'd just be able to use an alternate attached property to define these event handlers, i.e.
<Panel local:TagDown="TagDownEventHandler" />
And if we could get it to use ICommand objects instead of event handlers that'd be even better.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只使用 TagVisualizer 怎么样?这已经通过在视觉效果从屏幕上删除之前为您提供默认的淡出动画来处理标签丢失/找到的情况。
用手指做同样的事情更困难,因为一旦失去接触,原始接触和新接触之间就不再有联系。
How about just using the TagVisualizer? This already handles tag lost/found by giving you a default fade out animation before the visual is removed from screen.
Its harder to do the same thing with fingers because once the contact is lost there is no connection between the original contact and the new one.
我们在真实的 Surface 和接触事件中发现了同样的情况。
我们所做的(这取决于您的需求)是为“联系人容器”创建一个基类,它有自己的处理 ContactUp 的方法,我们在其中触发一个带有一组包含对象/标签的 eventArgs 的计时器正在删除并将其添加到列表中。如果计时器计时,那么我们从容器和排队列表中删除对象/标签。
当 contactDown 触发时,我们确认队列中没有匹配的对象,如果有,我们停止计时器并将其从队列中删除并忽略新标签,因为它仍然在容器中。如果没有,那么我们将处理放置的新标签。
我们仍在调整代码以确保其稳健性,一旦可以的话,我会将解决方案发布在 Codeplex 上。
华泰
We found the same thing with the real Surface and the contact events.
What we did (and this will depend on your needs) is to create a base class for a "contact container", which has it's own method of handling ContactUp where we fire off a timer with a set of eventArgs that contain the object/tag that is being removed and add it to a list. If the timer ticks, then we remove the object/tag from the container and the queued list.
When the contactDown fires, we confirm there's no matching object in the queue, if there is we stop the timer and remove it from the queue and ignore the new tag, as it's still already in the container. If not then we handle the new tag being placed.
We're still tweaking the code to ensure its robust, once it is if I can I'll post the solution on Codeplex.
HTH