MyProgressBar.cs 830 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace PaintDotNet.Preview2
  11. {
  12. public partial class MyProgressBar : UserControl
  13. {
  14. double _max = 100;
  15. double _min = 0;
  16. public MyProgressBar()
  17. {
  18. InitializeComponent();
  19. panel1.BackColor = CommonDefine.Blue;
  20. }
  21. double _value;
  22. public double Value
  23. {
  24. get => _value;
  25. set
  26. {
  27. value = Math.Min(_max, Math.Max(_min, value));
  28. _value = value;
  29. panel1.Width = (int)(this.Width / (_max - _min) * (value - _min));
  30. }
  31. }
  32. }
  33. }