2015-02-20 01:57:10 +00:00
|
|
|
|
using ImageMagickSharp;
|
|
|
|
|
using System;
|
2013-09-21 15:06:00 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.Drawing
|
|
|
|
|
{
|
|
|
|
|
public class PercentPlayedDrawer
|
|
|
|
|
{
|
2014-05-27 14:30:21 +00:00
|
|
|
|
private const int IndicatorHeight = 8;
|
2013-09-21 15:06:00 +00:00
|
|
|
|
|
2015-02-20 01:57:10 +00:00
|
|
|
|
public void Process(MagickWand wand, double percent)
|
2013-09-21 15:06:00 +00:00
|
|
|
|
{
|
2015-02-20 01:57:10 +00:00
|
|
|
|
var currentImage = wand.CurrentImage;
|
|
|
|
|
var height = currentImage.Height;
|
2013-09-21 15:06:00 +00:00
|
|
|
|
|
2015-02-20 01:57:10 +00:00
|
|
|
|
using (var draw = new DrawingWand())
|
2013-09-21 15:06:00 +00:00
|
|
|
|
{
|
2015-02-20 01:57:10 +00:00
|
|
|
|
using (PixelWand pixel = new PixelWand())
|
|
|
|
|
{
|
|
|
|
|
var endX = currentImage.Width - 1;
|
|
|
|
|
var endY = height - 1;
|
2013-09-21 15:06:00 +00:00
|
|
|
|
|
2015-02-20 01:57:10 +00:00
|
|
|
|
pixel.Color = "black";
|
|
|
|
|
pixel.Opacity = 0.4;
|
|
|
|
|
draw.FillColor = pixel;
|
|
|
|
|
draw.DrawRectangle(0, endY - IndicatorHeight, endX, endY);
|
2013-09-21 15:06:00 +00:00
|
|
|
|
|
2015-02-20 01:57:10 +00:00
|
|
|
|
double foregroundWidth = endX;
|
2014-01-01 18:26:31 +00:00
|
|
|
|
foregroundWidth *= percent;
|
|
|
|
|
foregroundWidth /= 100;
|
|
|
|
|
|
2015-02-20 01:57:10 +00:00
|
|
|
|
pixel.Color = "#52B54B";
|
|
|
|
|
pixel.Opacity = 0;
|
|
|
|
|
draw.FillColor = pixel;
|
|
|
|
|
draw.DrawRectangle(0, endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), endY);
|
|
|
|
|
wand.CurrentImage.DrawImage(draw);
|
2013-09-21 15:06:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|