2005-10-04 Peter Dennis Bartok <pbartok@novell.com>
[mono.git] / mcs / class / System.Drawing / System.Drawing / Graphics.cs
1 //
2 // System.Drawing.Graphics.cs
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com) (stubbed out)
6 //      Alexandre Pigolkine(pigolkine@gmx.de)
7 //      Jordi Mas i Hernandez (jordi@ximian.com)
8 //
9 // Copyright (C) 2003 Ximian, Inc. (http://www.ximian.com)
10 //
11 // Copyright (C) 2004-2005 Novell, Inc. (http://www.novell.com)
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 // 
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 // 
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 //
32
33 using System.Drawing.Drawing2D;
34 using System.Drawing.Imaging;
35 using System.Drawing.Text;
36 using System.ComponentModel;
37 using System.Runtime.InteropServices;
38 using System.Security.Permissions;
39 using System.Text;
40
41 namespace System.Drawing
42 {
43         [ComVisible(false)]
44         public sealed class Graphics : MarshalByRefObject, IDisposable
45         {
46                 internal IntPtr nativeObject = IntPtr.Zero;
47                 private bool disposed = false;
48                 private static float defDpiX = 0;
49                 private static float defDpiY = 0;
50
51                 [ComVisible(false)]
52                 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
53                                                             int flags,
54                                                             int dataSize,
55                                                             IntPtr data,
56                                                             PlayRecordCallback callbackData);
57                 
58                 [ComVisible (false)]
59                 public delegate bool DrawImageAbort (IntPtr callbackData);
60
61                 private Graphics (IntPtr nativeGraphics)
62                 {
63                         nativeObject = nativeGraphics;
64                 }
65
66                 ~Graphics ()
67                 {
68                         Dispose ();                     
69                 }               
70
71                 static internal float systemDpiX {
72                         get {
73                                 if (defDpiX == 0) {
74                                         Bitmap bmp = new Bitmap (1, 1);
75                                         Graphics g = Graphics.FromImage (bmp);
76                                         defDpiX = g.DpiX;
77                                 }
78                                 return defDpiX;
79                         }
80                 }
81
82                 static internal float systemDpiY {
83                         get {
84                                 if (defDpiY == 0) {
85                                         Bitmap bmp = new Bitmap (1, 1);
86                                         Graphics g = Graphics.FromImage (bmp);
87                                         defDpiY = g.DpiY;
88                                 }
89                                 return defDpiY;
90                         }
91                 }
92
93                 internal IntPtr NativeObject {
94                         get {
95                                 return nativeObject;
96                         }
97
98                         set {
99                                 nativeObject = value;
100                         }
101                 }
102
103                 [MonoTODO]
104                 public void AddMetafileComment (byte [] data)
105                 {
106                         throw new NotImplementedException ();
107                 }
108
109                 
110                 public GraphicsContainer BeginContainer ()
111                 {
112                         int state;
113                         Status status;
114                         status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
115                         GDIPlus.CheckStatus (status);
116
117                         return new GraphicsContainer(state);
118                 }
119                 
120                 public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
121                 {
122                         int state;
123                         Status status;
124                         status = GDIPlus.GdipBeginContainerI (nativeObject, dstrect, srcrect, unit, out state);
125                         GDIPlus.CheckStatus (status);
126
127                         return new GraphicsContainer (state);
128                 }
129
130                 
131                 public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
132                 {
133                         int state;
134                         Status status;
135                         status = GDIPlus.GdipBeginContainer (nativeObject, dstrect, srcrect, unit, out state);
136                         GDIPlus.CheckStatus (status);
137
138                         return new GraphicsContainer (state);
139                 }
140
141                 
142                 public void Clear (Color color)
143                 {
144                         Status status;
145                         status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ());
146                         GDIPlus.CheckStatus (status);
147                 }
148
149                 public void Dispose ()
150                 {
151                         Status status;
152                         if (! disposed) {
153                                 status = GDIPlus.GdipDeleteGraphics (nativeObject);
154                                 nativeObject = IntPtr.Zero;
155                                 GDIPlus.CheckStatus (status);
156                                 disposed = true;                                
157                         }
158                         GC.SuppressFinalize(this);
159                 }
160
161                 
162                 public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
163                 {
164                         DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
165                 }
166
167                 
168                 public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
169                 {
170                         DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
171                 }
172
173                 
174                 public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
175                 {
176                         Status status;
177                         status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
178                                         x, y, width, height, startAngle, sweepAngle);
179                         GDIPlus.CheckStatus (status);
180                 }
181
182                 // Microsoft documentation states that the signature for this member should be
183                 // public void DrawArc( Pen pen,  int x,  int y,  int width,  int height,   int startAngle,
184                 // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
185                 public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
186                 {
187                         Status status;
188                         status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
189                                                 x, y, width, height, startAngle, sweepAngle);
190                         GDIPlus.CheckStatus (status);
191                 }
192
193                 public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
194                 {
195                         Status status;
196                         status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
197                                                         pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
198                                                         pt3.Y, pt4.X, pt4.Y);
199                         GDIPlus.CheckStatus (status);
200                 }
201
202                 public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
203                 {
204                         Status status;
205                         status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
206                                                         pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
207                                                         pt3.Y, pt4.X, pt4.Y);
208                         GDIPlus.CheckStatus (status);
209                 }
210
211                 public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
212                 {
213                         Status status;
214                         status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
215                                                         y1, x2, y2, x3, y3, x4, y4);
216                         GDIPlus.CheckStatus (status);
217                 }
218
219                 public void DrawBeziers (Pen pen, Point [] points)
220                 {
221                         int length = points.Length;
222                         Status status;
223
224                         if (length < 3)
225                                 return;
226
227                         for (int i = 0; i < length; i += 3) {
228                                 Point p1 = points [i];
229                                 Point p2 = points [i + 1];
230                                 Point p3 = points [i + 2];
231                                 Point p4 = points [i + 3];
232
233                                 status = GDIPlus.GdipDrawBezier (nativeObject, 
234                                                         pen.nativeObject,
235                                                         p1.X, p1.Y, p2.X, p2.Y, 
236                                                         p3.X, p3.Y, p4.X, p4.Y);
237                                 GDIPlus.CheckStatus (status);
238                         }
239                 }
240
241                 public void DrawBeziers (Pen pen, PointF [] points)
242                 {
243                         int length = points.Length;
244                         Status status;
245
246                         if (length < 3)
247                                 return;
248
249                         for (int i = 0; i < length; i += 3) {
250                                 PointF p1 = points [i];
251                                 PointF p2 = points [i + 1];
252                                 PointF p3 = points [i + 2];
253                                 PointF p4 = points [i + 3];
254
255                                 status = GDIPlus.GdipDrawBezier (nativeObject, 
256                                                         pen.nativeObject,
257                                                         p1.X, p1.Y, p2.X, p2.Y, 
258                                                         p3.X, p3.Y, p4.X, p4.Y);
259                                 GDIPlus.CheckStatus (status);
260                         }
261                 }
262
263                 
264                 public void DrawClosedCurve (Pen pen, PointF [] points)
265                 {
266                         Status status;
267                         status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
268                         GDIPlus.CheckStatus (status);
269                 }
270                 
271                 public void DrawClosedCurve (Pen pen, Point [] points)
272                 {
273                         Status status;
274                         status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
275                         GDIPlus.CheckStatus (status);
276                 }
277                         
278                 public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
279                 {
280                         Status status;
281                         status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
282                         GDIPlus.CheckStatus (status);
283                 }
284                 
285                 public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
286                 {
287                         Status status;
288                         status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
289                         GDIPlus.CheckStatus (status);
290                 }
291                 
292                 public void DrawCurve (Pen pen, Point [] points)
293                 {
294                         Status status;
295                         status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
296                         GDIPlus.CheckStatus (status);
297                 }
298                 
299                 public void DrawCurve (Pen pen, PointF [] points)
300                 {
301                         Status status;
302                         status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
303                         GDIPlus.CheckStatus (status);
304                 }
305                 
306                 public void DrawCurve (Pen pen, PointF [] points, float tension)
307                 {
308                         Status status;
309                         status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
310                         GDIPlus.CheckStatus (status);
311                 }
312                 
313                 public void DrawCurve (Pen pen, Point [] points, float tension)
314                 {
315                         Status status;
316                         status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);              
317                         GDIPlus.CheckStatus (status);
318                 }
319                 
320                 
321                 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
322                 {
323                         Status status;
324                         status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
325                                                         points, points.Length, offset,
326                                                         numberOfSegments, 0.5f);
327                         GDIPlus.CheckStatus (status);
328                 }
329
330                 public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
331                 {
332                         Status status;
333                         status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
334                                                         points, points.Length, offset,
335                                                         numberOfSegments, tension);
336                         GDIPlus.CheckStatus (status);
337                 }
338
339                 
340                 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
341                 {
342                         Status status;
343                         status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
344                                                         points, points.Length, offset,
345                                                         numberOfSegments, tension);
346                         GDIPlus.CheckStatus (status);
347                 }
348
349                 public void DrawEllipse (Pen pen, Rectangle rect)
350                 {
351                         DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
352                 }
353
354                 public void DrawEllipse (Pen pen, RectangleF rect)
355                 {
356                         DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
357                 }
358
359                 public void DrawEllipse (Pen pen, int x, int y, int width, int height)
360                 {
361                         Status status;
362                         status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
363                         GDIPlus.CheckStatus (status);
364                 }
365
366                 public void DrawEllipse (Pen pen, float x, float y, float width, float height)
367                 {
368                         Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
369                         GDIPlus.CheckStatus (status);
370                 }
371
372                 public void DrawIcon (Icon icon, Rectangle targetRect)
373                 {
374                         Image img = icon.ToBitmap ();
375                         DrawImage (img, targetRect);
376                 }
377
378                 public void DrawIcon (Icon icon, int x, int y)
379                 {
380                         Image img = icon.ToBitmap ();
381                         DrawImage (img, x, y);
382                 }
383
384                 public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
385                 {
386                         Image img = icon.ToBitmap ();
387                         DrawImageUnscaled (img, targetRect);
388                 }
389                 
390                 public void DrawImage (Image image, RectangleF rect)
391                 {
392                         Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
393                         GDIPlus.CheckStatus (status);
394                 }
395
396                 
397                 public void DrawImage (Image image, PointF point)
398                 {
399                         Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
400                         GDIPlus.CheckStatus (status);
401                 }
402
403                 
404                 public void DrawImage (Image image, Point [] destPoints)
405                 {
406                         Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
407                         GDIPlus.CheckStatus (status);
408                 }
409
410                 
411                 public void DrawImage (Image image, Point point)
412                 {
413                         DrawImage (image, point.X, point.Y);
414                 }
415
416                 
417                 public void DrawImage (Image image, Rectangle rect)
418                 {
419                         DrawImage (image, rect.X, rect.Y, rect.Width, rect.Height);
420                 }
421
422                 
423                 public void DrawImage (Image image, PointF [] destPoints)
424                 {
425                         Status status = GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
426                         GDIPlus.CheckStatus (status);
427                 }
428
429                 
430                 public void DrawImage (Image image, int x, int y)
431                 {
432                         Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
433                         GDIPlus.CheckStatus (status);
434                 }
435
436                 
437                 public void DrawImage (Image image, float x, float y)
438                 {
439                         Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
440                         GDIPlus.CheckStatus (status);
441                 }
442
443                 
444                 public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
445                 {
446                         Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
447                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
448                                 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
449                                 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
450                         GDIPlus.CheckStatus (status);
451                 }
452                 
453                 public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
454                 {                       
455                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
456                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
457                                 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
458                                 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
459                         GDIPlus.CheckStatus (status);
460                 }
461
462                 
463                 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
464                 {
465                         Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
466                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y, 
467                                 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero, 
468                                 null, IntPtr.Zero);
469                         GDIPlus.CheckStatus (status);
470                 }
471
472                 
473                 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
474                 {
475                         
476                         Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
477                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y, 
478                                 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero, 
479                                 null, IntPtr.Zero);
480                         GDIPlus.CheckStatus (status);
481                 }
482
483                 
484                 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, 
485                                 ImageAttributes imageAttr)
486                 {
487                         Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
488                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
489                                 srcRect.Width, srcRect.Height, srcUnit,
490                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
491                         GDIPlus.CheckStatus (status);
492                 }
493                 
494                 public void DrawImage (Image image, float x, float y, float width, float height)
495                 {
496                         Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
497                            width, height);
498                         GDIPlus.CheckStatus (status);
499                 }
500
501                 
502                 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, 
503                                 ImageAttributes imageAttr)
504                 {
505                         Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
506                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
507                                 srcRect.Width, srcRect.Height, srcUnit, 
508                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
509                         GDIPlus.CheckStatus (status);
510                 }
511
512                 
513                 public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
514                 {                       
515                         Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
516                         GDIPlus.CheckStatus (status);
517                 }
518                 
519                 public void DrawImage (Image image, int x, int y, int width, int height)
520                 {
521                         Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
522                         GDIPlus.CheckStatus (status);
523                 }
524
525                 public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
526                 {                       
527                         Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
528                         GDIPlus.CheckStatus (status);
529                 }
530
531                 
532                 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
533                 {
534                         Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
535                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
536                                 srcRect.Width, srcRect.Height, srcUnit, 
537                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
538                         GDIPlus.CheckStatus (status);
539                 }
540
541                 
542                 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
543                 {
544                         
545                         Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
546                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
547                                 srcRect.Width, srcRect.Height, srcUnit, 
548                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
549                         GDIPlus.CheckStatus (status);
550                 }
551
552                 
553                 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
554                 {
555
556                         Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
557                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y, 
558                                 srcRect.Width, srcRect.Height, srcUnit, 
559                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
560                         GDIPlus.CheckStatus (status);
561                 }
562
563                 
564                 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
565                 {
566                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
567                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
568                                 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero, 
569                                 null, IntPtr.Zero);
570                         GDIPlus.CheckStatus (status);                                   
571                 }
572                 
573                 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
574                 {
575                         Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
576                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
577                                 srcRect.Width, srcRect.Height, srcUnit, 
578                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
579                         GDIPlus.CheckStatus (status);
580                 }
581
582                 
583                 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
584                 {
585                         Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
586                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
587                                 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero, 
588                                 null, IntPtr.Zero);
589                         GDIPlus.CheckStatus (status);
590                 }
591
592                 
593                 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
594                 {
595                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
596                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
597                                 srcX, srcY, srcWidth, srcHeight, srcUnit,
598                                 imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
599                         GDIPlus.CheckStatus (status);
600                 }
601                 
602                 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
603                 {                       
604                         Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject, 
605                                         destRect.X, destRect.Y, destRect.Width, 
606                                         destRect.Height, srcX, srcY, srcWidth, srcHeight,
607                                         srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
608                         GDIPlus.CheckStatus (status);
609                 }
610                 
611                 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
612                 {
613                         Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject, 
614                                         destRect.X, destRect.Y, destRect.Width, 
615                                         destRect.Height, srcX, srcY, srcWidth, srcHeight,
616                                         srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback,
617                                         IntPtr.Zero);
618                         GDIPlus.CheckStatus (status);
619                 }
620                 
621                 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
622                 {
623                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
624                                         destRect.X, destRect.Y, destRect.Width, 
625                                         destRect.Height, srcX, srcY, srcWidth, srcHeight,
626                                         srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, 
627                                         callback, IntPtr.Zero);
628                         GDIPlus.CheckStatus (status);
629                 }
630
631                 
632                 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
633                 {
634                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
635                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
636                                 srcX, srcY, srcWidth, srcHeight, srcUnit, 
637                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
638                         GDIPlus.CheckStatus (status);
639                 }
640
641                 
642                 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
643                 {
644                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
645                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
646                                 srcX, srcY, srcWidth, srcHeight, srcUnit,
647                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
648                         GDIPlus.CheckStatus (status);
649                 }               
650                 
651                 public void DrawImageUnscaled (Image image, Point point)
652                 {
653                         DrawImageUnscaled (image, point.X, point.Y);
654                 }
655                 
656                 public void DrawImageUnscaled (Image image, Rectangle rect)
657                 {
658                         DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
659                 }
660                 
661                 public void DrawImageUnscaled (Image image, int x, int y)
662                 {
663                         DrawImage (image, x, y, image.Width, image.Height);
664                 }
665
666                 public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
667                 {
668                         Image tmpImg = new Bitmap (width, height);
669                         Graphics g = FromImage (tmpImg);
670                         g.DrawImage (image, 0, 0, image.Width, image.Height);
671                         this.DrawImage (tmpImg, x, y, width, height);
672                         tmpImg.Dispose ();
673                         g.Dispose ();
674                 }
675
676                 public void DrawLine (Pen pen, PointF pt1, PointF pt2)
677                 {
678                         Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
679                                                 pt1.X, pt1.Y, pt2.X, pt2.Y);
680                         GDIPlus.CheckStatus (status);
681                 }
682
683                 public void DrawLine (Pen pen, Point pt1, Point pt2)
684                 {
685                         Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
686                                                 pt1.X, pt1.Y, pt2.X, pt2.Y);
687                         GDIPlus.CheckStatus (status);
688                 }
689
690                 public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
691                 {
692                         Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
693                         GDIPlus.CheckStatus (status);
694                 }
695
696                 public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
697                 {
698                         Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
699                         GDIPlus.CheckStatus (status);
700                 }
701
702                 public void DrawLines (Pen pen, PointF [] points)
703                 {
704                         Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
705                         GDIPlus.CheckStatus (status);
706                 }
707
708                 public void DrawLines (Pen pen, Point [] points)
709                 {
710                         Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
711                         GDIPlus.CheckStatus (status);
712                 }
713
714                 public void DrawPath (Pen pen, GraphicsPath path)
715                 {
716                         Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
717                         GDIPlus.CheckStatus (status);
718                 }
719                 
720                 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
721                 {
722                         DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
723                 }
724                 
725                 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
726                 {
727                         DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
728                 }
729                 
730                 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
731                 {
732                         Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
733                         GDIPlus.CheckStatus (status);
734                 }
735                 
736                 // Microsoft documentation states that the signature for this member should be
737                 // public void DrawPie(Pen pen, int x,  int y,  int width,   int height,   int startAngle
738                 // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
739                 public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
740                 {
741                         Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
742                         GDIPlus.CheckStatus (status);
743                 }
744
745                 public void DrawPolygon (Pen pen, Point [] points)
746                 {
747                         Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
748                         GDIPlus.CheckStatus (status);
749                 }
750
751                 public void DrawPolygon (Pen pen, PointF [] points)
752                 {
753                         Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
754                         GDIPlus.CheckStatus (status);
755                 }
756
757                 internal void DrawRectangle (Pen pen, RectangleF rect)
758                 {
759                         DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
760                 }
761
762                 public void DrawRectangle (Pen pen, Rectangle rect)
763                 {
764                         DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
765                 }
766
767                 public void DrawRectangle (Pen pen, float x, float y, float width, float height)
768                 {
769                         Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
770                         GDIPlus.CheckStatus (status);
771                 }
772
773                 public void DrawRectangle (Pen pen, int x, int y, int width, int height)
774                 {
775                         Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
776                         GDIPlus.CheckStatus (status);
777                 }
778
779                 public void DrawRectangles (Pen pen, RectangleF [] rects)
780                 {
781                         Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
782                         GDIPlus.CheckStatus (status);
783                 }
784
785                 public void DrawRectangles (Pen pen, Rectangle [] rects)
786                 {
787                         Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
788                         GDIPlus.CheckStatus (status);
789                 }
790
791                 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
792                 {
793                         DrawString (s, font, brush, layoutRectangle, null);
794                 }
795
796                 public void DrawString (string s, Font font, Brush brush, PointF point)
797                 {
798                         DrawString (s, font, brush, new RectangleF (point.X, point.Y, 0, 0), null);
799                 }
800
801                 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
802                 {
803                         DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
804                 }
805
806                 public void DrawString (string s, Font font, Brush brush, float x, float y)
807                 {
808                         DrawString (s, font, brush, new RectangleF (x, y, 0, 0), null);
809                 }
810
811                 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
812                 {
813                         DrawString (s, font, brush, new RectangleF(x, y, 0, 0), format);
814                 }
815
816                 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
817                 {
818                         if (font == null)
819                                 throw new ArgumentNullException ("font");
820                         if (brush == null)
821                                 throw new ArgumentNullException ("brush");
822                         if (s == null || s.Length == 0)
823                                 return;
824
825                         Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.nativeObject);
826                         GDIPlus.CheckStatus (status);
827                 }
828
829                 public void EndContainer (GraphicsContainer container)
830                 {
831                         Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
832                         GDIPlus.CheckStatus (status);
833                 }
834
835                 [MonoTODO]
836                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
837                 {
838                         throw new NotImplementedException ();
839                 }
840
841                 [MonoTODO]
842                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
843                 {
844                         throw new NotImplementedException ();
845                 }
846
847                 [MonoTODO]
848                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
849                 {
850                         throw new NotImplementedException ();
851                 }
852
853                 [MonoTODO]
854                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
855                 {
856                         throw new NotImplementedException ();
857                 }
858
859                 [MonoTODO]
860                 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
861                 {
862                         throw new NotImplementedException ();
863                 }
864
865                 [MonoTODO]
866                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
867                 {
868                         throw new NotImplementedException ();
869                 }
870
871                 [MonoTODO]
872                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
873                 {
874                         throw new NotImplementedException ();
875                 }
876
877                 [MonoTODO]
878                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
879                 {
880                         throw new NotImplementedException ();
881                 }
882
883                 [MonoTODO]
884                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
885                 {
886                         throw new NotImplementedException ();
887                 }
888
889                 [MonoTODO]
890                 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
891                 {
892                         throw new NotImplementedException ();
893                 }
894
895                 [MonoTODO]
896                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
897                 {
898                         throw new NotImplementedException ();
899                 }
900
901                 [MonoTODO]
902                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
903                 {
904                         throw new NotImplementedException ();
905                 }
906
907                 [MonoTODO]
908                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
909                 {
910                         throw new NotImplementedException ();
911                 }
912
913                 [MonoTODO]
914                 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
915                 {
916                         throw new NotImplementedException ();
917                 }
918
919                 [MonoTODO]
920                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
921                 {
922                         throw new NotImplementedException ();
923                 }
924
925                 [MonoTODO]
926                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
927                 {
928                         throw new NotImplementedException ();
929                 }
930
931                 [MonoTODO]
932                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
933                 {
934                         throw new NotImplementedException ();
935                 }
936
937                 [MonoTODO]
938                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
939                 {
940                         throw new NotImplementedException ();
941                 }
942
943                 [MonoTODO]
944                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
945                 {
946                         throw new NotImplementedException ();
947                 }
948
949                 [MonoTODO]
950                 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
951                 {
952                         throw new NotImplementedException ();
953                 }
954
955                 [MonoTODO]
956                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
957                 {
958                         throw new NotImplementedException ();
959                 }
960
961                 [MonoTODO]
962                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
963                 {
964                         throw new NotImplementedException ();
965                 }
966
967                 [MonoTODO]
968                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
969                 {
970                         throw new NotImplementedException ();
971                 }
972
973                 [MonoTODO]
974                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
975                 {
976                         throw new NotImplementedException ();
977                 }
978
979                 [MonoTODO]
980                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
981                 {
982                         throw new NotImplementedException ();
983                 }
984
985                 [MonoTODO]
986                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
987                 {
988                         throw new NotImplementedException ();
989                 }
990
991                 [MonoTODO]
992                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
993                 {
994                         throw new NotImplementedException ();
995                 }
996
997                 [MonoTODO]
998                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
999                 {
1000                         throw new NotImplementedException ();
1001                 }
1002
1003                 [MonoTODO]
1004                 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1005                 {
1006                         throw new NotImplementedException ();
1007                 }
1008
1009                 [MonoTODO]
1010                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1011                 {
1012                         throw new NotImplementedException ();
1013                 }
1014
1015                 [MonoTODO]
1016                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1017                 {
1018                         throw new NotImplementedException ();
1019                 }
1020
1021                 [MonoTODO]
1022                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1023                 {
1024                         throw new NotImplementedException ();
1025                 }
1026
1027                 [MonoTODO]
1028                 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1029                 {
1030                         throw new NotImplementedException ();
1031                 }
1032
1033                 [MonoTODO]
1034                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1035                 {
1036                         throw new NotImplementedException ();
1037                 }
1038
1039                 [MonoTODO]
1040                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1041                 {
1042                         throw new NotImplementedException ();
1043                 }
1044
1045                 [MonoTODO]
1046                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1047                 {
1048                         throw new NotImplementedException ();
1049                 }
1050         
1051                 public void ExcludeClip (Rectangle rect)
1052                 {
1053                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1054                         GDIPlus.CheckStatus (status);
1055                 }
1056
1057                 public void ExcludeClip (Region region)
1058                 {
1059                         Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
1060                         GDIPlus.CheckStatus (status);
1061                 }
1062
1063                 
1064                 public void FillClosedCurve (Brush brush, PointF [] points)
1065                 {
1066                        Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1067                         GDIPlus.CheckStatus (status);
1068                 }
1069
1070                 
1071                 public void FillClosedCurve (Brush brush, Point [] points)
1072                 {
1073                         Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1074                         GDIPlus.CheckStatus (status);
1075                 }
1076
1077                 
1078                 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1079                 {
1080                         FillClosedCurve (brush, points, fillmode, 0.5f);
1081                 }
1082                 
1083                 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1084                 {
1085                         FillClosedCurve (brush, points, fillmode, 0.5f);
1086                 }
1087
1088                 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1089                 {
1090                         Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1091                         GDIPlus.CheckStatus (status);
1092                 }
1093
1094                 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1095                 {
1096                         Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1097                         GDIPlus.CheckStatus (status);
1098                 }
1099
1100                 public void FillEllipse (Brush brush, Rectangle rect)
1101                 {
1102                         FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1103                 }
1104
1105                 public void FillEllipse (Brush brush, RectangleF rect)
1106                 {
1107                         FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1108                 }
1109
1110                 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1111                 {
1112                         Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1113                         GDIPlus.CheckStatus (status);
1114                 }
1115
1116                 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1117                 {
1118                         Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1119                         GDIPlus.CheckStatus (status);
1120                 }
1121
1122                 public void FillPath (Brush brush, GraphicsPath path)
1123                 {
1124                         Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject,  path.NativeObject);
1125                         GDIPlus.CheckStatus (status);
1126                 }
1127
1128                 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1129                 {
1130                         Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1131                         GDIPlus.CheckStatus (status);
1132                 }
1133
1134                 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1135                 {
1136                         Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1137                         GDIPlus.CheckStatus (status);
1138                 }
1139
1140                 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1141                 {
1142                         Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1143                         GDIPlus.CheckStatus (status);
1144                 }
1145
1146                 public void FillPolygon (Brush brush, PointF [] points)
1147                 {
1148                         Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1149                         GDIPlus.CheckStatus (status);
1150                 }
1151
1152                 public void FillPolygon (Brush brush, Point [] points)
1153                 {
1154                         Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1155                         GDIPlus.CheckStatus (status);
1156                 }
1157
1158                 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1159                 {
1160                         Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1161                         GDIPlus.CheckStatus (status);
1162                 }
1163
1164                 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1165                 {
1166                         Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1167                         GDIPlus.CheckStatus (status);
1168                 }
1169
1170                 public void FillRectangle (Brush brush, RectangleF rect)
1171                 {
1172                         FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1173                 }
1174
1175                 public void FillRectangle (Brush brush, Rectangle rect)
1176                 {
1177                         FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1178                 }
1179
1180                 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1181                 {
1182                         Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
1183                         GDIPlus.CheckStatus (status);
1184                 }
1185
1186                 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1187                 {
1188                         Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1189                         GDIPlus.CheckStatus (status);
1190                 }
1191
1192                 public void FillRectangles (Brush brush, Rectangle [] rects)
1193                 {
1194                         Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
1195                         GDIPlus.CheckStatus (status);
1196                 }
1197
1198                 public void FillRectangles (Brush brush, RectangleF [] rects)
1199                 {
1200                         Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
1201                         GDIPlus.CheckStatus (status);
1202                 }
1203
1204                 
1205                 public void FillRegion (Brush brush, Region region)
1206                 {
1207                         Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);                  
1208                         GDIPlus.CheckStatus(status);
1209                 }
1210
1211                 
1212                 public void Flush ()
1213                 {
1214                         Flush (FlushIntention.Flush);
1215                 }
1216
1217                 
1218                 public void Flush (FlushIntention intention)
1219                 {
1220                         Status status = GDIPlus.GdipFlush (nativeObject, intention);
1221                         GDIPlus.CheckStatus (status);                    
1222                         if (GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable)
1223                                 Carbon.CGContextSynchronize (GDIPlus.Display);
1224                 }
1225
1226                 [EditorBrowsable (EditorBrowsableState.Advanced)]               
1227                 public static Graphics FromHdc (IntPtr hdc)
1228                 {
1229                         IntPtr graphics;
1230                         Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
1231                         GDIPlus.CheckStatus (status);
1232                         return new Graphics (graphics);
1233                 }
1234
1235                 [MonoTODO]
1236                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1237                 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1238                 {
1239                         throw new NotImplementedException ();
1240                 }
1241
1242                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1243                 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1244                 public static Graphics FromHdcInternal (IntPtr hdc)
1245                 {
1246                         GDIPlus.Display = hdc;
1247                         return null;
1248                 }
1249
1250                 [EditorBrowsable (EditorBrowsableState.Advanced)]               
1251                 public static Graphics FromHwnd (IntPtr hwnd)
1252                 {
1253                         IntPtr graphics;
1254
1255                         if (GDIPlus.UseCocoaDrawable) {
1256                                 CarbonContext cgContext = Carbon.GetCGContextForNSView (hwnd);
1257                                 GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
1258                                 
1259                                 GDIPlus.Display = cgContext.ctx;
1260                                 return new Graphics (graphics);
1261                         }
1262                         if (GDIPlus.UseQuartzDrawable) {
1263                                 CarbonContext cgContext = Carbon.GetCGContextForView (hwnd);
1264                                 GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
1265                                 
1266                                 GDIPlus.Display = cgContext.ctx;
1267                                 return new Graphics (graphics);
1268                         }
1269                         if (GDIPlus.UseX11Drawable) {
1270                                 if (GDIPlus.Display == IntPtr.Zero) {
1271                                         GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
1272                                 }
1273
1274                                 return FromXDrawable (hwnd, GDIPlus.Display);
1275
1276                         }
1277
1278                         Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
1279                         GDIPlus.CheckStatus (status);
1280
1281                         return new Graphics (graphics);
1282                 }
1283                 
1284                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1285                 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1286                 public static Graphics FromHwndInternal (IntPtr hwnd)
1287                 {
1288                         return FromHwnd (hwnd);
1289                 }
1290
1291                 public static Graphics FromImage (Image image)
1292                 {
1293                         IntPtr graphics;
1294
1295                         if (image == null) 
1296                                 throw new ArgumentNullException ();
1297
1298                         Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1299                         GDIPlus.CheckStatus (status);
1300                         Graphics result = new Graphics (graphics);
1301                                 
1302                         // check for Unix platforms - see FAQ for more details
1303                         // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1304                         int platform = (int) Environment.OSVersion.Platform;
1305                         if ((platform == 4) || (platform == 128)) {
1306                                 Rectangle rect  = new Rectangle (0,0, image.Width, image.Height);
1307                                 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
1308                         }
1309                                 
1310                         return result;
1311                 }
1312
1313                 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1314                 {
1315                         IntPtr graphics;
1316
1317                         Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1318                         GDIPlus.CheckStatus (s);
1319                         return new Graphics (graphics);
1320                 }
1321
1322                 [MonoTODO]
1323                 public static IntPtr GetHalftonePalette ()
1324                 {
1325                         throw new NotImplementedException ();
1326                 }
1327
1328                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1329                 public IntPtr GetHdc ()
1330                 {
1331                         IntPtr hdc;
1332                         GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out hdc));
1333                         return hdc;
1334                 }
1335
1336                 
1337                 public Color GetNearestColor (Color color)
1338                 {
1339                         int argb;
1340                         
1341                         Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1342                         GDIPlus.CheckStatus (status);
1343
1344                         return Color.FromArgb (argb);
1345                 }
1346
1347                 
1348                 public void IntersectClip (Region region)
1349                 {
1350                         Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1351                         GDIPlus.CheckStatus (status);
1352                 }
1353                 
1354                 public void IntersectClip (RectangleF rect)
1355                 {
1356                         Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1357                         GDIPlus.CheckStatus (status);
1358                 }
1359
1360                 public void IntersectClip (Rectangle rect)
1361                 {                       
1362                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1363                         GDIPlus.CheckStatus (status);
1364                 }
1365
1366                 public bool IsVisible (Point point)
1367                 {
1368                         bool isVisible = false;
1369
1370                         Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1371                         GDIPlus.CheckStatus (status);
1372
1373                         return isVisible;
1374                 }
1375
1376                 
1377                 public bool IsVisible (RectangleF rect)
1378                 {
1379                         bool isVisible = false;
1380
1381                         Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1382                         GDIPlus.CheckStatus (status);
1383
1384                         return isVisible;
1385                 }
1386
1387                 public bool IsVisible (PointF point)
1388                 {
1389                         bool isVisible = false;
1390
1391                         Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1392                         GDIPlus.CheckStatus (status);
1393
1394                         return isVisible;
1395                 }
1396                 
1397                 public bool IsVisible (Rectangle rect)
1398                 {
1399                         bool isVisible = false;
1400
1401                         Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1402                         GDIPlus.CheckStatus (status);
1403
1404                         return isVisible;
1405                 }
1406                 
1407                 public bool IsVisible (float x, float y)
1408                 {
1409                         return IsVisible (new PointF (x, y));
1410                 }
1411                 
1412                 public bool IsVisible (int x, int y)
1413                 {
1414                         return IsVisible (new Point (x, y));
1415                 }
1416                 
1417                 public bool IsVisible (float x, float y, float width, float height)
1418                 {
1419                         return IsVisible (new RectangleF (x, y, width, height));
1420                 }
1421
1422                 
1423                 public bool IsVisible (int x, int y, int width, int height)
1424                 {
1425                         return IsVisible (new Rectangle (x, y, width, height));
1426                 }
1427
1428                 
1429                 public Region [] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1430                 {       
1431                         Status status;                  
1432                         int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
1433                         IntPtr[] native_regions = new IntPtr [regcount];
1434                         Region[] regions = new Region [regcount];
1435                         
1436                         for (int i = 0; i < regcount; i++) {
1437                                 regions[i] = new Region ();
1438                                 native_regions[i] = regions[i].NativeObject;
1439                         }
1440                         
1441                         status =  GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
1442                                 font.NativeObject, ref layoutRect, stringFormat.NativeObject, 
1443                                 regcount, out native_regions[0]); 
1444                         
1445                         GDIPlus.CheckStatus (status);                           
1446                                                         
1447                         return regions;                                                 
1448                 }
1449
1450                 
1451                 public SizeF MeasureString (string text, Font font)
1452                 {
1453                         return MeasureString (text, font, new Size (0, 0));
1454                 }
1455
1456                 
1457                 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1458                 {
1459                         int charactersFitted, linesFilled;
1460                         RectangleF boundingBox = new RectangleF ();
1461                         RectangleF rect = new RectangleF (0, 0, layoutArea.Width,
1462                                                           layoutArea.Height);
1463
1464                         if (text == null || text.Length == 0)
1465                                 return SizeF.Empty;
1466
1467                         if (font == null)
1468                                 throw new ArgumentNullException ("font");
1469
1470                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1471                                                                    font.NativeObject, ref rect,
1472                                                                    IntPtr.Zero, out boundingBox,
1473                                                                    out charactersFitted, out linesFilled);
1474                         GDIPlus.CheckStatus (status);
1475
1476                         return new SizeF (boundingBox.Width, boundingBox.Height);
1477                 }
1478
1479                 
1480                 public SizeF MeasureString (string text, Font font, int width)
1481                 {                               
1482                         RectangleF boundingBox = new RectangleF ();
1483                         RectangleF rect = new RectangleF (0, 0, width, 999999);
1484                         int charactersFitted, linesFilled;
1485
1486                         if (text == null || text.Length == 0)
1487                                 return SizeF.Empty;
1488
1489                         if (font == null)
1490                                 throw new ArgumentNullException ("font");
1491
1492                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
1493                                                                    font.NativeObject, ref rect,
1494                                                                    IntPtr.Zero, out boundingBox,
1495                                                                    out charactersFitted, out linesFilled);
1496                         GDIPlus.CheckStatus (status);
1497
1498                         return new SizeF (boundingBox.Width, boundingBox.Height);
1499                 }
1500
1501                 
1502                 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
1503                                             StringFormat stringFormat)
1504                 {
1505                         int charactersFitted, linesFilled;                      
1506                         return MeasureString (text, font, layoutArea, stringFormat,
1507                                               out charactersFitted, out linesFilled);
1508                 }
1509
1510                 
1511                 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1512                 {
1513                         int charactersFitted, linesFilled;                      
1514                         return MeasureString (text, font, new SizeF (width, 999999), 
1515                                               format, out charactersFitted, out linesFilled);
1516                 }
1517
1518                 
1519                 public SizeF MeasureString (string text, Font font, PointF origin,
1520                                             StringFormat stringFormat)
1521                 {
1522                         RectangleF boundingBox = new RectangleF ();
1523                         RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
1524                         int charactersFitted, linesFilled;
1525
1526                         if (text == null || text.Length == 0)
1527                                 return SizeF.Empty;
1528
1529                         if (font == null)
1530                                 throw new ArgumentNullException ("font");
1531
1532                         if (stringFormat == null)
1533                                 stringFormat = new StringFormat ();
1534
1535                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
1536                                                                    font.NativeObject, ref rect,
1537                                                                    stringFormat.NativeObject, 
1538                                                                    out boundingBox,
1539                                                                    out charactersFitted,
1540                                                                    out linesFilled);
1541                         GDIPlus.CheckStatus (status);
1542
1543                         return new SizeF (boundingBox.Width, boundingBox.Height);
1544                 }
1545
1546                 
1547                 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
1548                                             StringFormat stringFormat, out int charactersFitted,
1549                                             out int linesFilled)
1550                 {       
1551                         RectangleF boundingBox = new RectangleF ();
1552                         RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1553                         charactersFitted = 0;
1554                         linesFilled = 0;
1555
1556                         if (text == null || text.Length == 0)
1557                                 return SizeF.Empty;
1558
1559                         if (font == null)
1560                                 throw new ArgumentNullException ("font");
1561
1562                         if (stringFormat == null)
1563                                 stringFormat = new StringFormat ();
1564
1565                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
1566                                                                    font.NativeObject, ref rect,
1567                                                                    stringFormat.NativeObject,
1568                                                                    out boundingBox,
1569                                                                    out charactersFitted,
1570                                                                    out linesFilled);
1571                         GDIPlus.CheckStatus (status);
1572
1573                         return new SizeF (boundingBox.Width, boundingBox.Height);
1574                 }
1575
1576                 public void MultiplyTransform (Matrix matrix)
1577                 {
1578                         MultiplyTransform (matrix, MatrixOrder.Prepend);
1579                 }
1580
1581                 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
1582                 {
1583                         Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject,
1584                                                                             matrix.nativeMatrix,
1585                                                                             order);
1586                         GDIPlus.CheckStatus (status);
1587                 }
1588
1589                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1590                 public void ReleaseHdc (IntPtr hdc)
1591                 {
1592                         Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
1593                         GDIPlus.CheckStatus (status);
1594                 }
1595
1596                 [MonoTODO]
1597                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1598                 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1599                 public void ReleaseHdcInternal (IntPtr hdc)
1600                 {
1601                         throw new NotImplementedException ();
1602                 }
1603
1604                 
1605                 public void ResetClip ()
1606                 {
1607                         Status status = GDIPlus.GdipResetClip (nativeObject);
1608                         GDIPlus.CheckStatus (status);
1609                 }
1610
1611                 public void ResetTransform ()
1612                 {
1613                         Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
1614                         GDIPlus.CheckStatus (status);
1615                 }
1616
1617                 public void Restore (GraphicsState gstate)
1618                 {                       
1619                         Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
1620                         GDIPlus.CheckStatus (status);
1621                 }
1622
1623
1624                 public void RotateTransform (float angle)
1625                 {
1626                         RotateTransform (angle, MatrixOrder.Prepend);
1627                 }
1628
1629                 public void RotateTransform (float angle, MatrixOrder order)
1630                 {
1631
1632                         Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
1633                         GDIPlus.CheckStatus (status);
1634                 }
1635
1636                 public GraphicsState Save ()
1637                 {                                               
1638                         uint saveState;
1639                         Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
1640                         GDIPlus.CheckStatus (status);
1641
1642                         GraphicsState state = new GraphicsState ();
1643                         state.nativeState = saveState;
1644                         return state;
1645                 }
1646
1647                 public void ScaleTransform (float sx, float sy)
1648                 {
1649                         ScaleTransform (sx, sy, MatrixOrder.Prepend);
1650                 }
1651
1652                 public void ScaleTransform (float sx, float sy, MatrixOrder order)
1653                 {
1654                         Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
1655                         GDIPlus.CheckStatus (status);
1656                 }
1657
1658                 
1659                 public void SetClip (RectangleF rect)
1660                 {
1661                         SetClip (rect, CombineMode.Replace);
1662                 }
1663
1664                 
1665                 public void SetClip (GraphicsPath path)
1666                 {
1667                         SetClip (path, CombineMode.Replace);
1668                 }
1669
1670                 
1671                 public void SetClip (Rectangle rect)
1672                 {
1673                         SetClip (rect, CombineMode.Replace);
1674                 }
1675
1676                 
1677                 public void SetClip (Graphics g)
1678                 {
1679                         SetClip (g, CombineMode.Replace);
1680                 }
1681
1682                 
1683                 public void SetClip (Graphics g, CombineMode combineMode)
1684                 {
1685                         Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
1686                         GDIPlus.CheckStatus (status);
1687                 }
1688
1689                 
1690                 public void SetClip (Rectangle rect, CombineMode combineMode)
1691                 {
1692                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1693                         GDIPlus.CheckStatus (status);
1694                 }
1695
1696                 
1697                 public void SetClip (RectangleF rect, CombineMode combineMode)
1698                 {
1699                         Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1700                         GDIPlus.CheckStatus (status);
1701                 }
1702
1703                 
1704                 public void SetClip (Region region, CombineMode combineMode)
1705                 {
1706                         Status status =   GDIPlus.GdipSetClipRegion(nativeObject,  region.NativeObject, combineMode); 
1707                         GDIPlus.CheckStatus (status);
1708                 }
1709
1710                 
1711                 public void SetClip (GraphicsPath path, CombineMode combineMode)
1712                 {
1713                         Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
1714                         GDIPlus.CheckStatus (status);
1715                 }
1716
1717                 
1718                 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
1719                 {
1720                         IntPtr ptrPt =  GDIPlus.FromPointToUnManagedMemory (pts);
1721             
1722                         Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace,  ptrPt, pts.Length);
1723                         GDIPlus.CheckStatus (status);
1724                         
1725                         GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
1726                 }
1727
1728
1729                 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
1730                 {                                               
1731                         IntPtr ptrPt =  GDIPlus.FromPointToUnManagedMemoryI (pts);
1732             
1733                         Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
1734                         GDIPlus.CheckStatus (status);
1735                         
1736                         GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
1737                 }
1738
1739                 
1740                 public void TranslateClip (int dx, int dy)
1741                 {
1742                         Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
1743                         GDIPlus.CheckStatus (status);
1744                 }
1745
1746                 
1747                 public void TranslateClip (float dx, float dy)
1748                 {
1749                         Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
1750                         GDIPlus.CheckStatus (status);
1751                 }
1752
1753                 public void TranslateTransform (float dx, float dy)
1754                 {
1755                         TranslateTransform (dx, dy, MatrixOrder.Prepend);
1756                 }
1757
1758                 
1759                 public void TranslateTransform (float dx, float dy, MatrixOrder order)
1760                 {                       
1761                         Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
1762                         GDIPlus.CheckStatus (status);
1763                 }
1764
1765                 public Region Clip {
1766                         get {
1767                                 Region reg = new Region();
1768                                 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
1769                                 GDIPlus.CheckStatus (status);
1770                                 return reg;                             
1771                         }
1772                         set {
1773                                 SetClip (value, CombineMode.Replace);
1774                         }
1775                 }
1776
1777                 public RectangleF ClipBounds {
1778                         get {
1779                                 RectangleF rect = new RectangleF ();
1780                                 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
1781                                 GDIPlus.CheckStatus (status);
1782                                 return rect;
1783                         }
1784                 }
1785
1786                 public CompositingMode CompositingMode {
1787                         get {
1788                                 CompositingMode mode;
1789                                 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
1790                                 GDIPlus.CheckStatus (status);
1791
1792                                 return mode;
1793                         }
1794                         set {
1795                                 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
1796                                 GDIPlus.CheckStatus (status);
1797                         }
1798
1799                 }
1800
1801                 public CompositingQuality CompositingQuality {
1802                         get {
1803                                 CompositingQuality quality;
1804
1805                                 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
1806                                 GDIPlus.CheckStatus (status);
1807                                 return quality;
1808                         }
1809                         set {
1810                                 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
1811                                 GDIPlus.CheckStatus (status);
1812                         }
1813                 }
1814
1815                 public float DpiX {
1816                         get {
1817                                 float x;
1818
1819                                 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
1820                                 GDIPlus.CheckStatus (status);
1821                                 return x;
1822                         }
1823                 }
1824
1825                 public float DpiY {
1826                         get {
1827                                 float y;
1828
1829                                 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
1830                                 GDIPlus.CheckStatus (status);
1831                                 return y;
1832                         }
1833                 }
1834
1835                 public InterpolationMode InterpolationMode {
1836                         get {                           
1837                                 InterpolationMode imode = InterpolationMode.Invalid;
1838                                 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
1839                                 GDIPlus.CheckStatus (status);
1840                                 return imode;
1841                         }
1842                         set {
1843                                 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
1844                                 GDIPlus.CheckStatus (status);
1845                         }
1846                 }
1847
1848                 public bool IsClipEmpty {
1849                         get {
1850                                 bool isEmpty = false;
1851
1852                                 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
1853                                 GDIPlus.CheckStatus (status);
1854                                 return isEmpty;
1855                         }
1856                 }
1857
1858                 public bool IsVisibleClipEmpty {
1859                         get {
1860                                 bool isEmpty = false;
1861
1862                                 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
1863                                 GDIPlus.CheckStatus (status);
1864                                 return isEmpty;
1865                         }
1866                 }
1867
1868                 public float PageScale {
1869                         get {
1870                                 float scale;
1871
1872                                 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
1873                                 GDIPlus.CheckStatus (status);
1874                                 return scale;
1875                         }
1876                         set {
1877                                 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
1878                                 GDIPlus.CheckStatus (status);
1879                         }
1880                 }
1881
1882                 public GraphicsUnit PageUnit {
1883                         get {
1884                                 GraphicsUnit unit;
1885                                 
1886                                 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
1887                                 GDIPlus.CheckStatus (status);
1888                                 return unit;
1889                         }
1890                         set {
1891                                 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
1892                                 GDIPlus.CheckStatus (status);
1893                         }
1894                 }
1895
1896                 public PixelOffsetMode PixelOffsetMode {
1897                         get {
1898                                 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
1899                                 
1900                                 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
1901                                 GDIPlus.CheckStatus (status);
1902                                 return pixelOffset;
1903                         }
1904                         set {
1905                                 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value); 
1906                                 GDIPlus.CheckStatus (status);
1907                         }
1908                 }
1909
1910                 public Point RenderingOrigin {
1911                         get {
1912                                 int x, y;
1913                                 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
1914                                 GDIPlus.CheckStatus (status);
1915                                 return new Point (x, y);
1916                         }
1917
1918                         set {
1919                                 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
1920                                 GDIPlus.CheckStatus (status);
1921                         }
1922                 }
1923
1924                 public SmoothingMode SmoothingMode {
1925                         get {
1926                                 SmoothingMode mode = SmoothingMode.Invalid;
1927
1928                                 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
1929                                 GDIPlus.CheckStatus (status);
1930                                 return mode;
1931                         }
1932
1933                         set {
1934                                 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
1935                                 GDIPlus.CheckStatus (status);
1936                         }
1937                 }
1938
1939                 public int TextContrast {
1940                         get {   
1941                                 int contrast;
1942                                         
1943                                 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
1944                                 GDIPlus.CheckStatus (status);
1945                                 return contrast;
1946                         }
1947
1948                         set {
1949                                 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
1950                                 GDIPlus.CheckStatus (status);
1951                         }
1952                 }
1953
1954                 public TextRenderingHint TextRenderingHint {
1955                         get {
1956                                 TextRenderingHint hint;
1957
1958                                 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
1959                                 GDIPlus.CheckStatus (status);
1960                                 return hint;        
1961                         }
1962
1963                         set {
1964                                 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
1965                                 GDIPlus.CheckStatus (status);
1966                         }
1967                 }
1968
1969                 public Matrix Transform {
1970                         get {
1971                                 Matrix matrix = new Matrix ();
1972                                 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
1973                                 GDIPlus.CheckStatus (status);
1974                                 return matrix;
1975                         }
1976                         set {
1977                                 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
1978                                 GDIPlus.CheckStatus (status);
1979                         }
1980                 }
1981
1982                 public RectangleF VisibleClipBounds {
1983                         get {
1984                                 RectangleF rect;
1985                                         
1986                                 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
1987                                 GDIPlus.CheckStatus (status);
1988                                 return rect;
1989                         }
1990                 }
1991         }
1992 }
1993