私は最初にあなたを写真に入れようとしています.WPF4 VS2010でジェスチャを実装しようとしています.同じ指ですでに通り過ぎたタッチポイントを横切るまで指を動かすようなものなので、私の考えはリストを作成し、存在する場合はすべての新しいタッチポイントをチェックし、存在する場合はジェスチャを完了し、そうでない場合はコレクションにタッチポイントを追加して、次のタッチポイントと比較します。何らかの理由でこれがうまくいかないので、別のアプローチに移り、TouchPoints を TouchPoint の X 、 Y に置き換え、それらを文字列に変換し、TouchMove および TouchUp イベントを使用して、それらに対して Contains メソッドを使用しようとしました。私のコードは次のようになります。
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;
}
そのため、テストすると機能しません。タッチを直線で動かしても背景が変わります。何か案は ?
前もって感謝します