处理刷卡手势语在Windows 8中网格 [英] Handling Swipe Guesture in Windows 8 Grid

查看:166
本文介绍了处理刷卡手势语在Windows 8中网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现它由一些帆布元素作为孩子,当刷卡动作对电网做了一个网格的自定义控制,我打算瓶坯与画布元素的一些操作。
我无法处理电网轻扫,我已经张贴在
MSDN - Win8的开发论坛

I am trying to implement a custom control which consists of a grid with some canvas elements as children , When a swipe action is made on the grid , I am intended to preform some operation with the canvas elements . I am unable to handle the swipe for the grid , i have posted the same in the msdn - win8 Dev forum

推荐答案

我是在同一条船上,你们这些家伙,因为有在那里对这个是怎么做的没有样品,但仔细阅读和审查上滑动手势如何在Windows中实现的MSDN文档后使用C#8商店应用,这就是我想出了(和它的作品对我的应用程序,它需要刷卡上/下/左/右):

I was in the same boat as you guys, since there was no samples out there on how this was done, but after perusing and scrutinizing the MSDN documentation on how a swipe gesture is implemented on a Windows 8 Store app using C#, this is what i came up with (and it works for my app which requires swiping up / down / left / right):

首先,而不是GestureRecognizer,操作事件需要使用,所以对电网要办理刷卡(让'说,你让这个需要整个屏幕,以便它解释手势)执行以下操作:

First of all, instead of the GestureRecognizer, the Manipulation events need to be used, so on the grid that you want to handle the swiping (lets' say you make it so that it takes the whole screen so it interprets the gestures) do the following:

我叫我的网 swipingSurface ,我处理这两个Y轴和X轴的操作模式:

I called my grid swipingSurface and i'm handling manipulation modes for both the Y-axis and X-axis:

swipingSurface.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;



然后线了,你想被通知的操纵事件,在我来说,我只是想知道那么操作开始和结束的:

Then wire up the manipulation events that you want to be notified, in my case i just want to know then the manipulation started and when it ended:

swipingSurface.ManipulationStarted += OnManipulationStarted;
swipingSurface.ManipulationCompleted += OnManipulationCompleted;



做你想做你的操作开始,如获取初始点,如果你想。但实际的诀窍是在ManipulationCompleted事件,其中你需要得到流速从你的姿势导致,具体如下:

Do whatever you want on your manipulation started, such as getting the initial point if you want. But the actual trick is on the ManipulationCompleted event, in which you need to get the Velocities resulting from your gesture, as follows:

public void OnManipulationCompleted(object sender, ManipulationCompletedEventArgs e) {
    var velocities = e.Velocities;      
}



ManipulationCompletedEventArgs 流速属性将带回一个struct类型的 ManipulationVelocities ,其中包含内的其他属性:

The ManipulationCompletedEventArgs Velocities property will bring back a struct of type ManipulationVelocities, which contains other properties inside:

- 的:每毫秒度的旋转速度。

-Angular: The rotational velocity in degrees per millisecond.

- 扩展的:扩展或缩放,速度在每毫秒的DIP

-Expansion: The expansion, or scaling, velocity in DIPs per millisecond.

- 线性的:直线速度在每毫秒的DIP

-Linear: The straight line velocity in DIPs per millisecond.

实际上,我在看的线性速度,这是一个包含指示其执行手势的方向X和Y值;例如,如果刷卡是向上的,你会发现,在Y值是正的,如果它下来的Y值是负的;同样的问题也作为X值,如果刷卡是左中,X值是负的,如果刷卡是正确的,在X值是正的,这样你就可以使用这些值玩耍并检查您的刷卡方向,最终积分等

I'm actually looking at the Linear velocity, which is a Point that contains X and Y values indicating the direction in which the gesture was performed; for example, if the swipe was upward, you will notice that the Y value is positive, and if its down the Y value is negative; the same goes for the X value, if the swipe is left, the X values are negative and if the swipe is right, the X values are positive, so you can play around with those values and check your swiping direction, final points, etc.

希望这有助于。

这篇关于处理刷卡手势语在Windows 8中网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆