using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RichCreator.Utility.Structs { /// /// 多边形 /// public class ZTPolygon : IEnumerable { 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 IEnumerable.GetEnumerator() { return (IEnumerator)points.GetEnumerator(); } public IEnumerator GetEnumerator() { return points.GetEnumerator(); } } }