Author: toshok
Date: 2008-01-17 19:59:40 -0500 (Thu, 17 Jan 2008)
New Revision: 93225

Modified:
   trunk/olive/class/agclr/System.Windows/ChangeLog
   trunk/olive/class/agclr/System.Windows/Rect.cs
Log:
2008-01-17  Chris Toshok  <[EMAIL PROTECTED]>

        * Rect.cs: fix the Union/Intersect methods -- they were updating
        x/y and then accessing them implicitly through Right/Bottom.
        Also, in the intersect case, if the rectangle ends up being empty,
        clear it out so that Rect.Equals (Rect.Empty) returns true.  this
        gets DestroyAllInvaders working (woop!)



Modified: trunk/olive/class/agclr/System.Windows/ChangeLog
===================================================================
--- trunk/olive/class/agclr/System.Windows/ChangeLog    2008-01-18 00:32:46 UTC 
(rev 93224)
+++ trunk/olive/class/agclr/System.Windows/ChangeLog    2008-01-18 00:59:40 UTC 
(rev 93225)
@@ -1,3 +1,11 @@
+2008-01-17  Chris Toshok  <[EMAIL PROTECTED]>
+
+       * Rect.cs: fix the Union/Intersect methods -- they were updating
+       x/y and then accessing them implicitly through Right/Bottom.
+       Also, in the intersect case, if the rectangle ends up being empty,
+       clear it out so that Rect.Equals (Rect.Empty) returns true.  this
+       gets DestroyAllInvaders working (woop!)
+
 2007-12-19  Stephane Delcroix  <[EMAIL PROTECTED]>
 
         * DependencyObject.cs: adding LINEARGRADIENTBRUSH and 

Modified: trunk/olive/class/agclr/System.Windows/Rect.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/Rect.cs      2008-01-18 00:32:46 UTC 
(rev 93224)
+++ trunk/olive/class/agclr/System.Windows/Rect.cs      2008-01-18 00:59:40 UTC 
(rev 93225)
@@ -186,10 +186,19 @@
                
                public void Intersect(Rect rect)
                {
-                       x = Math.Max (x, rect.x);
-                       y = Math.Max (y, rect.y);
-                       w = Math.Min (Right, rect.Right) - x;
-                       h = Math.Min (Bottom, rect.Bottom) - y; 
+                       double new_x = Math.Max (x, rect.x);
+                       double new_y = Math.Max (y, rect.y);
+                       double new_w = Math.Min (Right, rect.Right) - new_x;
+                       double new_h = Math.Min (Bottom, rect.Bottom) - new_y; 
+
+                       x = new_x;
+                       y = new_y;
+                       w = new_w;
+                       h = new_h;
+
+                       if (w < 0 || h < 0) {
+                               x = y = w = h = 0;
+                       }
                }
                
                public static Rect Intersect(Rect rect1, Rect rect2)
@@ -215,10 +224,15 @@
                
                public void Union(Rect rect)
                {
-                       x = Math.Min (x, rect.x);
-                       y = Math.Min (y, rect.y);
-                       w = Math.Max (Right, rect.Right) - x;
-                       h = Math.Max (Bottom, rect.Bottom) - y;
+                       double new_x = Math.Min (x, rect.x);
+                       double new_y = Math.Min (y, rect.y);
+                       double new_w = Math.Max (Right, rect.Right) - x;
+                       double new_h = Math.Max (Bottom, rect.Bottom) - y;
+
+                       x = new_x;
+                       y = new_y;
+                       w = new_w;
+                       h = new_h;
                }
                
                public void Union(Point point)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to