Point.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace WMFConverter.Gdi
  7. {
  8. /// <summary>
  9. /// Represents a point (x,y).
  10. /// </summary>
  11. public class Point
  12. {
  13. #region Properties
  14. /// <summary>
  15. /// Point X
  16. /// </summary>
  17. public int X { get; set; }
  18. /// <summary>
  19. /// Point Y
  20. /// </summary>
  21. public int Y { get; set; }
  22. #endregion
  23. #region Constructors
  24. /// <summary>
  25. /// Default constructor.
  26. /// </summary>
  27. /// <param name="x"></param>
  28. /// <param name="y"></param>
  29. public Point(int x, int y)
  30. {
  31. X = x;
  32. Y = y;
  33. }
  34. #endregion
  35. #region Public Methods
  36. /// <summary>
  37. /// Serves as the default hash function.
  38. /// </summary>
  39. /// <returns></returns>
  40. public override int GetHashCode()
  41. {
  42. int prime = 31;
  43. int result = 1;
  44. result = prime * result + X;
  45. result = prime * result + Y;
  46. return result;
  47. }
  48. /// <summary>
  49. /// Determines whether the specified object is equal to the current object.
  50. /// </summary>
  51. /// <param name="obj"></param>
  52. /// <returns></returns>
  53. public override bool Equals(Object obj)
  54. {
  55. if (this == obj)
  56. return true;
  57. if (obj == null)
  58. return false;
  59. if (typeof(Point) != obj.GetType())
  60. return false;
  61. Point other = (Point)obj;
  62. if (X != other.X)
  63. return false;
  64. if (Y != other.Y)
  65. return false;
  66. return true;
  67. }
  68. /// <summary>
  69. /// Returns a string that represents the current object.
  70. /// </summary>
  71. /// <returns></returns>
  72. public override string ToString()
  73. {
  74. return "Point [x=" + X + ", y=" + Y + "]";
  75. }
  76. #endregion
  77. }
  78. }