Forum Xamarin.Forms

Xamarin SkiaSharp Analog Clock rotate handle by following finger gesture

I am trying to move the hour hand in the clock by following finger gesture. I am using SkiaSharp for this. I am stuck. I have below Touch Handle, its hitting the function but nothing happening. Also I don't know how to attach hour hand to finger gesture movements using Skiasharp?

private void Handle_Touch(object sender, SKTouchEventArgs args)
        {           
            IntPtr obj = hourMarkPaint.Handle;
            SKPoint point = args.Location;
            //SKPoint point =
            //    new SKPoint((float)(canvasView.CanvasSize.Width * pt.X / canvasView.Width),
            //                (float)(canvasView.CanvasSize.Height * pt.Y / canvasView.Height));

            switch (args.ActionType)
            {
                case SKTouchAction.Pressed:
                    if (!inProgressPaths.ContainsKey(args.Id))
                    {
                        SKPath path = new SKPath();
                        path.MoveTo(args.Location);
                        inProgressPaths.Add(args.Id, path);
                        canvasView.InvalidateSurface();
                    }
                    break;

                case SKTouchAction.Moved:
                    if (inProgressPaths.ContainsKey(args.Id))
                    {
                        SKPath path = inProgressPaths[args.Id];
                        path.LineTo(args.Location);
                        canvasView.InvalidateSurface();
                    }
                    break;

                case SKTouchAction.Released:
                    if (inProgressPaths.ContainsKey(args.Id))
                    {
                        completedPaths.Add(inProgressPaths[args.Id]);
                        inProgressPaths.Remove(args.Id);
                        canvasView.InvalidateSurface();
                    }
                    break;

                case SKTouchAction.Cancelled:
                    if (inProgressPaths.ContainsKey(args.Id))
                    {
                        inProgressPaths.Remove(args.Id);
                        canvasView.InvalidateSurface();
                    }
                    break;
            }
        }

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Could you please post a basic demo?

Sign In or Register to comment.