PercentPlayedDrawer.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Drawing;
  3. namespace Emby.Drawing.Net
  4. {
  5. public class PercentPlayedDrawer
  6. {
  7. private const int IndicatorHeight = 8;
  8. public void Process(Graphics graphics, Size imageSize, double percent)
  9. {
  10. var y = imageSize.Height - IndicatorHeight;
  11. using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 0, 0, 0)))
  12. {
  13. const int innerX = 0;
  14. var innerY = y;
  15. var innerWidth = imageSize.Width;
  16. var innerHeight = imageSize.Height;
  17. graphics.FillRectangle(backdroundBrush, innerX, innerY, innerWidth, innerHeight);
  18. using (var foregroundBrush = new SolidBrush(Color.FromArgb(82, 181, 75)))
  19. {
  20. double foregroundWidth = innerWidth;
  21. foregroundWidth *= percent;
  22. foregroundWidth /= 100;
  23. graphics.FillRectangle(foregroundBrush, innerX, innerY, Convert.ToInt32(Math.Round(foregroundWidth)), innerHeight);
  24. }
  25. }
  26. }
  27. }
  28. }