SimpleLoading.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace Y.Controls.Loadings
  11. {
  12. public partial class SimpleLoading : UserControl
  13. {
  14. private int _opacity = 125;
  15. public SimpleLoading()
  16. {
  17. InitializeComponent();
  18. }
  19. private void SimpleLoading_Load(object sender, EventArgs e)
  20. {
  21. }
  22. [Bindable(true), Category("Custom"), DefaultValue(125), Description("背景的透明度. 有效值0-255")]
  23. public int Opacity
  24. {
  25. get { return _opacity; }
  26. set
  27. {
  28. if (value > 255) value = 255;
  29. else if (value < 0) value = 0;
  30. _opacity = value;
  31. this.Invalidate();
  32. }
  33. }
  34. protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  35. {
  36. if (this._opacity > 0)
  37. {
  38. e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(this._opacity, this.BackColor)),
  39. this.ClientRectangle);
  40. }
  41. }
  42. public void Show() {
  43. }
  44. }
  45. }