Exemplo n.º 1
0
        void DrawOutline(SKPaintSurfaceEventArgs e)
        {
            var imageInfo = e.Info;
            var canvas    = e?.Surface?.Canvas;

            using (var outline = new SKPaint
            {
                Style = SKPaintStyle.Stroke,
                Color = OutlineColor.ToSKColor(),
                StrokeWidth = OutlineWidth,
                StrokeJoin = SKStrokeJoin.Round,
                IsAntialias = true
            })
            {
                var shape = Design == Design.Unified ? Shape : DEFAULT_SHAPE;
                if (shape == Shape.Circle)
                {
                    canvas.DrawCircle(imageInfo.Width / 2, imageInfo.Height / 2, (imageInfo.Width / 2) - (OutlineWidth / 2), outline);
                }
                else
                {
                    var cornerRadius = Design == Design.Native && Device.RuntimePlatform == Device.UWP ? 0 : OutlineWidth;
                    canvas.DrawRoundRect(OutlineWidth, OutlineWidth, imageInfo.Width - (OutlineWidth * 2), imageInfo.Height - (OutlineWidth * 2), cornerRadius, cornerRadius, outline);
                }
            }
        }
Exemplo n.º 2
0
    protected virtual void OnPaintSurface(object sender, SKPaintSurfaceEventArgs e)
    {
        SKImageInfo info    = e.Info;
        SKSurface   surface = e.Surface;
        SKCanvas    canvas  = surface.Canvas;

        canvas.Clear();
        SKPaint primaryFill = new SKPaint
        {
            Style = SKPaintStyle.Fill,
            Color = animatedBgColor != null ? animatedBgColor.Value : IsToggled?ToggledBackgroundColor.ToSKColor() : SwitchBackgroundColor.ToSKColor(),
                        IsAntialias = true
        };
        SKPaint primaryOutline = new SKPaint
        {
            Style       = SKPaintStyle.Stroke,
            StrokeWidth = 2,
            Color       = OutlineColor.ToSKColor(),
            IsAntialias = true
        };
        SKPaint circleFill = new SKPaint
        {
            Style       = SKPaintStyle.Fill,
            Color       = ButtonFillColor.ToSKColor(),
            IsAntialias = true
        };
        SKPaint circleOutline = new SKPaint
        {
            Style       = SKPaintStyle.Stroke,
            StrokeWidth = 2,
            Color       = OutlineColor.ToSKColor(),
            IsAntialias = true
        };
        SKRoundRect rect        = new SKRoundRect(new SKRect(0, 0, 120, 60), 30, 30);
        SKRoundRect rectOutline = new SKRoundRect(new SKRect(1, 1, 119, 59), 28, 28);

        if (!isAnimating)
        {
            buttonPosition.X = IsToggled ? 90f : 30f;
        }
        canvas.DrawRoundRect(rect, primaryFill);
        canvas.DrawRoundRect(rectOutline, primaryOutline);
        canvas.DrawCircle(buttonPosition, 24, circleFill);
        canvas.DrawCircle(buttonPosition, 23, circleOutline);
    }
Exemplo n.º 3
0
        void DrawOutline(SKPaintSurfaceEventArgs e)
        {
            var imageInfo = e.Info;
            var canvas    = e?.Surface?.Canvas;

            using (var outline = new SKPaint
            {
                Style = SKPaintStyle.Stroke,
                Color = OutlineColor.ToSKColor(),
                StrokeWidth = OutlineWidth,
                StrokeJoin = SKStrokeJoin.Round,
                IsAntialias = true
            })
            {
                if (Shape == Shape.Circle)
                {
                    canvas.DrawCircle(imageInfo.Width / 2, imageInfo.Height / 2, (float)((imageInfo.Width / 2) - (OutlineWidth / 2)), outline);
                }
                else
                {
                    canvas.DrawRoundRect(OutlineWidth, OutlineWidth, imageInfo.Width - (OutlineWidth * 2), imageInfo.Height - (OutlineWidth * 2), OutlineWidth, OutlineWidth, outline);
                }
            }
        }