GripBounds.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System;
  2. using System.Drawing;
  3. namespace Dongke.WinForm.Controls
  4. {
  5. internal struct GripBounds
  6. {
  7. private const int GRIPSIZE = 6;
  8. private const int CORNER_GRIPSIZE = GRIPSIZE << 1;
  9. private Rectangle _clientRectangle;
  10. public GripBounds(Rectangle clientRectangle)
  11. {
  12. this._clientRectangle = clientRectangle;
  13. }
  14. public Rectangle ClientRectangle
  15. {
  16. get { return _clientRectangle; }
  17. //set { clientRectangle = value; }
  18. }
  19. public Rectangle Bottom
  20. {
  21. get
  22. {
  23. Rectangle rect = ClientRectangle;
  24. rect.Y = rect.Bottom - GRIPSIZE + 1;
  25. rect.Height = GRIPSIZE;
  26. return rect;
  27. }
  28. }
  29. public Rectangle BottomRight
  30. {
  31. get
  32. {
  33. Rectangle rect = ClientRectangle;
  34. rect.Y = rect.Bottom - CORNER_GRIPSIZE + 1;
  35. rect.Height = CORNER_GRIPSIZE;
  36. rect.X = rect.Width - CORNER_GRIPSIZE + 1;
  37. rect.Width = CORNER_GRIPSIZE;
  38. return rect;
  39. }
  40. }
  41. public Rectangle Top
  42. {
  43. get
  44. {
  45. Rectangle rect = ClientRectangle;
  46. rect.Height = GRIPSIZE;
  47. return rect;
  48. }
  49. }
  50. public Rectangle TopRight
  51. {
  52. get
  53. {
  54. Rectangle rect = ClientRectangle;
  55. rect.Height = CORNER_GRIPSIZE;
  56. rect.X = rect.Width - CORNER_GRIPSIZE + 1;
  57. rect.Width = CORNER_GRIPSIZE;
  58. return rect;
  59. }
  60. }
  61. public Rectangle Left
  62. {
  63. get
  64. {
  65. Rectangle rect = ClientRectangle;
  66. rect.Width = GRIPSIZE;
  67. return rect;
  68. }
  69. }
  70. public Rectangle BottomLeft
  71. {
  72. get
  73. {
  74. Rectangle rect = ClientRectangle;
  75. rect.Width = CORNER_GRIPSIZE;
  76. rect.Y = rect.Height - CORNER_GRIPSIZE + 1;
  77. rect.Height = CORNER_GRIPSIZE;
  78. return rect;
  79. }
  80. }
  81. public Rectangle Right
  82. {
  83. get
  84. {
  85. Rectangle rect = ClientRectangle;
  86. rect.X = rect.Right - GRIPSIZE + 1;
  87. rect.Width = GRIPSIZE;
  88. return rect;
  89. }
  90. }
  91. public Rectangle TopLeft
  92. {
  93. get
  94. {
  95. Rectangle rect = ClientRectangle;
  96. rect.Width = CORNER_GRIPSIZE;
  97. rect.Height = CORNER_GRIPSIZE;
  98. return rect;
  99. }
  100. }
  101. }
  102. }