Author: schaveyt
Date: 2007-03-11 21:54:16 -0500 (Sun, 11 Mar 2007)
New Revision: 74089
Modified:
trunk/cocoa-sharp/src/Cocoa/Rect.cs
Log:
Added Contains and ToString methods
Modified: trunk/cocoa-sharp/src/Cocoa/Rect.cs
===================================================================
--- trunk/cocoa-sharp/src/Cocoa/Rect.cs 2007-03-12 02:49:07 UTC (rev 74088)
+++ trunk/cocoa-sharp/src/Cocoa/Rect.cs 2007-03-12 02:54:16 UTC (rev 74089)
@@ -1,18 +1,42 @@
+using System;
using Cocoa;
namespace Cocoa {
- public struct Rect {
+
+ public struct Rect
+ {
public Point Origin;
public Size Size;
-
+
public Rect (Point origin, Size size) {
this.Origin = origin;
this.Size = size;
}
-
+
public Rect (float x, float y, float width, float height) {
this.Origin = new Point (x, y);
this.Size = new Size (width, height);
}
+
+ public bool Contains( Point aPoint )
+ {
+ if( aPoint.X >= Origin.X && aPoint.X <= (Origin.X + Size.Width ) )
+ {
+ if( aPoint.Y >= Origin.Y && aPoint.Y <= (Origin.Y +
Size.Height ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public override string ToString()
+ {
+ return System.String.Format( "x: {0}, y: {1}, width: {2}, heigth:
{3}",
+ Origin.X, Origin.Y, Size.Width,
Size.Height );
+ }
}
+
+
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches