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); }
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; } }
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); } }
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); }