private void DrawSKCanvasView_PaintSurface(object sender, SKPaintSurfaceEventArgs e) { SkiaSharpHelper.Draw(drawType, pageVM.IsClear, e); }
private void OnTouch (object sender, TouchTracking.TouchActionEventArgs args) { // Convert touch point to pixel point _touch.Current = SkiaSharpHelper.ToPixel(args.Location.X, args.Location.Y, ref thumbsCanvas); // Check bounds if (_touch.Current.X < _thumbsCanvasInfo.ImageInfo.Rect.Left || _touch.Current.X > _thumbsCanvasInfo.ImageInfo.Rect.Right) { return; } // Check touch type switch (args.Type) { case TouchActionType.Pressed: _touch.Matrix = SKMatrix.MakeIdentity(); // Adjust thumbs bounds _leftThumbDraw.Bounds = new SKRect (_leftThumbDraw.Point.X - _leftThumbDraw.Radius, _leftThumbDraw.Point.Y - _leftThumbDraw.Radius , _leftThumbDraw.Point.X + _leftThumbDraw.Radius, _leftThumbDraw.Point.Y + _leftThumbDraw.Radius); _rightThumbDraw.Bounds = new SKRect (_rightThumbDraw.Point.X - _rightThumbDraw.Radius, _rightThumbDraw.Point.Y - _rightThumbDraw.Radius , _rightThumbDraw.Point.X + _rightThumbDraw.Radius, _rightThumbDraw.Point.Y + _rightThumbDraw.Radius); // Check if the inner circle was touched if (_leftThumbDraw.Bounds.Contains(_touch.Current) && _rightThumbDraw.Bounds.Contains(_touch.Current)) { _touch.Id = args.Id; _touch.Previous = _touch.Current; _activeThumb = _lastActiveThumb; } else if (_leftThumbDraw.Bounds.Contains(_touch.Current)) { _touch.Id = args.Id; _touch.Previous = _touch.Current; _activeThumb = ActiveThumb.Left; } else if (_rightThumbDraw.Bounds.Contains(_touch.Current)) { _touch.Id = args.Id; _touch.Previous = _touch.Current; _activeThumb = ActiveThumb.Right; } break; case TouchActionType.Moved: if (_touch.Id == args.Id) { // Adjust the matrix for the new position _touch.Matrix.TransX += _touch.Current.X - _touch.Previous.X; _touch.Matrix.TransY += _touch.Current.Y - _touch.Previous.Y; _touch.Previous = _touch.Current; var value = GetThumbValue(_touch.Current); // Check active thumb if (_activeThumb == ActiveThumb.Left) { Thumbs.Left.Value = value; Start = value; } else if (_activeThumb == ActiveThumb.Right) { Thumbs.Right.Value = value; End = value; } // Update value thumbsCanvas.InvalidateSurface(); } break; case TouchActionType.Released: case TouchActionType.Cancelled: { _touch.Id = -1; _lastActiveThumb = _activeThumb; } break; } }
private void DrawSKCanvasView_PaintSurface(object sender, SKPaintSurfaceEventArgs e) { SkiaSharpHelper.Draw(DrawType.CircleAnimation, false, e, scale); }
private void InitializePaints() { // Left thumb _leftThumbDraw.Paint = new SKPaint { Color = SKColors.White, IsAntialias = true }; _leftThumbDraw.ValueTextDraw.Paint = new SKPaint { Color = SKColors.Black, IsAntialias = true, }; _leftThumbDraw.IconTextDraw.Paint = new SKPaint { Color = SKColors.White, IsAntialias = true, Typeface = SkiaSharpHelper.LoadTtfFont(Fonts.Icons) }; // Right thumb _rightThumbDraw.Paint = new SKPaint { Color = SKColors.White, IsAntialias = true }; _rightThumbDraw.ValueTextDraw.Paint = new SKPaint { Color = SKColors.Black, IsAntialias = true }; _rightThumbDraw.IconTextDraw.Paint = new SKPaint { Color = SKColors.White, IsAntialias = true, Typeface = SkiaSharpHelper.LoadTtfFont(Fonts.Icons) }; // Thumbs shadow _leftThumbDraw.Paint.ImageFilter = _rightThumbDraw.Paint.ImageFilter = SKImageFilter.CreateDropShadow( 0, 0, 5, 5, SKColor.Parse("#EFEFEF"), SKDropShadowImageFilterShadowMode.DrawShadowAndForeground ); // Value segment _valueSegmentPaint = new SKPaint { Color = SKColors.Black, IsAntialias = true, }; // Remaining value segment _remainingValueSegmentPaint = new SKPaint { Color = SKColors.Gray, IsAntialias = true, }; }