RectangleF.cs: Fix edge intersection. Path by Brian Browning. [Fix bug #431587]
authorSebastien Pouliot <sebastien@ximian.com>
Mon, 6 Oct 2008 15:05:57 +0000 (15:05 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Mon, 6 Oct 2008 15:05:57 +0000 (15:05 -0000)
svn path=/trunk/mcs/; revision=114953

mcs/class/System.Drawing/System.Drawing/ChangeLog
mcs/class/System.Drawing/System.Drawing/RectangleF.cs

index d1ca4251506444adfba2299c160e4d4951c61e96..19fb5a959e10f7ee9817cc668872baf30558f42b 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-06  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * RectangleF.cs: Fix edge intersection. Path by Brian Browning.
+       [Fix bug #431587]
+
 2008-08-08  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * Icon.cs (InitFromStreamWithSize): Use temp ArrayList for IconDirEntry
index 6de9088ecc04fe28c35b2c2ac75fd50eb026cc94..00e49581b82328da4939402ceacf6c3025e66c31 100644 (file)
@@ -128,7 +128,9 @@ namespace System.Drawing
                public static RectangleF Intersect (RectangleF a, 
                                                    RectangleF b)
                {
-                       if (!a.IntersectsWith (b)) 
+                       // MS.NET returns a non-empty rectangle if the two rectangles
+                       // touch each other
+                       if (!a.IntersectsWithInclusive (b))
                                return Empty;
 
                        return FromLTRB (
@@ -531,6 +533,12 @@ namespace System.Drawing
                            (Top >= rect.Bottom) || (Bottom <= rect.Top));
                }
 
+               private bool IntersectsWithInclusive (RectangleF r)
+               {
+                       return !((Left > r.Right) || (Right < r.Left) ||
+                           (Top > r.Bottom) || (Bottom < r.Top));
+               }
+
                /// <summary>
                ///     Offset Method
                /// </summary>