1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
using System;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
using awt = java.awt;
using geom = java.awt.geom;
namespace System.Drawing
{
[ComVisible (false)]
public sealed class Region : BasicShape
{
#region Member Vars
internal static readonly Region InfiniteRegion = new Region(new Rectangle(-0x400000, -0x400000, 0x800000, 0x800000));
#endregion
#region Internals
internal geom.Area NativeObject
{
get
{
return (geom.Area)Shape;
}
}
#endregion
#region Ctors. and Dtor
public Region() : this((geom.Area)InfiniteRegion.NativeObject.clone())
{
}
internal Region(geom.Area native) : base(native)
{
}
public Region (GraphicsPath path) : this(new geom.Area(path.NativeObject))
{
}
public Region (Rectangle rect) : this(new geom.Area(rect.NativeObject))
{
}
public Region (RectangleF rect) : this(new geom.Area(rect.NativeObject))
{
}
[MonoTODO]
public Region (RegionData region_data) : this((geom.Area)null)
{
throw new NotImplementedException ();
}
#endregion
#region Union
public void Union (GraphicsPath path)
{
if (path == null)
throw new ArgumentNullException("path");
NativeObject.add(new geom.Area(path.NativeObject));
}
public void Union (Rectangle rect)
{
NativeObject.add(new geom.Area(rect.NativeObject));
}
public void Union (RectangleF rect)
{
NativeObject.add(new geom.Area(rect.NativeObject));
}
public void Union (Region region)
{
if (region == null)
throw new ArgumentNullException("region");
NativeObject.add(region.NativeObject);
}
#endregion
#region Intersect
//
public void Intersect (GraphicsPath path)
{
if (path == null)
throw new ArgumentNullException("path");
NativeObject.intersect(new geom.Area(path.NativeObject));
}
public void Intersect (Rectangle rect)
{
NativeObject.intersect(new geom.Area(rect.NativeObject));
}
public void Intersect (RectangleF rect)
{
NativeObject.intersect(new geom.Area(rect.NativeObject));
}
public void Intersect (Region region)
{
if (region == null)
throw new ArgumentNullException("region");
NativeObject.intersect(region.NativeObject);
}
#endregion
#region Complement
//
public void Complement (GraphicsPath path)
{
if (path == null)
throw new ArgumentNullException("path");
geom.Area a = new geom.Area(path.NativeObject);
a.subtract(NativeObject);
Shape = a;
}
public void Complement (Rectangle rect)
{
geom.Area a = new geom.Area(rect.NativeObject);
a.subtract(NativeObject);
Shape = a;
}
public void Complement (RectangleF rect)
{
geom.Area a = new geom.Area(rect.NativeObject);
a.subtract(NativeObject);
Shape = a;
}
public void Complement (Region region)
{
if (region == null)
throw new ArgumentNullException("region");
geom.Area a = (geom.Area)region.NativeObject.clone();
a.subtract(NativeObject);
Shape = a;
}
#endregion
#region Exclude
//
public void Exclude (GraphicsPath path)
{
if (path == null)
throw new ArgumentNullException("path");
NativeObject.subtract(new geom.Area(path.NativeObject));
}
public void Exclude (Rectangle rect)
{
NativeObject.subtract(new geom.Area(rect.NativeObject));
}
public void Exclude (RectangleF rect)
{
NativeObject.subtract(new geom.Area(rect.NativeObject));
}
public void Exclude (Region region)
{
if (region == null)
throw new ArgumentNullException("region");
NativeObject.subtract(region.NativeObject);
}
#endregion
#region Xor
//
public void Xor (GraphicsPath path)
{
if (path == null)
throw new ArgumentNullException("path");
NativeObject.exclusiveOr(new geom.Area(path.NativeObject));
}
public void Xor (Rectangle rect)
{
NativeObject.exclusiveOr(new geom.Area(rect.NativeObject));
}
public void Xor (RectangleF rect)
{
NativeObject.exclusiveOr(new geom.Area(rect.NativeObject));
}
public void Xor (Region region)
{
if (region == null)
throw new ArgumentNullException("region");
NativeObject.exclusiveOr(region.NativeObject);
}
#endregion
#region GetBounds
//
public RectangleF GetBounds (Graphics graphics)
{
if (graphics == null)
throw new ArgumentNullException("graphics");
return new RectangleF(NativeObject.getBounds2D());
}
#endregion
#region Translate
//
public void Translate (int dx, int dy)
{
Translate((float)dx, (float)dy);
}
public void Translate (float dx, float dy)
{
NativeObject.transform(geom.AffineTransform.getTranslateInstance(
dx,
dy));
}
#endregion
#region IsVisible [TODO]
//
public bool IsVisible (int x, int y, Graphics g)
{
return IsVisible((float)x, (float)y, g);
}
public bool IsVisible (int x, int y, int width, int height)
{
return IsVisible((float)x, (float)y, (float)width, (float)height);
}
public bool IsVisible (int x, int y, int width, int height, Graphics g)
{
return IsVisible((float)x, (float)y, (float)width, (float)height, g);
}
public bool IsVisible (Point point)
{
return IsVisible(point.X, point.Y);
}
public bool IsVisible (PointF point)
{
return IsVisible(point.X, point.Y);
}
public bool IsVisible (Point point, Graphics g)
{
return IsVisible(point.X, point.Y, g);
}
public bool IsVisible (PointF point, Graphics g)
{
return IsVisible(point.X, point.Y, g);
}
public bool IsVisible (Rectangle rect)
{
return IsVisible(rect.X, rect.Y, rect.Width, rect.Height);
}
public bool IsVisible (RectangleF rect)
{
return IsVisible(rect.X, rect.Y, rect.Width, rect.Height);
}
public bool IsVisible (Rectangle rect, Graphics g)
{
return IsVisible(rect.X, rect.Y, rect.Width, rect.Height, g);
}
public bool IsVisible (RectangleF rect, Graphics g)
{
return IsVisible(rect.X, rect.Y, rect.Width, rect.Height, g);
}
public bool IsVisible (float x, float y)
{
return NativeObject.contains(x,y);
}
public bool IsVisible (float x, float y, Graphics g)
{
if (g == null)
throw new ArgumentNullException("graphics");
return NativeObject.contains(x,y);
}
public bool IsVisible (float x, float y, float width, float height)
{
return NativeObject.intersects(x,y,width,height);
}
public bool IsVisible (float x, float y, float width, float height, Graphics g)
{
if (g == null)
throw new ArgumentNullException("graphics");
return NativeObject.intersects(x,y,width,height);
}
#endregion
#region IsEmpty
public bool IsEmpty(Graphics g)
{
if (g == null)
throw new ArgumentNullException("graphics");
return NativeObject.isEmpty();
}
#endregion
#region IsInfinite
public bool IsInfinite(Graphics g)
{
if (g == null)
throw new ArgumentNullException("graphics");
//probably too naive.
return NativeObject.equals(InfiniteRegion.NativeObject);
}
#endregion
#region MakeEmpty
public void MakeEmpty()
{
NativeObject.reset();
}
#endregion
#region MakeInfinite
public void MakeInfinite()
{
Shape = (geom.Area)InfiniteRegion.NativeObject.clone();
}
#endregion
#region Equals
public bool Equals(Region region, Graphics g)
{
if (g == null)
throw new ArgumentNullException("graphics");
return NativeObject.equals(region.NativeObject);
}
#endregion
[MonoTODO]
public RegionData GetRegionData()
{
throw new NotImplementedException();
}
[MonoTODO]
public IntPtr GetHrgn(Graphics g) {
throw new NotImplementedException();
}
public RectangleF[] GetRegionScans(Matrix matrix)
{
throw new NotSupportedException();
}
#region Transform
public void Transform(Matrix matrix)
{
if (matrix == null)
throw new ArgumentNullException("matrix");
NativeObject.transform(matrix.NativeObject);
}
#endregion
#region Clone
public Region Clone()
{
return new Region((geom.Area)NativeObject.clone());
}
#endregion
}
}
|