Beispiel #1
0
        protected virtual void DrawMaterialSliderThumb(ICanvas canvas, RectangleF dirtyRect)
        {
            canvas.SaveState();

            var value = ((double)Value).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)((HeightRequest - MaterialFloatThumb) / 2);

            canvas.FillColor = ThumbColor.ToGraphicsColor(Material.Color.Blue);

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

            canvas.RestoreState();

            _thumbRect = new RectangleF(x, y, MaterialFloatThumb, MaterialFloatThumb);
        }
Beispiel #2
0
        public void DoDrawAfterChildren(Graphics2D graphics2D)
        {
            RoundedRect track = new RoundedRect(GetTrackBounds(), TrackHeight / 2);
            Vector2     ValuePrintPosition;

            if (sliderAttachedTo.Orientation == Orientation.Horizontal)
            {
                ValuePrintPosition = new Vector2(sliderAttachedTo.TotalWidthInPixels / 2, -sliderAttachedTo.ThumbHeight - 12);
            }
            else
            {
                ValuePrintPosition = new Vector2(0, -sliderAttachedTo.ThumbHeight - 12);
            }

            // draw the track
            graphics2D.Render(track, TrackColor);

            // now do the thumb
            RectangleDouble thumbBounds  = sliderAttachedTo.GetThumbHitBounds();
            RoundedRect     thumbOutside = new RoundedRect(thumbBounds, sliderAttachedTo.ThumbWidth / 2);

            graphics2D.Render(thumbOutside, RGBA_Floats.GetTweenColor(ThumbColor.GetAsRGBA_Floats(), RGBA_Floats.Black.GetAsRGBA_Floats(), .2).GetAsRGBA_Bytes());
            thumbBounds.Inflate(-1);
            RoundedRect thumbInside = new RoundedRect(thumbBounds, sliderAttachedTo.ThumbWidth / 2);

            graphics2D.Render(thumbInside, ThumbColor);
        }
        public void DoDrawAfterChildren(Graphics2D graphics2D)
        {
            RoundedRect track = new RoundedRect(GetTrackBounds(), 0);
            Vector2     ValuePrintPosition;

            if (sliderAttachedTo.Orientation == Orientation.Horizontal)
            {
                ValuePrintPosition = new Vector2(sliderAttachedTo.TotalWidthInPixels / 2, -TrackHeight - 12);
            }
            else
            {
                ValuePrintPosition = new Vector2(0, -TrackHeight - 12);
            }

            // draw the track
            graphics2D.Render(track, TrackColor);

            // draw the first thumb
            RectangleDouble firstThumbBounds  = sliderAttachedTo.GetFirstThumbHitBounds();
            RoundedRect     firstThumbOutside = new RoundedRect(firstThumbBounds, 0);

            graphics2D.Render(firstThumbOutside, RGBA_Floats.GetTweenColor(ThumbColor.GetAsRGBA_Floats(), RGBA_Floats.Black.GetAsRGBA_Floats(), .2).GetAsRGBA_Bytes());

            // draw the second thumb
            RectangleDouble secondThumbBounds  = sliderAttachedTo.GetSecondThumbHitBounds();
            RoundedRect     secondThumbOutside = new RoundedRect(secondThumbBounds, 0);

            graphics2D.Render(secondThumbOutside, RGBA_Floats.GetTweenColor(ThumbColor.GetAsRGBA_Floats(), RGBA_Floats.Black.GetAsRGBA_Floats(), .2).GetAsRGBA_Bytes());
        }
        void DrawFluentSwitchThumb(ICanvas canvas, RectangleF dirtyRect)
        {
            canvas.SaveState();

            canvas.FillColor = ThumbColor.ToGraphicsColor(Fluent.Color.Foreground.White);

            var margin = 4;
            var radius = 6;

            var y = dirtyRect.Y + margin + radius;

            canvas.FillCircle(FluentSwitchThumbPosition, y, radius);

            canvas.RestoreState();
        }
Beispiel #5
0
        void DrawCupertinoSwitchThumb(ICanvas canvas, RectangleF dirtyRect)
        {
            canvas.SaveState();

            canvas.FillColor = ThumbColor.ToGraphicsColor(Fluent.Color.Foreground.White);

            var margin = 2;
            var radius = 13;

            var y = dirtyRect.Y + margin + radius;

            canvas.SetShadow(new SizeF(0, 1), 2, CanvasDefaults.DefaultShadowColor);
            canvas.FillCircle(CupertinoSwitchThumbPosition, y, radius);

            canvas.RestoreState();
        }
Beispiel #6
0
        public void DoDrawAfterChildren(Graphics2D graphics2D)
        {
            var track = new RoundedRect(GetTrackBounds(), TrackHeight / 2);

            // draw the track
            graphics2D.Render(track, TrackColor);

            // now do the thumb
            RectangleDouble thumbBounds  = sliderAttachedTo.GetThumbHitBounds();
            var             thumbOutside = new RoundedRect(thumbBounds, sliderAttachedTo.ThumbWidth / 2);

            graphics2D.Render(thumbOutside, ColorF.GetTweenColor(ThumbColor.ToColorF(), ColorF.Black.ToColorF(), .2).ToColor());
            thumbBounds.Inflate(-1);
            var thumbInside = new RoundedRect(thumbBounds, sliderAttachedTo.ThumbWidth / 2);

            graphics2D.Render(thumbInside, ThumbColor);
        }
        void DrawFluentSliderThumb(ICanvas canvas, RectangleF dirtyRect)
        {
            canvas.SaveState();

            float size        = 16f;
            float strokeWidth = 2f;

            if (IsEnabled)
            {
                canvas.StrokeColor = ThumbColor.ToGraphicsColor(Fluent.Color.Primary.ThemePrimary);
            }
            else
            {
                canvas.StrokeColor = ColorHelper.GetGraphicsColor(Fluent.Color.Background.NeutralTertiaryAlt, Fluent.Color.Background.NeutralQuaternaryAlt);
            }

            canvas.StrokeSize = strokeWidth;

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

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

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

            var y = (float)((HeightRequest - size) / 2);

            canvas.FillColor = ColorHelper.GetGraphicsColor(Fluent.Color.Foreground.White, Fluent.Color.Foreground.Black);

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

            canvas.RestoreState();

            _thumbRect = new RectangleF(x, y, size, size);
        }
Beispiel #8
0
        void DrawMaterialSwitchThumb(ICanvas canvas, RectangleF dirtyRect)
        {
            canvas.SaveState();

            if (IsToggled)
            {
                canvas.FillColor = ThumbColor.ToGraphicsColor(Material.Color.Blue);
            }
            else
            {
                canvas.FillColor = ThumbColor.ToGraphicsColor(Fluent.Color.Foreground.White);
            }

            var margin = 2;
            var radius = 10;

            var y = dirtyRect.Y + margin + radius;

            canvas.SetShadow(new SizeF(0, 1), 2, CanvasDefaults.DefaultShadowColor);
            canvas.FillCircle(MaterialSwitchThumbPosition, y, radius);

            canvas.RestoreState();
        }
Beispiel #9
0
        void DrawCupertinoSliderThumb(ICanvas canvas, RectangleF dirtyRect)
        {
            canvas.SaveState();

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

            canvas.StrokeColor = ThumbColor.ToGraphicsColor(DefaultCupertinoSliderThumbColor);
            canvas.StrokeSize  = strokeWidth;

            var value = ((double)Value).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)((HeightRequest - size) / 2);

            canvas.FillColor = ThumbColor.ToGraphicsColor(Colors.White.ToHex());

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

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

            canvas.RestoreState();

            _thumbRect = new RectangleF(x, y, size, size);
        }
Beispiel #10
0
        private void DrawThumbWithoutBitmap()
        {
            int r  = SliderRect.Height / 2;
            int x  = SliderRect.Left + r;
            int x2 = SliderRect.Left + SliderRect.Width - r;
            int y  = SliderRect.Top + r;

            if (Transforming)
            {
                int offset = 0;
                int x3     = 0;
                if (Checked)
                {
                    offset = (int)(Progress * (-SliderRect.Width));
                    x3     = x2 + offset;
                    if (x3 < x)
                    {
                        x3 = x;
                    }
                    if (HasShadow)
                    {
                        CurrentRenderTarget.fillCircle(x3 + ShadowOffset, y + ShadowOffset, r + ShadowAdditionRadius, ShadowColor);
                    }
                    if (UseGradient)
                    {
                        using (LinearGradientBrush brush = ThumbColorLinearGradientTrue(x3, y, r + 1))
                        {
                            CurrentRenderTarget.fillCircle(x3, y, r, brush);
                        }
                        using (LinearGradientBrush brush = ThumbColorLinearGradient(x3, y, r + 1, (int)(Progress * 255)))
                        {
                            CurrentRenderTarget.fillCircle(x3, y, r, brush);
                        }
                    }
                    else
                    {
                        CurrentRenderTarget.fillCircle(x3, y, r, ThumbColorTrue.ToArgb());
                        CurrentRenderTarget.fillCircle(x3, y, r, Color.FromArgb((int)(Progress * 255), ThumbColor).ToArgb());
                    }
                }
                else
                {
                    offset = (int)(Progress * SliderRect.Width);
                    x3     = x + offset;
                    if (x3 > x2)
                    {
                        x3 = x2;
                    }
                    if (HasShadow)
                    {
                        CurrentRenderTarget.fillCircle(x3 + ShadowOffset, y + ShadowOffset, r + ShadowAdditionRadius, ShadowColor);
                    }
                    if (UseGradient)
                    {
                        using (LinearGradientBrush brush = ThumbColorLinearGradient(x3, y, r + 1))
                        {
                            CurrentRenderTarget.fillCircle(x3, y, r, brush);
                        }
                        using (LinearGradientBrush brush = ThumbColorLinearGradientTrue(x3, y, r + 1, (int)(Progress * 255)))
                        {
                            CurrentRenderTarget.fillCircle(x3, y, r, brush);
                        }
                    }
                    else
                    {
                        CurrentRenderTarget.fillCircle(x3, y, r, ThumbColor.ToArgb());
                        CurrentRenderTarget.fillCircle(x3, y, r, Color.FromArgb((int)(Progress * 255), ThumbColorTrue).ToArgb());
                    }
                }
            }
            else
            {
                if (!Checked)
                {
                    if (HasShadow)
                    {
                        CurrentRenderTarget.fillCircle(x + ShadowOffset, y + ShadowOffset, r + ShadowAdditionRadius, ShadowColor);
                    }
                    if (UseGradient)
                    {
                        using (LinearGradientBrush brush = ThumbColorLinearGradient(x, y, r + 1))
                        {
                            CurrentRenderTarget.fillCircle(x, y, r, brush);
                        }
                    }
                    else
                    {
                        CurrentRenderTarget.fillCircle(x, y, r, ThumbColor.ToArgb());
                    }
                }
                else
                {
                    if (HasShadow)
                    {
                        CurrentRenderTarget.fillCircle(x2 + ShadowOffset, y + ShadowOffset, r + ShadowAdditionRadius, ShadowColor);
                    }
                    if (UseGradient)
                    {
                        using (LinearGradientBrush brush = ThumbColorLinearGradientTrue(x2, y, r + 1))
                        {
                            CurrentRenderTarget.fillCircle(x2, y, r, brush);
                        }
                    }
                    else
                    {
                        CurrentRenderTarget.fillCircle(x2, y, r, ThumbColorTrue.ToArgb());
                    }
                }
            }
        }