MoonProgress.cs 969 B

1234567891011121314151617181920212223242526272829
  1. using System.Drawing;
  2. using System.Drawing.Drawing2D;
  3. using System.Windows.Forms;
  4. namespace Optimizer
  5. {
  6. internal sealed class MoonProgress : ProgressBar
  7. {
  8. public MoonProgress()
  9. {
  10. DoubleBuffered = true;
  11. this.SetStyle(ControlStyles.UserPaint, true);
  12. }
  13. protected override void OnPaint(PaintEventArgs e)
  14. {
  15. LinearGradientBrush brush = null;
  16. Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
  17. if (ProgressBarRenderer.IsSupported)
  18. ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);
  19. rec.Width = (int)(rec.Width * ((double)base.Value / Maximum)) - 4;
  20. rec.Height -= 4;
  21. brush = new LinearGradientBrush(rec, OptionsHelper.ForegroundAccentColor, OptionsHelper.ForegroundColor, LinearGradientMode.Vertical);
  22. e.Graphics.FillRectangle(brush, 2, 2, rec.Width, rec.Height);
  23. }
  24. }
  25. }