开发者

Add a delay to OnContactDown events for Surface controls

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. 开发者_StackOverflow社区

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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜