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