asmrobot
2019-11-25 2aeab450471cb80b59002da7da80faf251a0c4f4
src/RichCreator.Utility/Structs/ZTPoint.cs
@@ -9,41 +9,20 @@
    /// <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);
@@ -79,6 +58,11 @@
            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>
@@ -89,7 +73,16 @@
            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)
@@ -98,6 +91,6 @@
            }
            return false;
        }
        #endregion
    }
}