Windows Mobile 6.5 Gesture API 介绍
2010-06-01 22:53:00 来源:WEB开发网gestureRecognizer1.Hold += new EventHandler(gestureRecognizer1_Hold);
gestureRecognizer1.Select += new EventHandler(gestureRecognizer1_Select);
gestureRecognizer1.DoubleSelect += new EventHandler(gestureRecognizer1_DoubleSelect);
gestureRecognizer1.Pan += new EventHandler(gestureRecognizer1_Pan);
gestureRecognizer1.Scroll += new EventHandler(gestureRecognizer1_Scroll);
}
void gestureRecognizer1_Scroll(object sender, GestureScrollEventArgs e)
{
label1.Text = e.Kind.ToString() + ": " + e.State + ", (" + e.X + ", " + e.Y + "), d=" + e.ScrollDirection + ", a=" + e.Angle + ", v=" + e.Velocity;
}
void gestureRecognizer1_Pan(object sender, GestureEventArgs e)
{
label1.Text = e.Kind.ToString() + ": " + e.State + ", (" + e.X + ", " + e.Y + ")";
}
void gestureRecognizer1_DoubleSelect(object sender, GestureEventArgs e)
{
label1.Text = e.Kind.ToString() + ": " + e.State + ", (" + e.X + ", " + e.Y + ")";
}
void gestureRecognizer1_Select(object sender, GestureEventArgs e)
{
label1.Text = e.Kind.ToString() + ": " + e.State + ", (" + e.X + ", " + e.Y + ")";
}
void gestureRecognizer1_Hold(object sender, GestureEventArgs e)
{
label1.Text = e.Kind.ToString() + ": " + e.State + ", (" + e.X + ", " + e.Y + ")";
}
该示例代码是在窗体上放了两个控件: Panel1用来捕获手势事件;label1用来显示当前手势的一些参数。 运行状况如下图所示:
最后一部分,是demo程序的源代码:GestureDemo2.zip (58.05 kb)
看到了吧,在Windows Mobile 6.5中,我们要给我们的程序加上手势的支持是如此的简单方便。好了,本小节就到这里,在下一节中我们将讨论手势和动画。
更多精彩
赞助商链接