You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Server.Impleme.../Drawing/PercentPlayedDrawer.cs

37 lines
1.3 KiB

using System.Drawing;
using System.Globalization;
namespace MediaBrowser.Server.Implementations.Drawing
{
public class PercentPlayedDrawer
{
private const int IndicatorWidth = 80;
private const int IndicatorHeight = 50;
private const int FontSize = 30;
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
public void Process(Graphics graphics, Size imageSize, int percent, int rightOffset)
{
var x = imageSize.Width - IndicatorWidth + rightOffset;
using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 102, 192, 16)))
{
graphics.FillRectangle(backdroundBrush, x, 0, IndicatorWidth, IndicatorHeight);
var text = string.Format("{0}%", percent.ToString(_usCulture));
x = imageSize.Width - (percent < 10 ? 66 : 75) + rightOffset;
using (var font = new Font(FontFamily.GenericSansSerif, FontSize, FontStyle.Regular, GraphicsUnit.Pixel))
{
using (var fontBrush = new SolidBrush(Color.White))
{
graphics.DrawString(text, font, fontBrush, x, 6);
}
}
}
}
}
}