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
32 : this ((geom
.Area
) InfiniteRegion
.NativeObject
.clone ())
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");
143 geom
.Area a
= (geom
.Area
) region
.NativeObject
.clone ();
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 if (NativeObject
.equals(InfiniteRegion
.NativeObject
))
224 NativeObject
.transform(geom
.AffineTransform
.getTranslateInstance(
230 #region IsVisible [TODO]
232 public bool IsVisible (int x
, int y
, Graphics g
)
234 return IsVisible((float)x
, (float)y
, g
);
237 public bool IsVisible (int x
, int y
, int width
, int height
)
239 return IsVisible((float)x
, (float)y
, (float)width
, (float)height
);
242 public bool IsVisible (int x
, int y
, int width
, int height
, Graphics g
)
244 return IsVisible((float)x
, (float)y
, (float)width
, (float)height
, g
);
247 public bool IsVisible (Point point
)
249 return IsVisible(point
.X
, point
.Y
);
252 public bool IsVisible (PointF point
)
254 return IsVisible(point
.X
, point
.Y
);
257 public bool IsVisible (Point point
, Graphics g
)
259 return IsVisible(point
.X
, point
.Y
, g
);
262 public bool IsVisible (PointF point
, Graphics g
)
264 return IsVisible(point
.X
, point
.Y
, g
);
267 public bool IsVisible (Rectangle rect
)
269 return IsVisible(rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
272 public bool IsVisible (RectangleF rect
)
274 return IsVisible(rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
);
277 public bool IsVisible (Rectangle rect
, Graphics g
)
279 return IsVisible(rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, g
);
282 public bool IsVisible (RectangleF rect
, Graphics g
)
284 return IsVisible(rect
.X
, rect
.Y
, rect
.Width
, rect
.Height
, g
);
287 public bool IsVisible (float x
, float y
)
289 return NativeObject
.contains(x
,y
);
292 public bool IsVisible (float x
, float y
, Graphics g
)
295 throw new ArgumentNullException("graphics");
296 return NativeObject
.contains(x
,y
);
299 public bool IsVisible (float x
, float y
, float width
, float height
)
301 return NativeObject
.intersects(x
,y
,width
,height
);
304 public bool IsVisible (float x
, float y
, float width
, float height
, Graphics g
)
307 throw new ArgumentNullException("graphics");
308 return NativeObject
.intersects(x
,y
,width
,height
);
313 public bool IsEmpty(Graphics g
)
316 throw new ArgumentNullException("graphics");
317 return NativeObject
.isEmpty();
322 public bool IsInfinite(Graphics g
)
325 throw new ArgumentNullException("graphics");
326 //probably too naive.
327 return NativeObject
.equals(InfiniteRegion
.NativeObject
);
332 public void MakeEmpty()
334 NativeObject
.reset();
339 public void MakeInfinite()
341 Shape
= (geom
.Area
) InfiniteRegion
.NativeObject
.clone ();
346 public bool Equals(Region region
, Graphics g
)
349 throw new ArgumentNullException("graphics");
350 return NativeObject
.equals(region
.NativeObject
);
355 public RegionData
GetRegionData()
357 throw new NotImplementedException();
361 public IntPtr
GetHrgn(Graphics g
) {
362 throw new NotImplementedException();
366 public RectangleF
[] GetRegionScans(Matrix matrix
)
368 throw new NotImplementedException();
372 public void Transform(Matrix matrix
)
375 throw new ArgumentNullException("matrix");
376 if (NativeObject
.equals(InfiniteRegion
.NativeObject
))
378 NativeObject
.transform(matrix
.NativeObject
);
383 public Region
Clone()
385 return new Region ((geom
.Area
) NativeObject
.clone ());