【发布时间】:2010-12-25 15:27:37
【问题描述】:
我试图首先让你进入画面,我试图在 WPF4 VS2010 中实现一个手势,就像你移动你的手指直到它穿过你已经用相同的手指经过的接触点,所以我的想法是制作一个列表并检查每个新的接触点是否存在,如果是,那么你已经完成了你的手势,如果没有,那么将接触点添加到集合中以与以下接触点进行比较。出于某种原因,这不能很好地工作,所以我转向了另一种方法,用 X 替换 TouchPoints , Y 为 TouchPoint 并将它们转换为字符串并尝试对它们使用 Contains 方法,使用 TouchMove 和 TouchUp 事件我的代码看起来像:
private void g1_TouchMove(object sender, TouchEventArgs e)
{
if(touchX.Contains(""+e.GetTouchPoint(g1).Position.X) && touchY.Contains(""+e.GetTouchPoint(g1).Position.Y))
{
// Clearing the lists , changing the canvas background color to know that the gesture is done
touchX.Clear();
touchY.Clear();
g1.Background = Brushes.AliceBlue;
}
else
{
//adding new X, Y values to their respective lists
touchX.Add(""+e.GetTouchPoint(g1).Position.X);
touchY.Add( ""+e.GetTouchPoint(g1).Position.Y);
}
}
private void g1_TouchUp(object sender, TouchEventArgs e)
{
//clearing the lists after the touch is up (finger removed)
touchX.Clear();
touchY.Clear();
//getting the canvas it's original background color
g1.Background = Brushes.Orange;
}
所以,在测试它时它不起作用,即使我沿直线移动触摸它也会改变背景。有什么想法吗?
提前致谢
【问题讨论】:
标签: c# wpf string contains multi-touch