3 using System.Drawing.Drawing2D;
4 using System.Runtime.InteropServices;
7 using geom = java.awt.geom;
9 namespace System.Drawing
12 public sealed class Region : BasicShape
15 internal static readonly Region InfiniteRegion = new Region(new Rectangle(-0x400000, -0x400000, 0x800000, 0x800000));
19 internal geom.Area NativeObject
23 return (geom.Area)Shape;
28 #region Ctors. and Dtor
\r
32 : this ((geom.Area) InfiniteRegion.NativeObject.MemberwiseClone ())
36 internal Region(geom.Area native) : base(native)
41 public Region (GraphicsPath path) : this(new geom.Area(path.NativeObject))
45 public Region (Rectangle rect) : this(new geom.Area(rect.NativeObject))
49 public Region (RectangleF rect) : this(new geom.Area(rect.NativeObject))
54 public Region (RegionData region_data) : this((geom.Area)null)
56 throw new NotImplementedException ();
61 public void Union (GraphicsPath path)
64 throw new ArgumentNullException("path");
65 NativeObject.add(new geom.Area(path.NativeObject));
69 public void Union (Rectangle rect)
71 NativeObject.add(new geom.Area(rect.NativeObject));
74 public void Union (RectangleF rect)
76 NativeObject.add(new geom.Area(rect.NativeObject));
79 public void Union (Region region)
82 throw new ArgumentNullException("region");
83 NativeObject.add(region.NativeObject);
89 public void Intersect (GraphicsPath path)
92 throw new ArgumentNullException("path");
93 NativeObject.intersect(new geom.Area(path.NativeObject));
96 public void Intersect (Rectangle rect)
98 NativeObject.intersect(new geom.Area(rect.NativeObject));
101 public void Intersect (RectangleF rect)
103 NativeObject.intersect(new geom.Area(rect.NativeObject));
106 public void Intersect (Region region)
109 throw new ArgumentNullException("region");
110 NativeObject.intersect(region.NativeObject);
116 public void Complement (GraphicsPath path)
119 throw new ArgumentNullException("path");
120 geom.Area a = new geom.Area(path.NativeObject);
121 a.subtract(NativeObject);
125 public void Complement (Rectangle rect)
127 geom.Area a = new geom.Area(rect.NativeObject);
128 a.subtract(NativeObject);
132 public void Complement (RectangleF rect)
134 geom.Area a = new geom.Area(rect.NativeObject);
135 a.subtract(NativeObject);
139 public void Complement (Region region)
142 throw new ArgumentNullException("region");
\r
143 geom.Area a = (geom.Area) region.NativeObject.MemberwiseClone ();
144 a.subtract(NativeObject);
151 public void Exclude (GraphicsPath path)
154 throw new ArgumentNullException("path");
155 NativeObject.subtract(new geom.Area(path.NativeObject));
158 public void Exclude (Rectangle rect)
160 NativeObject.subtract(new geom.Area(rect.NativeObject));
163 public void Exclude (RectangleF rect)
165 NativeObject.subtract(new geom.Area(rect.NativeObject));
168 public void Exclude (Region region)
171 throw new ArgumentNullException("region");
172 NativeObject.subtract(region.NativeObject);
178 public void Xor (GraphicsPath path)
181 throw new ArgumentNullException("path");
182 NativeObject.exclusiveOr(new geom.Area(path.NativeObject));
185 public void Xor (Rectangle rect)
187 NativeObject.exclusiveOr(new geom.Area(rect.NativeObject));
190 public void Xor (RectangleF rect)
192 NativeObject.exclusiveOr(new geom.Area(rect.NativeObject));
195 public void Xor (Region region)
198 throw new ArgumentNullException("region");
199 NativeObject.exclusiveOr(region.NativeObject);
205 public RectangleF GetBounds (Graphics graphics)
207 if (graphics == null)
208 throw new ArgumentNullException("graphics");
209 return new RectangleF(NativeObject.getBounds2D());
215 public void Translate (int dx, int dy)
217 Translate((float)dx, (float)dy);
220 public void Translate (float dx, float dy)
222 NativeObject.transform(geom.AffineTransform.getTranslateInstance(
228 #region IsVisible [TODO]
230 public bool IsVisible (int x, int y, Graphics g)
232 return IsVisible((float)x, (float)y, g);
235 public bool IsVisible (int x, int y, int width, int height)
237 return IsVisible((float)x, (float)y, (float)width, (float)height);
240 public bool IsVisible (int x, int y, int width, int height, Graphics g)
242 return IsVisible((float)x, (float)y, (float)width, (float)height, g);
245 public bool IsVisible (Point point)
247 return IsVisible(point.X, point.Y);
250 public bool IsVisible (PointF point)
252 return IsVisible(point.X, point.Y);
255 public bool IsVisible (Point point, Graphics g)
257 return IsVisible(point.X, point.Y, g);
260 public bool IsVisible (PointF point, Graphics g)
262 return IsVisible(point.X, point.Y, g);
265 public bool IsVisible (Rectangle rect)
267 return IsVisible(rect.X, rect.Y, rect.Width, rect.Height);
270 public bool IsVisible (RectangleF rect)
272 return IsVisible(rect.X, rect.Y, rect.Width, rect.Height);
275 public bool IsVisible (Rectangle rect, Graphics g)
277 return IsVisible(rect.X, rect.Y, rect.Width, rect.Height, g);
280 public bool IsVisible (RectangleF rect, Graphics g)
282 return IsVisible(rect.X, rect.Y, rect.Width, rect.Height, g);
285 public bool IsVisible (float x, float y)
287 return NativeObject.contains(x,y);
290 public bool IsVisible (float x, float y, Graphics g)
293 throw new ArgumentNullException("graphics");
294 return NativeObject.contains(x,y);
297 public bool IsVisible (float x, float y, float width, float height)
299 return NativeObject.intersects(x,y,width,height);
302 public bool IsVisible (float x, float y, float width, float height, Graphics g)
305 throw new ArgumentNullException("graphics");
306 return NativeObject.intersects(x,y,width,height);
311 public bool IsEmpty(Graphics g)
314 throw new ArgumentNullException("graphics");
315 return NativeObject.isEmpty();
320 public bool IsInfinite(Graphics g)
323 throw new ArgumentNullException("graphics");
324 //probably too naive.
325 return NativeObject.equals(InfiniteRegion.NativeObject);
330 public void MakeEmpty()
332 NativeObject.reset();
337 public void MakeInfinite()
339 Shape = (geom.Area) InfiniteRegion.NativeObject.MemberwiseClone ();
344 public bool Equals(Region region, Graphics g)
347 throw new ArgumentNullException("graphics");
348 return NativeObject.equals(region.NativeObject);
353 public RegionData GetRegionData()
355 throw new NotImplementedException();
359 public IntPtr GetHrgn(Graphics g) {
360 throw new NotImplementedException();
364 public RectangleF[] GetRegionScans(Matrix matrix)
366 throw new NotSupportedException();
370 public void Transform(Matrix matrix)
373 throw new ArgumentNullException("matrix");
374 NativeObject.transform(matrix.NativeObject);
379 public Region Clone()
381 return new Region ((geom.Area) NativeObject.MemberwiseClone ());