aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs82
1 files changed, 51 insertions, 31 deletions
diff --git a/MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs b/MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs
index 695c6390a..71cced041 100644
--- a/MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs
+++ b/MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs
@@ -1,49 +1,69 @@
-using System.Drawing;
+using ImageMagickSharp;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Model.Drawing;
+using System.Globalization;
namespace MediaBrowser.Server.Implementations.Drawing
{
public class UnplayedCountIndicator
{
- private const int IndicatorHeight = 41;
- public const int IndicatorWidth = 41;
- private const int OffsetFromTopRightCorner = 10;
+ private const int OffsetFromTopRightCorner = 38;
- public void DrawUnplayedCountIndicator(Graphics graphics, Size imageSize, int count)
+ private readonly IApplicationPaths _appPaths;
+
+ public UnplayedCountIndicator(IApplicationPaths appPaths)
{
- var x = imageSize.Width - IndicatorWidth - OffsetFromTopRightCorner;
+ _appPaths = appPaths;
+ }
- using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 82, 181, 75)))
- {
- graphics.FillEllipse(backdroundBrush, x, OffsetFromTopRightCorner, IndicatorWidth, IndicatorHeight);
+ public void DrawUnplayedCountIndicator(MagickWand wand, ImageSize imageSize, int count)
+ {
+ var x = imageSize.Width - OffsetFromTopRightCorner;
+ var text = count.ToString(CultureInfo.InvariantCulture);
- var text = count.ToString();
+ using (var draw = new DrawingWand())
+ {
+ using (PixelWand pixel = new PixelWand())
+ {
+ pixel.Color = "#52B54B";
+ pixel.Opacity = 0.2;
+ draw.FillColor = pixel;
+ draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);
- x = imageSize.Width - IndicatorWidth - OffsetFromTopRightCorner;
- var y = OffsetFromTopRightCorner + 6;
- var fontSize = 24;
+ pixel.Opacity = 0;
+ pixel.Color = "white";
+ draw.FillColor = pixel;
+ draw.Font = PlayedIndicatorDrawer.ExtractFont("robotoregular.ttf", _appPaths);
+ draw.FontStyle = FontStyleType.NormalStyle;
+ draw.TextAlignment = TextAlignType.CenterAlign;
+ draw.FontWeight = FontWeightType.RegularStyle;
+ draw.TextAntialias = true;
- if (text.Length == 1)
- {
- x += 10;
- }
- else if (text.Length == 2)
- {
- x += 3;
- }
- else if (text.Length == 3)
- {
- x += 1;
- y += 1;
- fontSize = 20;
- }
+ var fontSize = 30;
+ var y = OffsetFromTopRightCorner + 11;
- using (var font = new Font("Sans-Serif", fontSize, FontStyle.Regular, GraphicsUnit.Pixel))
- {
- using (var fontBrush = new SolidBrush(Color.White))
+ if (text.Length == 1)
+ {
+ x += 1;
+ }
+ else if (text.Length == 2)
{
- graphics.DrawString(text, font, fontBrush, x, y);
+ x += 1;
}
+ else if (text.Length >= 3)
+ {
+ //x += 1;
+ y -= 2;
+ fontSize = 24;
+ }
+
+ draw.FontSize = fontSize;
+ draw.DrawAnnotation(x, y, text);
+
+ draw.FillColor = pixel;
+ wand.CurrentImage.DrawImage(draw);
}
+
}
}
}