asmrobot
2019-11-21 589ed88a5924a7494e21b95b6bbff5e46ff49ddd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace RichCreator.Utility.Structs
{
    /// <summary>
    /// 点
    /// </summary>
    public struct ZTPoint:IEquatable<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 ZTPoint operator +(ZTPoint a, ZTPoint b)
        {
            return new ZTPoint(a.X + b.X, a.Y + b.Y);
        }
 
        public static ZTPoint operator -(ZTPoint a, ZTPoint b)
        {
            return new ZTPoint(a.X - b.X, a.Y - b.Y);
        }
 
        public override string ToString()
        {
            return "(" + this.X.ToString() + "," + this.Y.ToString() + ")";
        }
 
        /// <summary>
        /// x,y坐标加上指定的值
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public ZTPoint Add(Int32 val)
        {
            return new ZTPoint(this.X + val, this.Y + val);
        }
 
        /// <summary>
        /// 两个坐标相加
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public ZTPoint Add(ZTPoint val)
        {
            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>
        /// <param name="val"></param>
        /// <returns></returns>
        public ZTPoint Sub(ZTPoint val)
        {
            return new ZTPoint(this.X - val.X, this.Y - val.Y);
        }
 
 
 
        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 true;
            }
            return false;
        }
        
    }
}