bool値を返すメソッドがありますが、戻りたい値はタイマーの経過イベントに設定されているため、System.Timers.Timerが経過イベントを発生させるまで値を返すまで待つ必要があります。
public static bool RecognizePushGesture()
{
List<Point3D> shoulderPoints = new List<Point3D>();
List<Point3D> handPoints = new List<Point3D>();
shoulderPoints.Add(Mouse.shoulderPoint);
handPoints.Add(Mouse.GetSmoothPoint());
Timer dt = new Timer(1000);
bool click = false;
dt.Elapsed += (o, s) =>
{
shoulderPoints.Add(Mouse.shoulderPoint);
handPoints.Add(Mouse.GetSmoothPoint());
double i = shoulderPoints[0].Z - handPoints[0].Z;
double j = shoulderPoints[1].Z - handPoints[1].Z;
double k = j - i;
if (k >= 0.04)
{
click = true;
dt.Stop();
}
};
dt.Start();
//should wait with returning the value until timer raises elapsed event
return click;
}
ありがとう、ティム