Microsoft.Xna.Framework.Rectangle vs. System.Drawing.Rectangle

I noticed that the XNA framework Rectangle does not have a Contains method like the System.Drawing.Rectangle.

http://msdn2.microsoft.com/en-us/library/system.drawing.rectangle.contains.aspx

I found this function handy for handling mouse clicks on my 2D tile map. Is this by design, a bug, or yet to be implemented?

Thanks,

Trey

[540 byte] By [TreyTro] at [2007-12-24]
# 1
Thanks for the feedback. This is something we'll look into adding.
MitchWalker-MSFT at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 2
How about adding the rest of the missing System.Drawing.Rectangle methods (Inflate, Intersect, IntersectWith, Offset, Union) as well? I've added a suggestion on this already.
JimPerry at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 3
Union and Intersection at least would be nice. The other ones... no big loss.
KrisNye at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 4
I could see where Offset would be useful for moving sprites. The would probably be used by someone at some point. Why have confusion and not have them have the same methods?
JimPerry at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 5

Greetings,

I posted a suggestion for the Contains function on Connection before finding this post. Sorry XNA team.

Here is what I am doing to solve the Rectangle.Contains overload for a X and Y mouse point. I am using it in a Button class so the button object has a Class level member called ButtonRect. But this function could be public in a helper class that has a Rectangle as a parameter as well.

// helper until XNA supports

private bool Contains(int x, int y)

{

if ((x > this.ButtonRect.Left && x < this.ButtonRect.Right) &&

(y < this.ButtonRect.Bottom && y > this.ButtonRect.Top))

return true;

else

return false;

}

I have been building today a Menu component like Mitch shows in his Components Demo. I am about 90% compled. I am assuming that the XNA team will provide one in the final release, but I do not want to wait.

Anyway, not sure if my code is the correct way, but it seems to work.

Micah

MicahN at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...