GroupBoxEx.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using System.IO;
  6. using System.Drawing;
  7. using System.Drawing.Drawing2D;
  8. using System.ComponentModel;
  9. namespace LYFZ.ComponentLibrary
  10. {
  11. public class GroupBoxEx : System.Windows.Forms.GroupBox
  12. {
  13. public GroupBoxEx()
  14. {
  15. this.Paint += GroupBoxEx_Paint;
  16. this.SizeChanged += GroupBoxEx_SizeChanged;
  17. }
  18. void GroupBoxEx_SizeChanged(object sender, EventArgs e)
  19. {
  20. this.Update();
  21. }
  22. void GroupBoxEx_Paint(object sender, PaintEventArgs e)
  23. {
  24. Rectangle Rtg_LT = new Rectangle();
  25. Rectangle Rtg_RT = new Rectangle();
  26. Rectangle Rtg_LB = new Rectangle();
  27. Rectangle Rtg_RB = new Rectangle();
  28. Rtg_LT.X = 0; Rtg_LT.Y = 7; Rtg_LT.Width = 10; Rtg_LT.Height = 10;
  29. Rtg_RT.X = e.ClipRectangle.Width - 11; Rtg_RT.Y = 7; Rtg_RT.Width = 10; Rtg_RT.Height = 10;
  30. Rtg_LB.X = 0; Rtg_LB.Y = e.ClipRectangle.Height - 11; Rtg_LB.Width = 10; Rtg_LB.Height = 10;
  31. Rtg_RB.X = e.ClipRectangle.Width - 11; Rtg_RB.Y = e.ClipRectangle.Height - 11; Rtg_RB.Width = 10; Rtg_RB.Height = 10;
  32. Color color = LYFZ.ComponentLibrary.GetUIResources.BorderAreaColor;// Color.FromArgb(51, 94, 168);
  33. Pen Pen_AL = new Pen(color, 1);
  34. Pen_AL.Color = color;
  35. Brush brush = new HatchBrush(HatchStyle.Divot, color);
  36. // e.Graphics.DrawString(this.Text, this.Font, brush, 6, 3,StringFormat.GenericDefault);
  37. e.Graphics.DrawArc(Pen_AL, Rtg_LT, 180, 90);
  38. e.Graphics.DrawArc(Pen_AL, Rtg_RT, 270, 90);
  39. e.Graphics.DrawArc(Pen_AL, Rtg_LB, 90, 90);
  40. e.Graphics.DrawArc(Pen_AL, Rtg_RB, 0, 90);
  41. e.Graphics.DrawLine(Pen_AL, 5, 7, 6, 7);
  42. e.Graphics.DrawLine(Pen_AL, e.Graphics.MeasureString(this.Text, this.Font).Width + 3, 7, e.ClipRectangle.Width - 7, 7);
  43. e.Graphics.DrawLine(Pen_AL, 0, 13, 0, e.ClipRectangle.Height - 7);
  44. e.Graphics.DrawLine(Pen_AL, 6, e.ClipRectangle.Height - 1, e.ClipRectangle.Width - 7, e.ClipRectangle.Height - 1);
  45. e.Graphics.DrawLine(Pen_AL, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 7, e.ClipRectangle.Width - 1, 13);
  46. }
  47. }
  48. }