public override void DrawZoomView(RectF coverRect, RenderTarget rt, Brush fillBrush, Brush frameBrush, float strokeWidth)
        {
            Ellipse e = new Ellipse(coverRect.Center(), coverRect.Width / 2, coverRect.Width / 2);

            rt.FillEllipse(e, fillBrush);
            rt.DrawEllipse(e, frameBrush, strokeWidth);
        }
Exemple #2
0
        public virtual void DrawThumb(ICanvas canvas, RectF dirtyRect, ISlider slider)
        {
            canvas.SaveState();

            float size        = 28f;
            float strokeWidth = 0.5f;

            canvas.StrokeColor = slider.ThumbColor.WithDefault(DefaultCupertinoSliderThumbColor);
            canvas.StrokeSize  = strokeWidth;

            var value = (slider.Value / slider.Maximum - slider.Minimum).Clamp(0, 1);
            var x     = (float)((dirtyRect.Width * value) - (size / 2));

            if (x <= strokeWidth)
            {
                x = strokeWidth;
            }

            if (x >= dirtyRect.Width - (size + strokeWidth))
            {
                x = dirtyRect.Width - (size + strokeWidth);
            }

            var y = (float)((dirtyRect.Height - size) / 2);

            canvas.FillColor = slider.ThumbColor.WithDefault(slider.IsEnabled ? Cupertino.Color.Background.Light.Primary : Cupertino.Color.SystemGray.Light.InactiveGray);

            canvas.SetShadow(new SizeF(1, 1), 2, CanvasDefaults.DefaultShadowColor);

            touchTargetRect.Center(new PointF(x, y));

            canvas.FillEllipse(x, y, size, size);
            canvas.DrawEllipse(x, y, size, size);

            canvas.RestoreState();
        }
        public virtual void DrawThumb(ICanvas canvas, RectF dirtyRect, ISlider slider)
        {
            var MaterialFloatThumb = 12f;

            canvas.SaveState();

            var value = (slider.Value / slider.Maximum - slider.Minimum).Clamp(0, 1);
            var x     = (float)((dirtyRect.Width * value) - (MaterialFloatThumb / 2));

            if (x <= 0)
            {
                x = 0;
            }

            if (x >= dirtyRect.Width - MaterialFloatThumb)
            {
                x = dirtyRect.Width - MaterialFloatThumb;
            }

            var y = (float)((dirtyRect.Height - MaterialFloatThumb) / 2);

            if (slider.IsEnabled)
            {
                canvas.FillColor = slider.ThumbColor.WithDefault(Material.Color.Blue);
            }
            else
            {
                canvas.FillColor = slider.ThumbColor.WithDefault(Material.Color.Light.Gray1, Material.Color.Dark.Gray1);
            }

            touchTargetRect.Center(new PointF(x, y));

            canvas.FillEllipse(x, y, MaterialFloatThumb, MaterialFloatThumb);

            canvas.RestoreState();
        }
Exemple #4
0
        public void DrawThumb(ICanvas canvas, RectF dirtyRect, ISlider slider)
        {
            float size        = 38f;
            float strokeWidth = 0.5f;

            var value = slider.Value / slider.Maximum - slider.Minimum;
            var x     = (float)((dirtyRect.Width * value) - (size / 2));

            if (x <= strokeWidth)
            {
                x = strokeWidth;
            }

            if (x >= dirtyRect.Width - (size + strokeWidth))
            {
                x = dirtyRect.Width - (size + strokeWidth);
            }

            var y = (float)((dirtyRect.Height - size) / 2);

            canvas.SaveState();

            canvas.StrokeColor = Color.FromArgb("#4F01E0"); //slider.ThumbColor.WithDefault(Colors.Black.ToArgbHex());
            canvas.StrokeSize  = strokeWidth;

            var linearGradientPaint = new LinearGradientPaint
            {
                StartColor = Color.FromArgb("#B589D6"),
                EndColor   = Color.FromArgb("#552586")
            };

            linearGradientPaint.StartPoint = new Point(0, 0);
            linearGradientPaint.EndPoint   = new Point(0.8, 1.0);

            canvas.SetFillPaint(linearGradientPaint, new RectF(x, y, size, size)); //slider.ThumbColor.WithDefault(Colors.White.ToArgbHex());

            canvas.SetShadow(new SizeF(6, 6), 6, Color.FromArgb("#99330194"));

            touchTargetRect.Center(new PointF(x, y));

            canvas.FillRoundedRectangle(x, y, size, size, 6);

            canvas.RestoreState();

            canvas.SaveState();

            canvas.SetShadow(new SizeF(-6, -6), 6, Color.FromArgb("#999E27FF"));

            canvas.DrawRoundedRectangle(x, y, size, size, 6);

            canvas.RestoreState();

            canvas.RestoreState();

            float marginX = 3;
            float marginY = 13;

            canvas.Translate(x + marginX, y + marginY);

            var vBuilder = new PathBuilder();
            var path     = vBuilder.BuildPath("M6.0190067,0.16500799L7.4250088,1.5890061 3.9923439,4.979006 14.419033,4.979006 14.419033,6.9799988 3.699379,6.9799988 7.4300079,10.708995 6.015007,12.123994 0,6.1090004z M25.982016,0L32.001003,5.9430005 25.985983,11.958999 24.571004,10.543993 28.167773,6.9479963 18.027001,6.9479963 18.027001,4.9470035 28.144115,4.9470035 24.576009,1.4240091z");

            canvas.FillColor = Colors.White;
            canvas.FillPath(path);

            canvas.SaveState();
        }
        public virtual void DrawThumb(ICanvas canvas, RectF dirtyRect, ISlider slider)
        {
            // Thumb
            canvas.SaveState();

            var thumbSize   = 20f;
            var strokeWidth = 1f;

            var value = (slider.Value / slider.Maximum - slider.Minimum).Clamp(0, 1);

            stateDefaultValues.TryGetValue("TextSize", out var textSize);
            var x = (float)(((dirtyRect.Width - (float)textSize - TextMargin) * value) - (thumbSize / 2));

            if (x <= strokeWidth)
            {
                x = strokeWidth / 2;
            }

            if (x >= dirtyRect.Width - (thumbSize + strokeWidth))
            {
                x = dirtyRect.Width - (thumbSize + strokeWidth);
            }

            var y = (float)((dirtyRect.Height - thumbSize) / 2);

            touchTargetRect.Center(new PointF(x, y));

            canvas.FillColor = slider.ThumbColor.WithDefault(Fluent.Color.Light.Control.Background.Default, Fluent.Color.Dark.Control.Background.Default);

            canvas.FillEllipse(x, y, thumbSize, thumbSize);

            canvas.RestoreState();

            // Inner Thumb
            if (!slider.IsEnabled)
            {
                canvas.SaveState();

                var innerThumbSize = 10f;

                canvas.FillColor = slider.ThumbColor.WithDefault(Fluent.Color.Light.Accent.Disabled, Fluent.Color.Dark.Accent.Disabled);

                var margin = (thumbSize - innerThumbSize) / 2;

                canvas.FillEllipse(x + margin, y + margin, innerThumbSize, innerThumbSize);

                canvas.RestoreState();
            }

            if (IsDragging)
            {
                canvas.SaveState();

                var innerThumbSize = 14f;

                canvas.FillColor = slider.ThumbColor.WithDefault(Fluent.Color.Light.Accent.Primary, Fluent.Color.Dark.Accent.Primary);

                var margin = (thumbSize - innerThumbSize) / 2;

                canvas.FillEllipse(x + margin, y + margin, innerThumbSize, innerThumbSize);

                canvas.RestoreState();
            }

            // Thumb Border
            if (slider.ThumbColor == null)
            {
                canvas.SaveState();

                canvas.StrokeSize = strokeWidth;

                canvas.StrokeColor = (Application.Current?.RequestedTheme == AppTheme.Light) ? Fluent.Color.Light.Control.Border.Default.ToColor() : Fluent.Color.Dark.Control.Border.Default.ToColor();

                canvas.DrawEllipse(x, y, thumbSize, thumbSize);

                canvas.RestoreState();
            }
        }