o
asmrobot
2019-10-27 c4bd9d8c587bd1401f0fb2f60c34a4964d7afe20
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace RichCreator.Utility.Structs
{
    /// <summary>
    /// 多边形
    /// </summary>
    public class ZTPolygon : IEnumerable<ZTPoint>
    {
        private ZTPoint[] points;
 
        public ZTPolygon(ZTPoint[] points)
        {
            this.points = points;
        }
 
        public ZTPoint[] Points
        {
            get { return points; }
            set { points = value; }
        }
 
        public int Length
        {
            get { return points.Length; }
        }
 
        public ZTPoint this[int index]
        {
            get { return points[index]; }
            set { points[index] = value; }
        }
 
        public static bool operator !=(ZTPolygon a, ZTPolygon b)
        {
            if (a == b)
            {
                return false;
            }
            return true;
        }
 
        public static bool operator ==(ZTPolygon a, ZTPolygon b)
        {
            if (a.Length != b.Length)
            {
                return false;
            }
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] != b[i])
                {
                    return false;
                }
            }
            return true;
        }
 
        public static implicit operator ZTPoint[] (ZTPolygon polygon)
        {
            return polygon.points;
        }
 
        public static implicit operator ZTPolygon(ZTPoint[] points)
        {
            return new ZTPolygon(points);
        }
 
        IEnumerator<ZTPoint> IEnumerable<ZTPoint>.GetEnumerator()
        {
            return (IEnumerator<ZTPoint>)points.GetEnumerator();
        }
 
        public IEnumerator GetEnumerator()
        {
            return points.GetEnumerator();
        }
    }
}