MoonProgress.cs 949 B

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