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

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

            using (var checkPath = new SKPath())
            {
                checkPath.MoveTo(.275f * imageInfo.Width, .5f * imageInfo.Height);
                checkPath.LineTo(.425f * imageInfo.Width, .65f * imageInfo.Height);
                checkPath.LineTo(.725f * imageInfo.Width, .375f * imageInfo.Height);

                using (var checkStroke = new SKPaint
                {
                    Style = SKPaintStyle.Stroke,
                    Color = CheckColor.ToSKColor(),
                    StrokeWidth = (float)OutlineWidth,
                    StrokeCap = SKStrokeCap.Round,
                    IsAntialias = true
                })
                {
                    canvas.DrawPath(checkPath, checkStroke);
                }
            }
        }
Ejemplo n.º 2
0
        void DrawCheckFilled(SKPaintSurfaceEventArgs e)
        {
            var imageInfo = e.Info;
            var canvas    = e?.Surface?.Canvas;

            using (var checkfill = new SKPaint
            {
                Style = SKPaintStyle.Fill,
                Color = FillColor.ToSKColor(),
                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), checkfill);
                }
                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, checkfill);
                }
            }

            using (var checkPath = new SKPath())
            {
                if (Design == Design.Unified)
                {
                    checkPath.MoveTo(.275f * imageInfo.Width, .5f * imageInfo.Height);
                    checkPath.LineTo(.425f * imageInfo.Width, .65f * imageInfo.Height);
                    checkPath.LineTo(.725f * imageInfo.Width, .375f * imageInfo.Height);
                }
                else
                {
                    switch (Device.RuntimePlatform)
                    {
                    case Device.iOS:
                        checkPath.MoveTo(.2f * imageInfo.Width, .5f * imageInfo.Height);
                        checkPath.LineTo(.375f * imageInfo.Width, .675f * imageInfo.Height);
                        checkPath.LineTo(.75f * imageInfo.Width, .3f * imageInfo.Height);
                        break;

                    case Device.Android:
                        checkPath.MoveTo(.2f * imageInfo.Width, .5f * imageInfo.Height);
                        checkPath.LineTo(.425f * imageInfo.Width, .7f * imageInfo.Height);
                        checkPath.LineTo(.8f * imageInfo.Width, .275f * imageInfo.Height);
                        break;

                    case Device.UWP:
                        checkPath.MoveTo(.15f * imageInfo.Width, .5f * imageInfo.Height);
                        checkPath.LineTo(.375f * imageInfo.Width, .75f * imageInfo.Height);
                        checkPath.LineTo(.85f * imageInfo.Width, .25f * imageInfo.Height);
                        break;

                    default:
                        break;
                    }
                }

                using (var checkStroke = new SKPaint
                {
                    Style = SKPaintStyle.Stroke,
                    Color = CheckColor.ToSKColor(),
                    StrokeWidth = OutlineWidth,
                    IsAntialias = true
                })
                {
                    checkStroke.StrokeCap = Design == Design.Unified ? SKStrokeCap.Round : SKStrokeCap.Butt;
                    canvas.DrawPath(checkPath, checkStroke);
                }
            }
        }