コード例 #1
0
        private void DrawThumb(ref ThumbDraw thumbDraw, RangeSliderThumbOptions thumbOptions)
        {
            // Colors
            thumbDraw.Paint.Color = SKColor.Parse((thumbOptions.BackgroundColor ?? _defaultColor));

            thumbDraw.ValueTextDraw.Paint.Color = SKColor.Parse((thumbOptions.TextColor ?? _defaultColor));

            float percentage = GetXPercentage(thumbOptions);

            if (percentage == -1f)
            {
                return;
            }

            // Calculate thumb bounds
            thumbDraw.Radius = _thumbsCanvasInfo.ImageInfo.Rect.MidY
                               - (_thumbsCanvasInfo.ImageInfo.Rect.MidY * 0.5f);

            thumbDraw.Point = new SKPoint
            {
                X = percentage * _thumbsCanvasInfo.ImageInfo.Width,
                Y = _thumbsCanvasInfo.ImageInfo.Rect.MidY
            };

            CheckThumbBounds(ref thumbDraw);

            _thumbsCanvasInfo.Canvas.DrawCircle(thumbDraw.Point, thumbDraw.Radius, thumbDraw.Paint);
        }
コード例 #2
0
 private void CheckThumbBounds(ref ThumbDraw thumbDraw)
 {
     if ((thumbDraw.Point.X - thumbDraw.Radius) < _thumbsCanvasInfo.ImageInfo.Rect.Left)
     {
         thumbDraw.Point.X = _thumbsCanvasInfo.ImageInfo.Rect.Left + thumbDraw.Radius;
     }
     else if ((thumbDraw.Point.X + thumbDraw.Radius) > _thumbsCanvasInfo.ImageInfo.Rect.Right)
     {
         thumbDraw.Point.X = _thumbsCanvasInfo.ImageInfo.Rect.Right - thumbDraw.Radius;
     }
 }
コード例 #3
0
 private float GetThumbValueXPosition(ThumbDraw thumbDraw, TextDraw textDraw)
 {
     if (thumbDraw.Point.X - textDraw.Bounds.MidX < _valuesCanvasInfo.ImageInfo.Rect.Left)
     {
         return(_valuesCanvasInfo.ImageInfo.Rect.Left);
     }
     else if (thumbDraw.Point.X + textDraw.Bounds.MidX > _valuesCanvasInfo.ImageInfo.Rect.Right)
     {
         return(_valuesCanvasInfo.ImageInfo.Rect.Right - textDraw.Bounds.Width);
     }
     else
     {
         return(thumbDraw.Point.X - textDraw.Bounds.MidX);
     }
 }
コード例 #4
0
        private void DrawThumbIcon(ref ThumbDraw thumbDraw, RangeSliderThumbOptions thumbOptions)
        {
            // Set size
            thumbDraw.IconTextDraw.Paint.TextSize = thumbDraw.Radius * 0.75f;

            // Measure
            thumbDraw.IconTextDraw.Paint.MeasureText(thumbOptions.Icon,
                                                     ref thumbDraw.IconTextDraw.Bounds);

            // Update paint
            thumbDraw.IconTextDraw.Paint.Color = SKColor.Parse(thumbOptions.IconColor ?? _defaultColor);

            // Draw
            var point = new SKPoint
            {
                X = thumbDraw.Point.X - Math.Abs(thumbDraw.IconTextDraw.Bounds.MidX),
                Y = thumbDraw.Point.Y + Math.Abs(thumbDraw.IconTextDraw.Bounds.MidY)
            };

            _thumbsCanvasInfo.Canvas.DrawText(thumbOptions.Icon,
                                              point,
                                              thumbDraw.IconTextDraw.Paint);
        }