PointEx.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Drawing;
  2. namespace Microsoft.Drawing
  3. {
  4. /// <summary>
  5. /// 点帮助类
  6. /// </summary>
  7. public static class PointEx
  8. {
  9. /// <summary>
  10. /// 平移指定量
  11. /// </summary>
  12. /// <param name="p">点</param>
  13. /// <param name="size">平移量</param>
  14. /// <returns>平移后的点</returns>
  15. public static Point Offset(Point p, Size size)
  16. {
  17. p.Offset(size.Width, size.Height);
  18. return p;
  19. }
  20. /// <summary>
  21. /// 平移指定量
  22. /// </summary>
  23. /// <param name="p">点</param>
  24. /// <param name="pos">平移量</param>
  25. /// <returns>平移后的点</returns>
  26. public static Point Offset(Point p, Point pos)
  27. {
  28. p.Offset(pos);
  29. return p;
  30. }
  31. /// <summary>
  32. /// 平移指定量
  33. /// </summary>
  34. /// <param name="p">点</param>
  35. /// <param name="dx">水平平移量</param>
  36. /// <param name="dy">垂直平移量</param>
  37. /// <returns>平移后的点</returns>
  38. public static Point Offset(Point p, int dx, int dy)
  39. {
  40. p.Offset(dx, dy);
  41. return p;
  42. }
  43. }
  44. }