@@ -21,14 +21,20 @@ public Rectangle(Point location, Size size) : this()
21
21
Width = size . Width ;
22
22
Height = size . Height ;
23
23
}
24
-
25
- public int Bottom { get { return Y + Height ; } }
24
+
25
+ public int Bottom
26
+ {
27
+ get { return Y + Height ; }
28
+ }
26
29
public int Height { get ; set ; }
27
30
public bool IsEmpty
28
31
{
29
32
get { return X == 0 && Y == 0 && Width == 0 && Height == 0 ; }
30
33
}
31
- public int Left { get { return X ; } }
34
+ public int Left
35
+ {
36
+ get { return X ; }
37
+ }
32
38
public Point Location
33
39
{
34
40
get { return new Point ( X , Y ) ; }
@@ -38,7 +44,10 @@ public Point Location
38
44
Y = value . Y ;
39
45
}
40
46
}
41
- public int Right { get { return X + Width ; } }
47
+ public int Right
48
+ {
49
+ get { return X + Width ; }
50
+ }
42
51
public Size Size
43
52
{
44
53
get { return new Size ( Width , Height ) ; }
@@ -48,11 +57,14 @@ public Size Size
48
57
Height = value . Height ;
49
58
}
50
59
}
51
- public int Top { get { return Y ; } }
60
+ public int Top
61
+ {
62
+ get { return Y ; }
63
+ }
52
64
public int Width { get ; set ; }
53
65
public int X { get ; set ; }
54
66
public int Y { get ; set ; }
55
-
67
+
56
68
public static bool operator != ( Rectangle left , Rectangle right )
57
69
{
58
70
return ! ( left == right ) ;
@@ -84,9 +96,9 @@ public static Rectangle Intersect(Rectangle a, Rectangle b)
84
96
int y1 = Math . Max ( a . Y , b . Y ) ;
85
97
int y2 = Math . Min ( a . Y + a . Height , b . Y + b . Height ) ;
86
98
87
- if ( x2 >= x1 && y2 >= y1 )
99
+ if ( x2 >= x1 && y2 >= y1 )
88
100
return new Rectangle ( x1 , y1 , x2 - x1 , y2 - y1 ) ;
89
-
101
+
90
102
return Empty ;
91
103
}
92
104
public static Rectangle Union ( Rectangle a , Rectangle b )
@@ -98,7 +110,7 @@ public static Rectangle Union(Rectangle a, Rectangle b)
98
110
99
111
return new Rectangle ( x1 , y1 , x2 - x1 , y2 - y1 ) ;
100
112
}
101
-
113
+
102
114
public bool Contains ( int x , int y )
103
115
{
104
116
return X <= x && x < X + Width && Y <= y && y < Y + Height ;
@@ -117,8 +129,8 @@ public bool Equals(Rectangle other)
117
129
}
118
130
public override bool Equals ( object obj )
119
131
{
120
- if ( obj is Rectangle == false ) return false ;
121
- var rect = ( Rectangle ) obj ;
132
+ if ( ! ( obj is Rectangle ) ) return false ;
133
+ var rect = ( Rectangle ) obj ;
122
134
return rect . X == X && rect . Y == Y && rect . Width == Width && rect . Height == Height ;
123
135
}
124
136
public override int GetHashCode ( )
@@ -163,8 +175,8 @@ public void Offset(int x, int y)
163
175
public override string ToString ( )
164
176
{
165
177
return "{X=" + X . ToString ( CultureInfo . CurrentCulture ) + ",Y=" + Y . ToString ( CultureInfo . CurrentCulture ) +
166
- ",Width=" + Width . ToString ( CultureInfo . CurrentCulture ) +
167
- ",Height=" + Height . ToString ( CultureInfo . CurrentCulture ) + "}" ;
178
+ ",Width=" + Width . ToString ( CultureInfo . CurrentCulture ) +
179
+ ",Height=" + Height . ToString ( CultureInfo . CurrentCulture ) + "}" ;
168
180
}
169
181
}
170
- }
182
+ }
0 commit comments