ControlPaint.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Drawing;
  2. namespace System.Windows.Forms
  3. {
  4. public class ControlPaint
  5. {
  6. public static void DrawVisualStyleBorder(Graphics graphics, Rectangle bounds, int dpi = 96)
  7. {
  8. if (graphics == null)
  9. {
  10. throw new ArgumentNullException("graphics");
  11. }
  12. graphics.DrawRectangle(SystemPens.ActiveBorder, bounds);
  13. bounds.Inflate(-1, -1);
  14. if (dpi > 120)
  15. graphics.DrawRectangle(SystemPens.ActiveBorder, bounds);
  16. }
  17. public static void DrawFocusRectangle(Graphics graphics, Rectangle bounds)
  18. {
  19. // TODO? not used in FR
  20. }
  21. public static void DrawBorder3D(Graphics graphics, int x, int y, int width, int height, Border3DStyle style)
  22. {
  23. // TODO: incomplete
  24. graphics.DrawRectangle(SystemPens.ActiveBorder, x, y, width, height);
  25. }
  26. }
  27. public static class ControlPaintExt
  28. {
  29. public static void DrawVisualStyleBorder(this Control control, Graphics graphics, Rectangle bounds)
  30. {
  31. ControlPaint.DrawVisualStyleBorder(graphics, bounds, control.DeviceDpi);
  32. }
  33. }
  34. }