asmrobot
2019-11-13 576b92fd82f568572bc4beb125fa0ba0191a602f
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace RichCreator.Utility.Structs
{
    /// <summary>
    /// 线
    /// </summary>
    public struct ZTLine
    {
        public static ZTLine Empty = default(ZTLine);
 
        public ZTLine(Int32 x,Int32 y,Int32 length)
        {
            this.X = x;
            this.Y = y;
            this.Length = length;
        }
        public Int32 X { get; set; }
 
        public Int32 Y { get; set; }
 
        public Int32 Length { get; set; }
 
        public static bool operator ==(ZTLine a, ZTLine b)
        {
            if ((a.X == b.X && a.Y == b.Y && a.Length == b.Length))
            {
                return true;
            }
            return false;
        }
 
        public static bool operator !=(ZTLine a, ZTLine b)
        {
            if (a.X != b.X || a.Y != b.Y || a.Length != b.Length)
            {
                return true;
            }
            return false;
        }
 
        /// <summary>
        /// 是否包含点
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="orientation"></param>
        /// <returns></returns>
        public bool Contain(Int32 x, Int32 y, Orientation orientation)
        {
            if (orientation == Orientation.Horizontal)
            {
                if (this.Y == y&& x >= this.X && x <= (this.X + this.Length - 1))
                {
                    return true;
                }
            }
            else
            {
                if (this.X == x&& y >= this.Y && y <= (this.Y + this.Length - 1))
                {
                    return true;
                }
            }
            return false;
        }
 
    }
}