@@ -21,14 +21,20 @@ public Rectangle(Point location, Size size) : this()
2121 Width = size . Width ;
2222 Height = size . Height ;
2323 }
24-
25- public int Bottom { get { return Y + Height ; } }
24+
25+ public int Bottom
26+ {
27+ get { return Y + Height ; }
28+ }
2629 public int Height { get ; set ; }
2730 public bool IsEmpty
2831 {
2932 get { return X == 0 && Y == 0 && Width == 0 && Height == 0 ; }
3033 }
31- public int Left { get { return X ; } }
34+ public int Left
35+ {
36+ get { return X ; }
37+ }
3238 public Point Location
3339 {
3440 get { return new Point ( X , Y ) ; }
@@ -38,7 +44,10 @@ public Point Location
3844 Y = value . Y ;
3945 }
4046 }
41- public int Right { get { return X + Width ; } }
47+ public int Right
48+ {
49+ get { return X + Width ; }
50+ }
4251 public Size Size
4352 {
4453 get { return new Size ( Width , Height ) ; }
@@ -48,11 +57,14 @@ public Size Size
4857 Height = value . Height ;
4958 }
5059 }
51- public int Top { get { return Y ; } }
60+ public int Top
61+ {
62+ get { return Y ; }
63+ }
5264 public int Width { get ; set ; }
5365 public int X { get ; set ; }
5466 public int Y { get ; set ; }
55-
67+
5668 public static bool operator != ( Rectangle left , Rectangle right )
5769 {
5870 return ! ( left == right ) ;
@@ -84,9 +96,9 @@ public static Rectangle Intersect(Rectangle a, Rectangle b)
8496 int y1 = Math . Max ( a . Y , b . Y ) ;
8597 int y2 = Math . Min ( a . Y + a . Height , b . Y + b . Height ) ;
8698
87- if ( x2 >= x1 && y2 >= y1 )
99+ if ( x2 >= x1 && y2 >= y1 )
88100 return new Rectangle ( x1 , y1 , x2 - x1 , y2 - y1 ) ;
89-
101+
90102 return Empty ;
91103 }
92104 public static Rectangle Union ( Rectangle a , Rectangle b )
@@ -98,7 +110,7 @@ public static Rectangle Union(Rectangle a, Rectangle b)
98110
99111 return new Rectangle ( x1 , y1 , x2 - x1 , y2 - y1 ) ;
100112 }
101-
113+
102114 public bool Contains ( int x , int y )
103115 {
104116 return X <= x && x < X + Width && Y <= y && y < Y + Height ;
@@ -117,8 +129,8 @@ public bool Equals(Rectangle other)
117129 }
118130 public override bool Equals ( object obj )
119131 {
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 ;
122134 return rect . X == X && rect . Y == Y && rect . Width == Width && rect . Height == Height ;
123135 }
124136 public override int GetHashCode ( )
@@ -163,8 +175,8 @@ public void Offset(int x, int y)
163175 public override string ToString ( )
164176 {
165177 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 ) + "}" ;
168180 }
169181 }
170- }
182+ }
0 commit comments