aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs
blob: e2f5b6129c46de6c02863c1db940c8efdde651c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);
                    }
                }
            }

        }
    }
}