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