2019-01-13 20:54:44 +01:00
|
|
|
using System.Globalization;
|
2017-05-09 21:53:46 +02:00
|
|
|
using MediaBrowser.Model.Drawing;
|
2019-01-13 20:16:43 +01:00
|
|
|
using SkiaSharp;
|
2017-05-09 21:53:46 +02:00
|
|
|
|
2019-01-20 04:38:41 +01:00
|
|
|
namespace Emby.Drawing
|
2017-05-09 21:53:46 +02:00
|
|
|
{
|
2019-01-20 14:25:13 +01:00
|
|
|
public static class UnplayedCountIndicator
|
2017-05-09 21:53:46 +02:00
|
|
|
{
|
|
|
|
private const int OffsetFromTopRightCorner = 38;
|
|
|
|
|
2019-01-20 14:25:13 +01:00
|
|
|
public static void DrawUnplayedCountIndicator(SKCanvas canvas, ImageSize imageSize, int count)
|
2017-05-09 21:53:46 +02:00
|
|
|
{
|
|
|
|
var x = imageSize.Width - OffsetFromTopRightCorner;
|
|
|
|
var text = count.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
|
|
|
using (var paint = new SKPaint())
|
|
|
|
{
|
|
|
|
paint.Color = SKColor.Parse("#CC52B54B");
|
|
|
|
paint.Style = SKPaintStyle.Fill;
|
|
|
|
canvas.DrawCircle((float)x, OffsetFromTopRightCorner, 20, paint);
|
|
|
|
}
|
|
|
|
using (var paint = new SKPaint())
|
|
|
|
{
|
|
|
|
paint.Color = new SKColor(255, 255, 255, 255);
|
|
|
|
paint.Style = SKPaintStyle.Fill;
|
2017-11-21 23:14:56 +01:00
|
|
|
|
2017-05-09 21:53:46 +02:00
|
|
|
paint.TextSize = 24;
|
|
|
|
paint.IsAntialias = true;
|
|
|
|
|
|
|
|
var y = OffsetFromTopRightCorner + 9;
|
|
|
|
|
|
|
|
if (text.Length == 1)
|
|
|
|
{
|
|
|
|
x -= 7;
|
|
|
|
}
|
|
|
|
if (text.Length == 2)
|
|
|
|
{
|
|
|
|
x -= 13;
|
|
|
|
}
|
|
|
|
else if (text.Length >= 3)
|
|
|
|
{
|
|
|
|
x -= 15;
|
|
|
|
y -= 2;
|
|
|
|
paint.TextSize = 18;
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas.DrawText(text, (float)x, y, paint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|