You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.4 KiB

1 month ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Diagnostics;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace Customize.Controls
  12. {
  13. public class BorderPanel
  14. : Panel
  15. {
  16. private Color _BoarderColor = Color.Black;
  17. [Browsable(true), Description("边框颜色"), Category("自定义分组")]
  18. public Color BoarderColor
  19. {
  20. get
  21. {
  22. return _BoarderColor;
  23. }
  24. set
  25. {
  26. _BoarderColor = value;
  27. }
  28. }
  29. private int _BoarderSize = 2;//初始边框粗细
  30. [Browsable(true), Description("边框粗细"), Category("自定义分组")]//功能如上
  31. public int BoarderSize//边框粗细
  32. {
  33. get
  34. {
  35. return _BoarderSize;
  36. }
  37. set
  38. {
  39. _BoarderSize = value;
  40. }
  41. }
  42. protected override void OnPaint(PaintEventArgs e)
  43. {
  44. Debug.WriteLine("----------BorderPanel");
  45. if (_BoarderSize > 0)
  46. {
  47. Pen p = new Pen(_BoarderColor, _BoarderSize);
  48. p.DashStyle = DashStyle.Dot;
  49. e.Graphics.DrawRectangle(p, this.ClientRectangle);
  50. }
  51. base.OnPaint(e);
  52. }
  53. }
  54. }