Size.cs 2.2 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 size object.
  10. /// </summary>
  11. public class Size
  12. {
  13. #region Properties
  14. /// <summary>
  15. /// Width of the object.
  16. /// </summary>
  17. public int Width { get; set; }
  18. /// <summary>
  19. /// Height of the object.
  20. /// </summary>
  21. public int Height { get; set; }
  22. #endregion
  23. #region Constructors
  24. /// <summary>
  25. /// Default constructor.
  26. /// </summary>
  27. /// <param name="width"></param>
  28. /// <param name="height"></param>
  29. public Size(int width, int height)
  30. {
  31. Width = width;
  32. Height = height;
  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 + Height;
  45. result = prime * result + Width;
  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(Size) != obj.GetType())
  60. return false;
  61. Size other = (Size)obj;
  62. if (Height != other.Height)
  63. return false;
  64. if (Width != other.Width)
  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 "Size [width=" + Width + ", height=" + Height + "]";
  75. }
  76. #endregion
  77. }
  78. }