diff options
| author | LogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com> | 2019-01-23 00:31:35 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-23 00:31:35 -0800 |
| commit | 404bd04cbc17dc8c8bf4a5c9aa3ca9c5cd85aa68 (patch) | |
| tree | 3d267c6ceef9439a034c113095e10e4d619e7c70 /Emby.Drawing/UnplayedCountIndicator.cs | |
| parent | 8ff89fdc0c30f595a171ffc550f907ef22b6212a (diff) | |
| parent | e05e002b8bb4d13eb2b80b56a0aad8903ddb701e (diff) | |
Merge pull request #8 from jellyfin/master
rebase to latest master
Diffstat (limited to 'Emby.Drawing/UnplayedCountIndicator.cs')
| -rw-r--r-- | Emby.Drawing/UnplayedCountIndicator.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Emby.Drawing/UnplayedCountIndicator.cs b/Emby.Drawing/UnplayedCountIndicator.cs new file mode 100644 index 000000000..16c084a21 --- /dev/null +++ b/Emby.Drawing/UnplayedCountIndicator.cs @@ -0,0 +1,51 @@ +using System.Globalization; +using MediaBrowser.Model.Drawing; +using SkiaSharp; + +namespace Emby.Drawing +{ + public static class UnplayedCountIndicator + { + private const int OffsetFromTopRightCorner = 38; + + public static 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); + } + } + } +} |
