2015-03-08 20:56:42 -07:00
|
|
|
|
using ImageMagickSharp;
|
|
|
|
|
using MediaBrowser.Common.Configuration;
|
2015-02-19 18:57:10 -07:00
|
|
|
|
using MediaBrowser.Model.Drawing;
|
2015-03-08 20:56:42 -07:00
|
|
|
|
using System.Globalization;
|
2016-10-25 12:02:04 -07:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Controller.IO;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2015-04-08 07:38:02 -07:00
|
|
|
|
namespace Emby.Drawing.ImageMagick
|
2014-01-01 11:26:31 -07:00
|
|
|
|
{
|
|
|
|
|
public class UnplayedCountIndicator
|
|
|
|
|
{
|
2015-02-19 18:57:10 -07:00
|
|
|
|
private const int OffsetFromTopRightCorner = 38;
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2015-03-08 20:56:42 -07:00
|
|
|
|
private readonly IApplicationPaths _appPaths;
|
2015-09-13 16:07:54 -07:00
|
|
|
|
private readonly IFileSystem _fileSystem;
|
2015-03-08 20:56:42 -07:00
|
|
|
|
|
2015-09-13 16:07:54 -07:00
|
|
|
|
public UnplayedCountIndicator(IApplicationPaths appPaths, IFileSystem fileSystem)
|
2015-03-08 20:56:42 -07:00
|
|
|
|
{
|
|
|
|
|
_appPaths = appPaths;
|
2015-09-13 16:07:54 -07:00
|
|
|
|
_fileSystem = fileSystem;
|
2015-03-08 20:56:42 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-19 18:57:10 -07:00
|
|
|
|
public void DrawUnplayedCountIndicator(MagickWand wand, ImageSize imageSize, int count)
|
2014-01-01 11:26:31 -07:00
|
|
|
|
{
|
2015-02-19 18:57:10 -07:00
|
|
|
|
var x = imageSize.Width - OffsetFromTopRightCorner;
|
|
|
|
|
var text = count.ToString(CultureInfo.InvariantCulture);
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2015-02-19 18:57:10 -07:00
|
|
|
|
using (var draw = new DrawingWand())
|
2014-01-01 11:26:31 -07:00
|
|
|
|
{
|
2015-02-19 18:57:10 -07:00
|
|
|
|
using (PixelWand pixel = new PixelWand())
|
|
|
|
|
{
|
|
|
|
|
pixel.Color = "#52B54B";
|
|
|
|
|
pixel.Opacity = 0.2;
|
|
|
|
|
draw.FillColor = pixel;
|
|
|
|
|
draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2015-02-19 18:57:10 -07:00
|
|
|
|
pixel.Opacity = 0;
|
|
|
|
|
pixel.Color = "white";
|
|
|
|
|
draw.FillColor = pixel;
|
2015-09-13 14:32:02 -07:00
|
|
|
|
draw.Font = PlayedIndicatorDrawer.ExtractFont("robotoregular.ttf", _appPaths, _fileSystem);
|
2015-02-19 18:57:10 -07:00
|
|
|
|
draw.FontStyle = FontStyleType.NormalStyle;
|
|
|
|
|
draw.TextAlignment = TextAlignType.CenterAlign;
|
|
|
|
|
draw.FontWeight = FontWeightType.RegularStyle;
|
|
|
|
|
draw.TextAntialias = true;
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2015-02-19 18:57:10 -07:00
|
|
|
|
var fontSize = 30;
|
|
|
|
|
var y = OffsetFromTopRightCorner + 11;
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2015-02-19 18:57:10 -07:00
|
|
|
|
if (text.Length == 1)
|
|
|
|
|
{
|
2015-03-08 20:56:42 -07:00
|
|
|
|
x += 1;
|
2015-02-19 18:57:10 -07:00
|
|
|
|
}
|
|
|
|
|
else if (text.Length == 2)
|
|
|
|
|
{
|
|
|
|
|
x += 1;
|
|
|
|
|
}
|
|
|
|
|
else if (text.Length >= 3)
|
2014-01-01 11:26:31 -07:00
|
|
|
|
{
|
2015-03-08 20:58:16 -07:00
|
|
|
|
//x += 1;
|
2015-02-19 18:57:10 -07:00
|
|
|
|
y -= 2;
|
|
|
|
|
fontSize = 24;
|
2014-01-01 11:26:31 -07:00
|
|
|
|
}
|
2015-02-19 18:57:10 -07:00
|
|
|
|
|
|
|
|
|
draw.FontSize = fontSize;
|
|
|
|
|
draw.DrawAnnotation(x, y, text);
|
|
|
|
|
|
|
|
|
|
draw.FillColor = pixel;
|
|
|
|
|
wand.CurrentImage.DrawImage(draw);
|
2014-01-01 11:26:31 -07:00
|
|
|
|
}
|
2015-02-19 18:57:10 -07:00
|
|
|
|
|
2014-01-01 11:26:31 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|