2005-08-10 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Wed, 10 Aug 2005 14:46:20 +0000 (14:46 -0000)
committerZoltan Varga <vargaz@gmail.com>
Wed, 10 Aug 2005 14:46:20 +0000 (14:46 -0000)
* Rectangle.cs (Intersect): Return a non-empty rectangle if the two
rectangles touch each other.

svn path=/trunk/mcs/; revision=48230

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

index f2e63c5ee2a93c641bcc8ce5b46daa130099cd0e..f4a0d4991e55fccedf10d5b47f4aac1f1fb92d43 100644 (file)
@@ -1,4 +1,9 @@
-2005-08-10 Konstantin Triger <kostat@mainsoft.com>
+2005-08-10  Zoltan Varga  <vargaz@freemail.hu>
+
+       * Rectangle.cs (Intersect): Return a non-empty rectangle if the two
+       rectangles touch each other.
+
+2005-08-09 Konstantin Triger <kostat@mainsoft.com>
 
        * Graphics.jvm.cs: Fixed DrawCurve.2005-08-10 Konstantin Triger <kostat@mainsoft.com>
 
index 3d75a33a64d5f578d8c5da8f64e8c17241c61c8b..6b96fe4f4f96d14b633ca48014056d7c47c027bd 100644 (file)
@@ -157,7 +157,9 @@ namespace System.Drawing
                
                public static Rectangle Intersect (Rectangle r1, Rectangle r2)
                {
-                       if (!r1.IntersectsWith (r2))
+                       // MS.NET returns a non-empty rectangle if the two rectangles
+                       // touch each other
+                       if (!r1.IntersectsWithInclusive (r2))
                                return Empty;
 
                        return Rectangle.FromLTRB (
@@ -584,6 +586,12 @@ namespace System.Drawing
                            (Top >= r.Bottom) || (Bottom <= r.Top));
                }
 
+               private bool IntersectsWithInclusive (Rectangle r)
+               {
+                       return !((Left > r.Right) || (Right < r.Left) ||
+                           (Top > r.Bottom) || (Bottom < r.Top));
+               }
+
                /// <summary>
                ///     Offset Method
                /// </summary>