This project is read-only.

Missing Rectangle.Intersects

Apr 2, 2009 at 12:21 AM
Edited Apr 2, 2009 at 12:22 AM

I saw that Rectangle.Intersects was missing, so I created an extension method :

public static bool Intersects(this Rectangle rectangle, Rectangle rectangle2)
    Rect rect = new Rect
        X = rectangle.X,
        Y = rectangle.Y,
        Width = rectangle.Width,
        Height = rectangle.Height    
    Rect rect2 = new Rect
        X = rectangle2.X,
        Y = rectangle2.Y,
        Width = rectangle2.Width,
        Height = rectangle2.Height


    return !(rect == Rect.Empty);

Feel free to re-use it if it's correct.

Thanks for your project.

If you need some help, feel free to contact me :)

Benjamin Roux [MVP Client App Dev]
Apr 2, 2009 at 6:16 PM

Thanks, I have a good rectangle intersects method around somewhere, I'll add this as an issue and implement it.