我正在尝试通过跟随手指手势来移动时针。我为此使用 SkiaSharp 。我陷入了将时针附加到手指手势动作上的问题。
我在Touch_Handle方法下面,点击了以下函数并执行了所有操作,但是触摸时时钟(当前至少尝试移动时钟)没有动。
Xaml:
<Grid>
<skia:SKCanvasView
x:Name="canvasView"
EnableTouchEvents="true"
Touch="Handle_Touch"
PaintSurface="OnCanvasViewPaintSurface" />
</Grid>
Xaml.cs
private void Handle_Touch(object sender, SKTouchEventArgs args)
{
SKPoint point = args.Location;
switch (args.ActionType)
{
case SKTouchAction.Pressed:
if (!inProgressPaths.ContainsKey(args.Id))
{
SKPath path = new SKPath();
path.MoveTo(args.Location);
inProgressPaths.Add(args.Id, path);
((SKCanvasView)sender).InvalidateSurface();
}
break;
case SKTouchAction.Moved:
if (inProgressPaths.ContainsKey(args.Id))
{
SKPath path = inProgressPaths[args.Id];
path.LineTo(args.Location);
((SKCanvasView)sender).InvalidateSurface();
}
break;
case SKTouchAction.Released:
if (inProgressPaths.ContainsKey(args.Id))
{
completedPaths.Add(inProgressPaths[args.Id]);
inProgressPaths.Remove(args.Id);
((SKCanvasView)sender).InvalidateSurface();
}
break;
case SKTouchAction.Cancelled:
if (inProgressPaths.ContainsKey(args.Id))
{
inProgressPaths.Remove(args.Id);
((SKCanvasView)sender).InvalidateSurface();
}
break;
}
// we have handled these events
args.Handled = true;
}