| | |
| | | /// <summary> |
| | | /// 点 |
| | | /// </summary> |
| | | public class ZTPoint : IEquatable<ZTPoint> |
| | | public struct ZTPoint:IEquatable<ZTPoint> |
| | | { |
| | | public static ZTPoint Empty = default(ZTPoint); |
| | | |
| | | public static ZTPoint Empty = new ZTPoint(0,0); |
| | | |
| | | public ZTPoint(Int32 x, Int32 y) |
| | | { |
| | | this.X = x; |
| | | this.Y = y; |
| | | } |
| | | |
| | | |
| | | public Int32 X { get; set; } |
| | | |
| | | public Int32 Y { get; set; } |
| | | |
| | | |
| | | |
| | | public static bool operator ==(ZTPoint a, ZTPoint b) |
| | | { |
| | | if (a.X == b.X && a.Y == b.Y) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public static bool operator !=(ZTPoint a, ZTPoint b) |
| | | { |
| | | if (a.X != b.X || a.Y != b.Y) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | public static ZTPoint operator +(ZTPoint a, ZTPoint b) |
| | | { |
| | | return new ZTPoint(a.X + b.X, a.Y + b.Y); |
| | |
| | | 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 (this.X == other.X && this.Y == other.Y) |
| | |
| | | } |
| | | return false; |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | } |