jellyfin-server/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs

35 lines
1.1 KiB
C#
Raw Normal View History

using System;
using System.Drawing;
2013-09-21 15:06:00 +00:00
namespace MediaBrowser.Server.Implementations.Drawing
{
public class PercentPlayedDrawer
{
private const int IndicatorHeight = 10;
2013-09-21 15:06:00 +00:00
public void Process(Graphics graphics, Size imageSize, double percent)
2013-09-21 15:06:00 +00:00
{
var y = imageSize.Height - IndicatorHeight;
2013-09-21 15:06:00 +00:00
using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 0, 0, 0)))
2013-09-21 15:06:00 +00:00
{
const int innerX = 0;
var innerY = y;
var innerWidth = imageSize.Width;
var innerHeight = imageSize.Height;
2013-09-21 15:06:00 +00:00
graphics.FillRectangle(backdroundBrush, innerX, innerY, innerWidth, innerHeight);
2013-09-21 15:06:00 +00:00
using (var foregroundBrush = new SolidBrush(Color.FromArgb(82, 181, 75)))
2013-09-21 15:06:00 +00:00
{
double foregroundWidth = innerWidth;
foregroundWidth *= percent;
foregroundWidth /= 100;
graphics.FillRectangle(foregroundBrush, innerX, innerY, Convert.ToInt32(Math.Round(foregroundWidth)), innerHeight);
2013-09-21 15:06:00 +00:00
}
}
}
}
}