| | |
| | | /// <summary> |
| | | /// 点 |
| | | /// </summary> |
| | | public class ZTPoint |
| | | public struct ZTPoint:IEquatable<ZTPoint> |
| | | { |
| | | public static ZTPoint Empty = new ZTPoint(0,0); |
| | | |
| | | public ZTPoint() |
| | | { |
| | | |
| | | } |
| | | |
| | | public ZTPoint(Int32 x, Int32 y) |
| | | { |
| | | this.X = x; |
| | | this.Y = y; |
| | | } |
| | | |
| | | |
| | | public Int32 X { get; set; } |
| | | |
| | | public Int32 Y { get; set; } |
| | |
| | | return new ZTPoint(this.X + val.X, this.Y + val.Y); |
| | | } |
| | | |
| | | public ZTPoint Add(Int32 x, Int32 y) |
| | | { |
| | | return new ZTPoint(this.X + x, this.Y + y); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 两个坐标相减 |
| | | /// </summary> |
| | |
| | | return new ZTPoint(this.X - val.X, this.Y - val.Y); |
| | | } |
| | | |
| | | #region IEquatable |
| | | |
| | | |
| | | public override int GetHashCode() |
| | | { |
| | | Int32 hashCode = 17; |
| | | hashCode = hashCode * 23 + this.X; |
| | | hashCode = hashCode * 23 + this.Y; |
| | | return hashCode; |
| | | } |
| | | |
| | | public bool Equals(ZTPoint other) |
| | | { |
| | | if (other == null) |
| | | { |
| | | return false; |
| | | } |
| | | if (this.X == other.X && this.Y == other.Y) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | } |