diff options
| author | Andrew Rabert <ar@nullsum.net> | 2019-01-19 22:38:41 -0500 |
|---|---|---|
| committer | Andrew Rabert <ar@nullsum.net> | 2019-01-19 22:38:41 -0500 |
| commit | 875392c77fce26f2b51142f65998a1d73727310b (patch) | |
| tree | f68b60cbc7f164921dd9c75f5a6dfdda6d4861a6 /Emby.Drawing/UnplayedCountIndicator.cs | |
| parent | 449dd1a6a242a990a75f3e19afea3b00670d0f5b (diff) | |
Combine Emby.Drawing and Emby.Drawing.Skia
Diffstat (limited to 'Emby.Drawing/UnplayedCountIndicator.cs')
| -rw-r--r-- | Emby.Drawing/UnplayedCountIndicator.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Emby.Drawing/UnplayedCountIndicator.cs b/Emby.Drawing/UnplayedCountIndicator.cs new file mode 100644 index 0000000000..caa3e465be --- /dev/null +++ b/Emby.Drawing/UnplayedCountIndicator.cs @@ -0,0 +1,65 @@ +using System.Globalization; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Net; +using MediaBrowser.Model.Drawing; +using MediaBrowser.Model.IO; +using SkiaSharp; + +namespace Emby.Drawing +{ + public class UnplayedCountIndicator + { + private const int OffsetFromTopRightCorner = 38; + + private readonly IApplicationPaths _appPaths; + private readonly IHttpClient _iHttpClient; + private readonly IFileSystem _fileSystem; + + public UnplayedCountIndicator(IApplicationPaths appPaths, IHttpClient iHttpClient, IFileSystem fileSystem) + { + _appPaths = appPaths; + _iHttpClient = iHttpClient; + _fileSystem = fileSystem; + } + + public void DrawUnplayedCountIndicator(SKCanvas canvas, ImageSize imageSize, int count) + { + 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; + + 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); + } + } + } +} |
