Bitmap.cs: Move LockBits validations into unmanaged code.
[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 //      Sebastien Pouliot  <sebastien@ximian.com>
9 //
10 // Copyright (C) 2003 Ximian, Inc. (http://www.ximian.com)
11 // Copyright (C) 2004-2006 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 #if !NET_2_0
44         [ComVisible(false)]  
45 #endif
46         public sealed class Graphics : MarshalByRefObject, IDisposable
47 #if NET_2_0
48         , IDeviceContext
49 #endif
50         {
51                 internal IntPtr nativeObject = IntPtr.Zero;
52                 private bool disposed = false;
53                 private static float defDpiX = 0;
54                 private static float defDpiY = 0;
55 #if NET_2_0
56                 private IntPtr deviceContextHdc;
57 #endif
58
59 #if !NET_2_0
60                 [ComVisible(false)]
61 #endif
62                 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
63                                                             int flags,
64                                                             int dataSize,
65                                                             IntPtr data,
66                                                             PlayRecordCallback callbackData);
67                 
68 #if !NET_2_0
69                 [ComVisible (false)]
70 #endif
71                 public delegate bool DrawImageAbort (IntPtr callbackData);
72
73                 internal Graphics (IntPtr nativeGraphics)
74                 {
75                         nativeObject = nativeGraphics;
76                 }
77
78                 ~Graphics ()
79                 {
80                         Dispose ();                     
81                 }               
82
83                 static internal float systemDpiX {
84                         get {
85                                 if (defDpiX == 0) {
86                                         Bitmap bmp = new Bitmap (1, 1);
87                                         Graphics g = Graphics.FromImage (bmp);
88                                         defDpiX = g.DpiX;
89                                         defDpiY = g.DpiY;
90                                 }
91                                 return defDpiX;
92                         }
93                 }
94
95                 static internal float systemDpiY {
96                         get {
97                                 if (defDpiY == 0) {
98                                         Bitmap bmp = new Bitmap (1, 1);
99                                         Graphics g = Graphics.FromImage (bmp);
100                                         defDpiX = g.DpiX;
101                                         defDpiY = g.DpiY;
102                                 }
103                                 return defDpiY;
104                         }
105                 }
106
107                 internal IntPtr NativeObject {
108                         get {
109                                 return nativeObject;
110                         }
111
112                         set {
113                                 nativeObject = value;
114                         }
115                 }
116                 
117                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
118                 public void AddMetafileComment (byte [] data)
119                 {
120                         throw new NotImplementedException ();
121                 }
122
123                 public GraphicsContainer BeginContainer ()
124                 {
125                         uint state;
126                         Status status;
127                         status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
128                         GDIPlus.CheckStatus (status);
129
130                         return new GraphicsContainer(state);
131                 }
132
133                 [MonoTODO ("The rectangles and unit parameters aren't supported in libgdiplus")]                
134                 public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
135                 {
136                         uint state;
137                         Status status;
138                         status = GDIPlus.GdipBeginContainerI (nativeObject, ref dstrect, ref srcrect, unit, out state);
139                         GDIPlus.CheckStatus (status);
140
141                         return new GraphicsContainer (state);
142                 }
143
144                 [MonoTODO ("The rectangles and unit parameters aren't supported in libgdiplus")]                
145                 public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
146                 {
147                         uint state;
148                         Status status;
149                         status = GDIPlus.GdipBeginContainer (nativeObject, ref dstrect, ref srcrect, unit, out state);
150                         GDIPlus.CheckStatus (status);
151
152                         return new GraphicsContainer (state);
153                 }
154
155                 
156                 public void Clear (Color color)
157                 {
158                         Status status;
159                         status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ());
160                         GDIPlus.CheckStatus (status);
161                 }
162 #if NET_2_0             
163                 [MonoLimitation ("Works on Win32 and on X11 (but not on Cocoa and Quartz)")]
164                 public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
165                 {
166                         CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
167                                 blockRegionSize, CopyPixelOperation.SourceCopy);                                
168                 }
169
170                 [MonoLimitation ("Works on Win32 and (for CopyPixelOperation.SourceCopy only) on X11 but not on Cocoa and Quartz")]
171                 public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
172                 {
173                         CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
174                                 blockRegionSize, copyPixelOperation);
175                 }
176                 
177                 [MonoLimitation ("Works on Win32 and on X11 (but not on Cocoa and Quartz)")]
178                 public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize)
179                 {
180                         CopyFromScreen (sourceX, sourceY, destinationX, destinationY, blockRegionSize,
181                                 CopyPixelOperation.SourceCopy);
182                 }
183
184                 [MonoLimitation ("Works on Win32 and (for CopyPixelOperation.SourceCopy only) on X11 but not on Cocoa and Quartz")]
185                 public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
186                 {
187                         if (!Enum.IsDefined (typeof (CopyPixelOperation), copyPixelOperation))
188                                 throw new InvalidEnumArgumentException (Locale.GetText ("Enum argument value '{0}' is not valid for CopyPixelOperation", copyPixelOperation));
189
190                         if (GDIPlus.UseX11Drawable) {
191                                 CopyFromScreenX11 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
192                         } else if (GDIPlus.UseCocoaDrawable || GDIPlus.UseQuartzDrawable) {
193                                 CopyFromScreenMac (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
194                         } else {
195                                 CopyFromScreenWin32 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
196                         }
197                 }
198
199                 private void CopyFromScreenWin32 (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
200                 {
201                         IntPtr window = GDIPlus.GetDesktopWindow ();
202                         IntPtr srcDC = GDIPlus.GetDC (window);
203                         IntPtr dstDC = GetHdc ();
204                         GDIPlus.BitBlt (dstDC, destinationX, destinationY, blockRegionSize.Width,
205                                 blockRegionSize.Height, srcDC, sourceX, sourceY, (int) copyPixelOperation);
206
207                         GDIPlus.ReleaseDC (IntPtr.Zero, srcDC);
208                         ReleaseHdc (dstDC);                     
209                 }
210                 
211                 private void CopyFromScreenMac (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
212                 {
213                         throw new NotImplementedException ();
214                 }
215
216                 private void CopyFromScreenX11 (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
217                 {
218                         IntPtr window, image, defvisual, vPtr;
219                         int AllPlanes = ~0, nitems = 0, pixel;
220
221                         if (copyPixelOperation != CopyPixelOperation.SourceCopy)
222                                 throw new NotImplementedException ("Operation not implemented under X11");
223                 
224                         if (GDIPlus.Display == IntPtr.Zero) {
225                                 GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);                                   
226                         }
227
228                         window = GDIPlus.XRootWindow (GDIPlus.Display, 0);
229                         defvisual = GDIPlus.XDefaultVisual (GDIPlus.Display, 0);                                
230                         XVisualInfo visual = new XVisualInfo ();
231
232                         /* Get XVisualInfo for this visual */
233                         visual.visualid = GDIPlus.XVisualIDFromVisual(defvisual);
234                         vPtr = GDIPlus.XGetVisualInfo (GDIPlus.Display, 0x1 /* VisualIDMask */, ref visual, ref nitems);
235                         visual = (XVisualInfo) Marshal.PtrToStructure(vPtr, typeof (XVisualInfo));
236
237                         /* Sorry I do not have access to a computer with > deepth. Fell free to add more pixel formats */       
238                         image = GDIPlus.XGetImage (GDIPlus.Display, window, sourceX, sourceY, blockRegionSize.Width,
239                                 blockRegionSize.Height, AllPlanes, 2 /* ZPixmap*/);
240                                 
241                         Bitmap bmp = new Bitmap (blockRegionSize.Width, blockRegionSize.Height);
242                         int red, blue, green;
243                         for (int y = sourceY; y <  sourceY + blockRegionSize.Height; y++) {
244                                 for (int x = sourceX; x <  sourceX + blockRegionSize.Width; x++) {
245                                         pixel = GDIPlus.XGetPixel (image, x, y);                        
246
247                                         switch (visual.depth) {
248                                                 case 16: /* 16bbp pixel transformation */
249                                                         red = (int) ((pixel & visual.red_mask ) >> 8) & 0xff;
250                                                         green = (int) (((pixel & visual.green_mask ) >> 3 )) & 0xff;
251                                                         blue = (int) ((pixel & visual.blue_mask ) << 3 ) & 0xff;
252                                                         break;
253                                                 case 24:
254                                                 case 32:
255                                                         red = (int) ((pixel & visual.red_mask ) >> 16) & 0xff;
256                                                         green = (int) (((pixel & visual.green_mask ) >> 8 )) & 0xff;
257                                                         blue = (int) ((pixel & visual.blue_mask )) & 0xff;
258                                                         break;
259                                                 default:
260                                                         throw new NotImplementedException ("Deepth not supported right now");
261                                         }
262                                                 
263                                         bmp.SetPixel (x, y, Color.FromArgb (255, red, green, blue));                                                     
264                                 }
265                         }
266
267                         DrawImage (bmp, 0, 0);
268                         bmp.Dispose ();
269                         GDIPlus.XDestroyImage (image);
270                         GDIPlus.XFree (vPtr);
271                 }
272 #endif
273
274                 public void Dispose ()
275                 {
276                         Status status;
277                         if (! disposed) {
278                                 status = GDIPlus.GdipDeleteGraphics (nativeObject);
279                                 nativeObject = IntPtr.Zero;
280                                 GDIPlus.CheckStatus (status);
281                                 disposed = true;                                
282                         }
283                         GC.SuppressFinalize(this);
284                 }
285
286                 
287                 public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
288                 {
289                         DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
290                 }
291
292                 
293                 public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
294                 {
295                         DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
296                 }
297
298                 
299                 public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
300                 {
301                         Status status;
302                         if (pen == null)
303                                 throw new ArgumentNullException ("pen");
304                         
305                         status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
306                                         x, y, width, height, startAngle, sweepAngle);
307                         GDIPlus.CheckStatus (status);
308                 }
309
310                 // Microsoft documentation states that the signature for this member should be
311                 // public void DrawArc( Pen pen,  int x,  int y,  int width,  int height,   int startAngle,
312                 // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
313                 public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
314                 {
315                         Status status;
316                         if (pen == null)
317                                 throw new ArgumentNullException ("pen");
318                         status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
319                                                 x, y, width, height, startAngle, sweepAngle);
320                         GDIPlus.CheckStatus (status);
321                 }
322
323                 public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
324                 {
325                         Status status;
326                         if (pen == null)
327                                 throw new ArgumentNullException ("pen");
328                         status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
329                                                         pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
330                                                         pt3.Y, pt4.X, pt4.Y);
331                         GDIPlus.CheckStatus (status);
332                 }
333
334                 public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
335                 {
336                         Status status;
337                         if (pen == null)
338                                 throw new ArgumentNullException ("pen");
339                         status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
340                                                         pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
341                                                         pt3.Y, pt4.X, pt4.Y);
342                         GDIPlus.CheckStatus (status);
343                 }
344
345                 public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
346                 {
347                         Status status;
348                         if (pen == null)
349                                 throw new ArgumentNullException ("pen");
350                         status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
351                                                         y1, x2, y2, x3, y3, x4, y4);
352                         GDIPlus.CheckStatus (status);
353                 }
354
355                 public void DrawBeziers (Pen pen, Point [] points)
356                 {
357                         if (pen == null)
358                                 throw new ArgumentNullException ("pen");
359                         if (points == null)
360                                 throw new ArgumentNullException ("points");
361                         
362                         int length = points.Length;
363                         Status status;
364
365                         if (length < 4)
366                                 return;
367
368                         for (int i = 0; i < length - 1; i += 3) {
369                                 Point p1 = points [i];
370                                 Point p2 = points [i + 1];
371                                 Point p3 = points [i + 2];
372                                 Point p4 = points [i + 3];
373
374                                 status = GDIPlus.GdipDrawBezier (nativeObject, 
375                                                         pen.nativeObject,
376                                                         p1.X, p1.Y, p2.X, p2.Y, 
377                                                         p3.X, p3.Y, p4.X, p4.Y);
378                                 GDIPlus.CheckStatus (status);
379                         }
380                 }
381
382                 public void DrawBeziers (Pen pen, PointF [] points)
383                 {
384                         if (pen == null)
385                                 throw new ArgumentNullException ("pen");
386                         if (points == null)
387                                 throw new ArgumentNullException ("points");
388                         
389                         int length = points.Length;
390                         Status status;
391
392                         if (length < 4)
393                                 return;
394
395                         for (int i = 0; i < length - 1; i += 3) {
396                                 PointF p1 = points [i];
397                                 PointF p2 = points [i + 1];
398                                 PointF p3 = points [i + 2];
399                                 PointF p4 = points [i + 3];
400
401                                 status = GDIPlus.GdipDrawBezier (nativeObject, 
402                                                         pen.nativeObject,
403                                                         p1.X, p1.Y, p2.X, p2.Y, 
404                                                         p3.X, p3.Y, p4.X, p4.Y);
405                                 GDIPlus.CheckStatus (status);
406                         }
407                 }
408
409                 
410                 public void DrawClosedCurve (Pen pen, PointF [] points)
411                 {
412                         if (pen == null)
413                                 throw new ArgumentNullException ("pen");
414                         if (points == null)
415                                 throw new ArgumentNullException ("points");
416                         
417                         Status status;
418                         status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
419                         GDIPlus.CheckStatus (status);
420                 }
421                 
422                 public void DrawClosedCurve (Pen pen, Point [] points)
423                 {
424                         if (pen == null)
425                                 throw new ArgumentNullException ("pen");
426                         if (points == null)
427                                 throw new ArgumentNullException ("points");
428                         
429                         Status status;
430                         status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
431                         GDIPlus.CheckStatus (status);
432                 }
433                         
434                 public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
435                 {
436                         if (pen == null)
437                                 throw new ArgumentNullException ("pen");
438                         if (points == null)
439                                 throw new ArgumentNullException ("points");
440                         
441                         Status status;
442                         status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
443                         GDIPlus.CheckStatus (status);
444                 }
445                 
446                 public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
447                 {
448                         if (pen == null)
449                                 throw new ArgumentNullException ("pen");
450                         if (points == null)
451                                 throw new ArgumentNullException ("points");
452                         
453                         Status status;
454                         status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
455                         GDIPlus.CheckStatus (status);
456                 }
457                 
458                 public void DrawCurve (Pen pen, Point [] points)
459                 {
460                         if (pen == null)
461                                 throw new ArgumentNullException ("pen");
462                         if (points == null)
463                                 throw new ArgumentNullException ("points");
464                         
465                         Status status;
466                         status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
467                         GDIPlus.CheckStatus (status);
468                 }
469                 
470                 public void DrawCurve (Pen pen, PointF [] points)
471                 {
472                         if (pen == null)
473                                 throw new ArgumentNullException ("pen");
474                         if (points == null)
475                                 throw new ArgumentNullException ("points");
476                         
477                         Status status;
478                         status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
479                         GDIPlus.CheckStatus (status);
480                 }
481                 
482                 public void DrawCurve (Pen pen, PointF [] points, float tension)
483                 {
484                         if (pen == null)
485                                 throw new ArgumentNullException ("pen");
486                         if (points == null)
487                                 throw new ArgumentNullException ("points");
488                         
489                         Status status;
490                         status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
491                         GDIPlus.CheckStatus (status);
492                 }
493                 
494                 public void DrawCurve (Pen pen, Point [] points, float tension)
495                 {
496                         if (pen == null)
497                                 throw new ArgumentNullException ("pen");
498                         if (points == null)
499                                 throw new ArgumentNullException ("points");
500                         
501                         Status status;
502                         status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);              
503                         GDIPlus.CheckStatus (status);
504                 }
505                 
506                 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
507                 {
508                         if (pen == null)
509                                 throw new ArgumentNullException ("pen");
510                         if (points == null)
511                                 throw new ArgumentNullException ("points");
512                         
513                         Status status;
514                         status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
515                                                         points, points.Length, offset,
516                                                         numberOfSegments, 0.5f);
517                         GDIPlus.CheckStatus (status);
518                 }
519
520                 public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
521                 {
522                         if (pen == null)
523                                 throw new ArgumentNullException ("pen");
524                         if (points == null)
525                                 throw new ArgumentNullException ("points");
526                         
527                         Status status;
528                         status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
529                                                         points, points.Length, offset,
530                                                         numberOfSegments, tension);
531                         GDIPlus.CheckStatus (status);
532                 }
533
534                 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
535                 {
536                         if (pen == null)
537                                 throw new ArgumentNullException ("pen");
538                         if (points == null)
539                                 throw new ArgumentNullException ("points");
540                         
541                         Status status;
542                         status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
543                                                         points, points.Length, offset,
544                                                         numberOfSegments, tension);
545                         GDIPlus.CheckStatus (status);
546                 }
547
548                 public void DrawEllipse (Pen pen, Rectangle rect)
549                 {
550                         if (pen == null)
551                                 throw new ArgumentNullException ("pen");
552                         
553                         DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
554                 }
555
556                 public void DrawEllipse (Pen pen, RectangleF rect)
557                 {
558                         if (pen == null)
559                                 throw new ArgumentNullException ("pen");
560                         DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
561                 }
562
563                 public void DrawEllipse (Pen pen, int x, int y, int width, int height)
564                 {
565                         if (pen == null)
566                                 throw new ArgumentNullException ("pen");
567                         Status status;
568                         status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
569                         GDIPlus.CheckStatus (status);
570                 }
571
572                 public void DrawEllipse (Pen pen, float x, float y, float width, float height)
573                 {
574                         if (pen == null)
575                                 throw new ArgumentNullException ("pen");
576                         Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
577                         GDIPlus.CheckStatus (status);
578                 }
579
580                 public void DrawIcon (Icon icon, Rectangle targetRect)
581                 {
582                         if (icon == null)
583                                 throw new ArgumentNullException ("icon");
584
585                         DrawImage (icon.GetInternalBitmap (), targetRect);
586                 }
587
588                 public void DrawIcon (Icon icon, int x, int y)
589                 {
590                         if (icon == null)
591                                 throw new ArgumentNullException ("icon");
592
593                         DrawImage (icon.GetInternalBitmap (), x, y);
594                 }
595
596                 public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
597                 {
598                         if (icon == null)
599                                 throw new ArgumentNullException ("icon");
600
601                         DrawImageUnscaled (icon.GetInternalBitmap (), targetRect);
602                 }
603                 
604                 public void DrawImage (Image image, RectangleF rect)
605                 {
606                         if (image == null)
607                                 throw new ArgumentNullException ("image");
608                         
609                         Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
610                         GDIPlus.CheckStatus (status);
611                 }
612
613                 
614                 public void DrawImage (Image image, PointF point)
615                 {
616                         if (image == null)
617                                 throw new ArgumentNullException ("image");
618                         
619                         Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
620                         GDIPlus.CheckStatus (status);
621                 }
622
623                 
624                 public void DrawImage (Image image, Point [] destPoints)
625                 {
626                         if (image == null)
627                                 throw new ArgumentNullException ("image");
628                         if (destPoints == null)
629                                 throw new ArgumentNullException ("destPoints");
630                         
631                         Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
632                         GDIPlus.CheckStatus (status);
633                 }
634
635                 
636                 public void DrawImage (Image image, Point point)
637                 {
638                         if (image == null)
639                                 throw new ArgumentNullException ("image");
640                         DrawImage (image, point.X, point.Y);
641                 }
642
643                 
644                 public void DrawImage (Image image, Rectangle rect)
645                 {
646                         if (image == null)
647                                 throw new ArgumentNullException ("image");
648                         DrawImage (image, rect.X, rect.Y, rect.Width, rect.Height);
649                 }
650
651                 
652                 public void DrawImage (Image image, PointF [] destPoints)
653                 {
654                         if (image == null)
655                                 throw new ArgumentNullException ("image");
656                         if (destPoints == null)
657                                 throw new ArgumentNullException ("destPoints");
658                         Status status = GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
659                         GDIPlus.CheckStatus (status);
660                 }
661
662                 
663                 public void DrawImage (Image image, int x, int y)
664                 {
665                         if (image == null)
666                                 throw new ArgumentNullException ("image");
667                         Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
668                         GDIPlus.CheckStatus (status);
669                 }
670
671                 
672                 public void DrawImage (Image image, float x, float y)
673                 {
674                         if (image == null)
675                                 throw new ArgumentNullException ("image");
676                         Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
677                         GDIPlus.CheckStatus (status);
678                 }
679
680                 
681                 public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
682                 {
683                         if (image == null)
684                                 throw new ArgumentNullException ("image");
685                         Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
686                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
687                                 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
688                                 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
689                         GDIPlus.CheckStatus (status);
690                 }
691                 
692                 public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
693                 {                       
694                         if (image == null)
695                                 throw new ArgumentNullException ("image");
696                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
697                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
698                                 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
699                                 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
700                         GDIPlus.CheckStatus (status);
701                 }
702
703                 
704                 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
705                 {
706                         if (image == null)
707                                 throw new ArgumentNullException ("image");
708                         if (destPoints == null)
709                                 throw new ArgumentNullException ("destPoints");
710                         
711                         Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
712                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y, 
713                                 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero, 
714                                 null, IntPtr.Zero);
715                         GDIPlus.CheckStatus (status);
716                 }
717
718                 
719                 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
720                 {
721                         if (image == null)
722                                 throw new ArgumentNullException ("image");
723                         if (destPoints == null)
724                                 throw new ArgumentNullException ("destPoints");
725                         
726                         Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
727                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y, 
728                                 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero, 
729                                 null, IntPtr.Zero);
730                         GDIPlus.CheckStatus (status);
731                 }
732
733                 
734                 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, 
735                                 ImageAttributes imageAttr)
736                 {
737                         if (image == null)
738                                 throw new ArgumentNullException ("image");
739                         if (destPoints == null)
740                                 throw new ArgumentNullException ("destPoints");
741                         Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
742                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
743                                 srcRect.Width, srcRect.Height, srcUnit,
744                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
745                         GDIPlus.CheckStatus (status);
746                 }
747                 
748                 public void DrawImage (Image image, float x, float y, float width, float height)
749                 {
750                         if (image == null)
751                                 throw new ArgumentNullException ("image");
752                         Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
753                            width, height);
754                         GDIPlus.CheckStatus (status);
755                 }
756
757                 
758                 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, 
759                                 ImageAttributes imageAttr)
760                 {
761                         if (image == null)
762                                 throw new ArgumentNullException ("image");
763                         if (destPoints == null)
764                                 throw new ArgumentNullException ("destPoints");
765                         Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
766                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
767                                 srcRect.Width, srcRect.Height, srcUnit, 
768                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
769                         GDIPlus.CheckStatus (status);
770                 }
771
772                 
773                 public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
774                 {                       
775                         if (image == null)
776                                 throw new ArgumentNullException ("image");
777                         Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
778                         GDIPlus.CheckStatus (status);
779                 }
780                 
781                 public void DrawImage (Image image, int x, int y, int width, int height)
782                 {
783                         if (image == null)
784                                 throw new ArgumentNullException ("image");
785                         Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
786                         GDIPlus.CheckStatus (status);
787                 }
788
789                 public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
790                 {                       
791                         if (image == null)
792                                 throw new ArgumentNullException ("image");
793                         Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
794                         GDIPlus.CheckStatus (status);
795                 }
796
797                 
798                 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
799                 {
800                         if (image == null)
801                                 throw new ArgumentNullException ("image");
802                         if (destPoints == null)
803                                 throw new ArgumentNullException ("destPoints");
804                         Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
805                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
806                                 srcRect.Width, srcRect.Height, srcUnit, 
807                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
808                         GDIPlus.CheckStatus (status);
809                 }
810
811                 
812                 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
813                 {
814                         if (image == null)
815                                 throw new ArgumentNullException ("image");
816                         if (destPoints == null)
817                                 throw new ArgumentNullException ("destPoints");
818                         
819                         Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
820                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
821                                 srcRect.Width, srcRect.Height, srcUnit, 
822                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
823                         GDIPlus.CheckStatus (status);
824                 }
825
826                 
827                 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
828                 {
829                         if (image == null)
830                                 throw new ArgumentNullException ("image");
831                         if (destPoints == null)
832                                 throw new ArgumentNullException ("destPoints");
833
834                         Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
835                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y, 
836                                 srcRect.Width, srcRect.Height, srcUnit, 
837                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
838                         GDIPlus.CheckStatus (status);
839                 }
840
841                 
842                 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
843                 {
844                         if (image == null)
845                                 throw new ArgumentNullException ("image");
846                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
847                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
848                                 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero, 
849                                 null, IntPtr.Zero);
850                         GDIPlus.CheckStatus (status);                                   
851                 }
852                 
853                 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
854                 {
855                         Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
856                                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
857                                 srcRect.Width, srcRect.Height, srcUnit, 
858                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
859                         GDIPlus.CheckStatus (status);
860                 }
861
862                 
863                 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
864                 {
865                         if (image == null)
866                                 throw new ArgumentNullException ("image");
867                         Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
868                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
869                                 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero, 
870                                 null, IntPtr.Zero);
871                         GDIPlus.CheckStatus (status);
872                 }
873
874                 
875                 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
876                 {
877                         if (image == null)
878                                 throw new ArgumentNullException ("image");
879                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
880                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
881                                 srcX, srcY, srcWidth, srcHeight, srcUnit,
882                                 imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
883                         GDIPlus.CheckStatus (status);
884                 }
885                 
886                 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
887                 {                       
888                         if (image == null)
889                                 throw new ArgumentNullException ("image");
890                         Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject, 
891                                         destRect.X, destRect.Y, destRect.Width, 
892                                         destRect.Height, srcX, srcY, srcWidth, srcHeight,
893                                         srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
894                         GDIPlus.CheckStatus (status);
895                 }
896                 
897                 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
898                 {
899                         if (image == null)
900                                 throw new ArgumentNullException ("image");
901                         Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject, 
902                                         destRect.X, destRect.Y, destRect.Width, 
903                                         destRect.Height, srcX, srcY, srcWidth, srcHeight,
904                                         srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback,
905                                         IntPtr.Zero);
906                         GDIPlus.CheckStatus (status);
907                 }
908                 
909                 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
910                 {
911                         if (image == null)
912                                 throw new ArgumentNullException ("image");
913                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
914                                         destRect.X, destRect.Y, destRect.Width, 
915                                         destRect.Height, srcX, srcY, srcWidth, srcHeight,
916                                         srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, 
917                                         callback, IntPtr.Zero);
918                         GDIPlus.CheckStatus (status);
919                 }
920
921                 
922                 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
923                 {
924                         if (image == null)
925                                 throw new ArgumentNullException ("image");
926                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
927                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
928                                 srcX, srcY, srcWidth, srcHeight, srcUnit, 
929                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
930                         GDIPlus.CheckStatus (status);
931                 }
932
933                 
934                 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
935                 {
936                         if (image == null)
937                                 throw new ArgumentNullException ("image");
938                         Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
939                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
940                                 srcX, srcY, srcWidth, srcHeight, srcUnit,
941                                 imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
942                         GDIPlus.CheckStatus (status);
943                 }               
944                 
945                 public void DrawImageUnscaled (Image image, Point point)
946                 {
947                         if (image == null)
948                                 throw new ArgumentNullException ("image");
949                         DrawImageUnscaled (image, point.X, point.Y);
950                 }
951                 
952                 public void DrawImageUnscaled (Image image, Rectangle rect)
953                 {
954                         if (image == null)
955                                 throw new ArgumentNullException ("image");
956                         DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
957                 }
958                 
959                 public void DrawImageUnscaled (Image image, int x, int y)
960                 {
961                         if (image == null)
962                                 throw new ArgumentNullException ("image");
963                         DrawImage (image, x, y, image.Width, image.Height);
964                 }
965
966                 public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
967                 {
968                         if (image == null)
969                                 throw new ArgumentNullException ("image");
970                         Image tmpImg = new Bitmap (width, height);
971                         Graphics g = FromImage (tmpImg);
972                         g.DrawImage (image, 0, 0, image.Width, image.Height);
973                         this.DrawImage (tmpImg, x, y, width, height);
974                         tmpImg.Dispose ();
975                         g.Dispose ();
976                 }
977
978 #if NET_2_0
979                 public void DrawImageUnscaledAndClipped (Image image, Rectangle rect)
980                 {
981                         int height, width;                      
982                         width = (image.Width > rect.Width) ? rect.Width : image.Width;
983                         height = (image.Height > rect.Height) ? rect.Height : image.Height;
984
985                         DrawImageUnscaled (image, rect.X, rect.Y, width, height);                       
986                 }
987 #endif
988
989                 public void DrawLine (Pen pen, PointF pt1, PointF pt2)
990                 {
991                         if (pen == null)
992                                 throw new ArgumentNullException ("pen");
993                         Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
994                                                 pt1.X, pt1.Y, pt2.X, pt2.Y);
995                         GDIPlus.CheckStatus (status);
996                 }
997
998                 public void DrawLine (Pen pen, Point pt1, Point pt2)
999                 {
1000                         if (pen == null)
1001                                 throw new ArgumentNullException ("pen");
1002                         Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
1003                                                 pt1.X, pt1.Y, pt2.X, pt2.Y);
1004                         GDIPlus.CheckStatus (status);
1005                 }
1006
1007                 public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
1008                 {
1009                         if (pen == null)
1010                                 throw new ArgumentNullException ("pen");
1011                         Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
1012                         GDIPlus.CheckStatus (status);
1013                 }
1014
1015                 public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
1016                 {
1017                         if (pen == null)
1018                                 throw new ArgumentNullException ("pen");
1019                         Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
1020                         GDIPlus.CheckStatus (status);
1021                 }
1022
1023                 public void DrawLines (Pen pen, PointF [] points)
1024                 {
1025                         if (pen == null)
1026                                 throw new ArgumentNullException ("pen");
1027                         if (points == null)
1028                                 throw new ArgumentNullException ("points");
1029                         Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
1030                         GDIPlus.CheckStatus (status);
1031                 }
1032
1033                 public void DrawLines (Pen pen, Point [] points)
1034                 {
1035                         if (pen == null)
1036                                 throw new ArgumentNullException ("pen");
1037                         if (points == null)
1038                                 throw new ArgumentNullException ("points");
1039                         Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
1040                         GDIPlus.CheckStatus (status);
1041                 }
1042
1043                 public void DrawPath (Pen pen, GraphicsPath path)
1044                 {
1045                         if (pen == null)
1046                                 throw new ArgumentNullException ("pen");
1047                         if (path == null)
1048                                 throw new ArgumentNullException ("path");
1049                         Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
1050                         GDIPlus.CheckStatus (status);
1051                 }
1052                 
1053                 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
1054                 {
1055                         if (pen == null)
1056                                 throw new ArgumentNullException ("pen");
1057                         DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1058                 }
1059                 
1060                 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
1061                 {
1062                         if (pen == null)
1063                                 throw new ArgumentNullException ("pen");
1064                         DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1065                 }
1066                 
1067                 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
1068                 {
1069                         if (pen == null)
1070                                 throw new ArgumentNullException ("pen");
1071                         Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
1072                         GDIPlus.CheckStatus (status);
1073                 }
1074                 
1075                 // Microsoft documentation states that the signature for this member should be
1076                 // public void DrawPie(Pen pen, int x,  int y,  int width,   int height,   int startAngle
1077                 // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
1078                 public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
1079                 {
1080                         if (pen == null)
1081                                 throw new ArgumentNullException ("pen");
1082                         Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
1083                         GDIPlus.CheckStatus (status);
1084                 }
1085
1086                 public void DrawPolygon (Pen pen, Point [] points)
1087                 {
1088                         if (pen == null)
1089                                 throw new ArgumentNullException ("pen");
1090                         if (points == null)
1091                                 throw new ArgumentNullException ("points");
1092                         Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
1093                         GDIPlus.CheckStatus (status);
1094                 }
1095
1096                 public void DrawPolygon (Pen pen, PointF [] points)
1097                 {
1098                         if (pen == null)
1099                                 throw new ArgumentNullException ("pen");
1100                         if (points == null)
1101                                 throw new ArgumentNullException ("points");
1102                         Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
1103                         GDIPlus.CheckStatus (status);
1104                 }
1105
1106                 internal void DrawRectangle (Pen pen, RectangleF rect)
1107                 {
1108                         if (pen == null)
1109                                 throw new ArgumentNullException ("pen");
1110                         DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
1111                 }
1112
1113                 public void DrawRectangle (Pen pen, Rectangle rect)
1114                 {
1115                         if (pen == null)
1116                                 throw new ArgumentNullException ("pen");
1117                         DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
1118                 }
1119
1120                 public void DrawRectangle (Pen pen, float x, float y, float width, float height)
1121                 {
1122                         if (pen == null)
1123                                 throw new ArgumentNullException ("pen");
1124                         Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
1125                         GDIPlus.CheckStatus (status);
1126                 }
1127
1128                 public void DrawRectangle (Pen pen, int x, int y, int width, int height)
1129                 {
1130                         if (pen == null)
1131                                 throw new ArgumentNullException ("pen");
1132                         Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
1133                         GDIPlus.CheckStatus (status);
1134                 }
1135
1136                 public void DrawRectangles (Pen pen, RectangleF [] rects)
1137                 {
1138                         if (pen == null)
1139                                 throw new ArgumentNullException ("image");
1140                         if (rects == null)
1141                                 throw new ArgumentNullException ("rects");
1142                         Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
1143                         GDIPlus.CheckStatus (status);
1144                 }
1145
1146                 public void DrawRectangles (Pen pen, Rectangle [] rects)
1147                 {
1148                         if (pen == null)
1149                                 throw new ArgumentNullException ("image");
1150                         if (rects == null)
1151                                 throw new ArgumentNullException ("rects");
1152                         Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
1153                         GDIPlus.CheckStatus (status);
1154                 }
1155
1156                 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
1157                 {
1158                         DrawString (s, font, brush, layoutRectangle, null);
1159                 }
1160
1161                 public void DrawString (string s, Font font, Brush brush, PointF point)
1162                 {
1163                         DrawString (s, font, brush, new RectangleF (point.X, point.Y, 0, 0), null);
1164                 }
1165
1166                 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
1167                 {
1168                         DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
1169                 }
1170
1171                 public void DrawString (string s, Font font, Brush brush, float x, float y)
1172                 {
1173                         DrawString (s, font, brush, new RectangleF (x, y, 0, 0), null);
1174                 }
1175
1176                 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
1177                 {
1178                         DrawString (s, font, brush, new RectangleF(x, y, 0, 0), format);
1179                 }
1180
1181                 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
1182                 {
1183                         if (font == null)
1184                                 throw new ArgumentNullException ("font");
1185                         if (brush == null)
1186                                 throw new ArgumentNullException ("brush");
1187                         if (s == null || s.Length == 0)
1188                                 return;
1189
1190                         Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.nativeObject);
1191                         GDIPlus.CheckStatus (status);
1192                 }
1193
1194                 public void EndContainer (GraphicsContainer container)
1195                 {
1196 #if NET_2_0
1197                         if (container == null)
1198                                 throw new ArgumentNullException ("container");
1199 #endif
1200                         Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
1201                         GDIPlus.CheckStatus (status);
1202                 }
1203
1204                 private const string MetafileEnumeration = "Metafiles enumeration, for both WMF and EMF formats, isn't supported.";
1205
1206                 [MonoTODO (MetafileEnumeration)]
1207                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
1208                 {
1209                         throw new NotImplementedException ();
1210                 }
1211
1212                 [MonoTODO (MetafileEnumeration)]
1213                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
1214                 {
1215                         throw new NotImplementedException ();
1216                 }
1217
1218                 [MonoTODO (MetafileEnumeration)]
1219                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
1220                 {
1221                         throw new NotImplementedException ();
1222                 }
1223
1224                 [MonoTODO (MetafileEnumeration)]
1225                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
1226                 {
1227                         throw new NotImplementedException ();
1228                 }
1229
1230                 [MonoTODO (MetafileEnumeration)]
1231                 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
1232                 {
1233                         throw new NotImplementedException ();
1234                 }
1235
1236                 [MonoTODO (MetafileEnumeration)]
1237                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
1238                 {
1239                         throw new NotImplementedException ();
1240                 }
1241
1242                 [MonoTODO (MetafileEnumeration)]
1243                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1244                 {
1245                         throw new NotImplementedException ();
1246                 }
1247
1248                 [MonoTODO (MetafileEnumeration)]
1249                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1250                 {
1251                         throw new NotImplementedException ();
1252                 }
1253
1254                 [MonoTODO (MetafileEnumeration)]
1255                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1256                 {
1257                         throw new NotImplementedException ();
1258                 }
1259
1260                 [MonoTODO (MetafileEnumeration)]
1261                 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1262                 {
1263                         throw new NotImplementedException ();
1264                 }
1265
1266                 [MonoTODO (MetafileEnumeration)]
1267                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1268                 {
1269                         throw new NotImplementedException ();
1270                 }
1271
1272                 [MonoTODO (MetafileEnumeration)]
1273                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1274                 {
1275                         throw new NotImplementedException ();
1276                 }
1277
1278                 [MonoTODO (MetafileEnumeration)]
1279                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1280                 {
1281                         throw new NotImplementedException ();
1282                 }
1283
1284                 [MonoTODO (MetafileEnumeration)]
1285                 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1286                 {
1287                         throw new NotImplementedException ();
1288                 }
1289
1290                 [MonoTODO (MetafileEnumeration)]
1291                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1292                 {
1293                         throw new NotImplementedException ();
1294                 }
1295
1296                 [MonoTODO (MetafileEnumeration)]
1297                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1298                 {
1299                         throw new NotImplementedException ();
1300                 }
1301
1302                 [MonoTODO (MetafileEnumeration)]
1303                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1304                 {
1305                         throw new NotImplementedException ();
1306                 }
1307
1308                 [MonoTODO (MetafileEnumeration)]
1309                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1310                 {
1311                         throw new NotImplementedException ();
1312                 }
1313
1314                 [MonoTODO (MetafileEnumeration)]
1315                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1316                 {
1317                         throw new NotImplementedException ();
1318                 }
1319
1320                 [MonoTODO (MetafileEnumeration)]
1321                 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1322                 {
1323                         throw new NotImplementedException ();
1324                 }
1325
1326                 [MonoTODO (MetafileEnumeration)]
1327                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1328                 {
1329                         throw new NotImplementedException ();
1330                 }
1331
1332                 [MonoTODO (MetafileEnumeration)]
1333                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1334                 {
1335                         throw new NotImplementedException ();
1336                 }
1337
1338                 [MonoTODO (MetafileEnumeration)]
1339                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1340                 {
1341                         throw new NotImplementedException ();
1342                 }
1343
1344                 [MonoTODO (MetafileEnumeration)]
1345                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1346                 {
1347                         throw new NotImplementedException ();
1348                 }
1349
1350                 [MonoTODO (MetafileEnumeration)]
1351                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1352                 {
1353                         throw new NotImplementedException ();
1354                 }
1355
1356                 [MonoTODO (MetafileEnumeration)]
1357                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1358                 {
1359                         throw new NotImplementedException ();
1360                 }
1361
1362                 [MonoTODO (MetafileEnumeration)]
1363                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1364                 {
1365                         throw new NotImplementedException ();
1366                 }
1367
1368                 [MonoTODO (MetafileEnumeration)]
1369                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1370                 {
1371                         throw new NotImplementedException ();
1372                 }
1373
1374                 [MonoTODO (MetafileEnumeration)]
1375                 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1376                 {
1377                         throw new NotImplementedException ();
1378                 }
1379
1380                 [MonoTODO (MetafileEnumeration)]
1381                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1382                 {
1383                         throw new NotImplementedException ();
1384                 }
1385
1386                 [MonoTODO (MetafileEnumeration)]
1387                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1388                 {
1389                         throw new NotImplementedException ();
1390                 }
1391
1392                 [MonoTODO (MetafileEnumeration)]
1393                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1394                 {
1395                         throw new NotImplementedException ();
1396                 }
1397
1398                 [MonoTODO (MetafileEnumeration)]
1399                 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1400                 {
1401                         throw new NotImplementedException ();
1402                 }
1403
1404                 [MonoTODO (MetafileEnumeration)]
1405                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1406                 {
1407                         throw new NotImplementedException ();
1408                 }
1409
1410                 [MonoTODO (MetafileEnumeration)]
1411                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1412                 {
1413                         throw new NotImplementedException ();
1414                 }
1415
1416                 [MonoTODO (MetafileEnumeration)]
1417                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1418                 {
1419                         throw new NotImplementedException ();
1420                 }
1421         
1422                 public void ExcludeClip (Rectangle rect)
1423                 {
1424                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1425                         GDIPlus.CheckStatus (status);
1426                 }
1427
1428                 public void ExcludeClip (Region region)
1429                 {
1430                         if (region == null)
1431                                 throw new ArgumentNullException ("region");
1432                         Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
1433                         GDIPlus.CheckStatus (status);
1434                 }
1435
1436                 
1437                 public void FillClosedCurve (Brush brush, PointF [] points)
1438                 {
1439                         if (brush == null)
1440                                 throw new ArgumentNullException ("brush");
1441                         if (points == null)
1442                                 throw new ArgumentNullException ("points");
1443                         Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1444                         GDIPlus.CheckStatus (status);
1445                 }
1446                 
1447                 public void FillClosedCurve (Brush brush, Point [] points)
1448                 {
1449                         if (brush == null)
1450                                 throw new ArgumentNullException ("brush");
1451                         if (points == null)
1452                                 throw new ArgumentNullException ("points");
1453                         Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1454                         GDIPlus.CheckStatus (status);
1455                 }
1456
1457                 
1458                 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1459                 {
1460                         if (brush == null)
1461                                 throw new ArgumentNullException ("brush");
1462                         if (points == null)
1463                                 throw new ArgumentNullException ("points");
1464                         FillClosedCurve (brush, points, fillmode, 0.5f);
1465                 }
1466                 
1467                 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1468                 {
1469                         if (brush == null)
1470                                 throw new ArgumentNullException ("brush");
1471                         if (points == null)
1472                                 throw new ArgumentNullException ("points");
1473                         FillClosedCurve (brush, points, fillmode, 0.5f);
1474                 }
1475
1476                 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1477                 {
1478                         if (brush == null)
1479                                 throw new ArgumentNullException ("brush");
1480                         if (points == null)
1481                                 throw new ArgumentNullException ("points");
1482                         Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1483                         GDIPlus.CheckStatus (status);
1484                 }
1485
1486                 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1487                 {
1488                         if (brush == null)
1489                                 throw new ArgumentNullException ("brush");
1490                         if (points == null)
1491                                 throw new ArgumentNullException ("points");
1492                         Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1493                         GDIPlus.CheckStatus (status);
1494                 }
1495
1496                 public void FillEllipse (Brush brush, Rectangle rect)
1497                 {
1498                         if (brush == null)
1499                                 throw new ArgumentNullException ("brush");
1500                         FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1501                 }
1502
1503                 public void FillEllipse (Brush brush, RectangleF rect)
1504                 {
1505                         if (brush == null)
1506                                 throw new ArgumentNullException ("brush");
1507                         FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1508                 }
1509
1510                 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1511                 {
1512                         if (brush == null)
1513                                 throw new ArgumentNullException ("brush");
1514                         Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1515                         GDIPlus.CheckStatus (status);
1516                 }
1517
1518                 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1519                 {
1520                         if (brush == null)
1521                                 throw new ArgumentNullException ("brush");
1522                         Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1523                         GDIPlus.CheckStatus (status);
1524                 }
1525
1526                 public void FillPath (Brush brush, GraphicsPath path)
1527                 {
1528                         if (brush == null)
1529                                 throw new ArgumentNullException ("brush");
1530                         if (path == null)
1531                                 throw new ArgumentNullException ("path");
1532                         Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject,  path.NativeObject);
1533                         GDIPlus.CheckStatus (status);
1534                 }
1535
1536                 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1537                 {
1538                         if (brush == null)
1539                                 throw new ArgumentNullException ("brush");
1540                         Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1541                         GDIPlus.CheckStatus (status);
1542                 }
1543
1544                 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1545                 {
1546                         if (brush == null)
1547                                 throw new ArgumentNullException ("brush");
1548                         Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1549                         GDIPlus.CheckStatus (status);
1550                 }
1551
1552                 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1553                 {
1554                         if (brush == null)
1555                                 throw new ArgumentNullException ("brush");
1556                         Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1557                         GDIPlus.CheckStatus (status);
1558                 }
1559
1560                 public void FillPolygon (Brush brush, PointF [] points)
1561                 {
1562                         if (brush == null)
1563                                 throw new ArgumentNullException ("brush");
1564                         if (points == null)
1565                                 throw new ArgumentNullException ("points");
1566                         Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1567                         GDIPlus.CheckStatus (status);
1568                 }
1569
1570                 public void FillPolygon (Brush brush, Point [] points)
1571                 {
1572                         if (brush == null)
1573                                 throw new ArgumentNullException ("brush");
1574                         if (points == null)
1575                                 throw new ArgumentNullException ("points");
1576                         Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1577                         GDIPlus.CheckStatus (status);
1578                 }
1579
1580                 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1581                 {
1582                         if (brush == null)
1583                                 throw new ArgumentNullException ("brush");
1584                         if (points == null)
1585                                 throw new ArgumentNullException ("points");
1586                         Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1587                         GDIPlus.CheckStatus (status);
1588                 }
1589
1590                 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1591                 {
1592                         if (brush == null)
1593                                 throw new ArgumentNullException ("brush");
1594                         if (points == null)
1595                                 throw new ArgumentNullException ("points");
1596                         Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1597                         GDIPlus.CheckStatus (status);
1598                 }
1599
1600                 public void FillRectangle (Brush brush, RectangleF rect)
1601                 {
1602                         if (brush == null)
1603                                 throw new ArgumentNullException ("brush");
1604                         FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1605                 }
1606
1607                 public void FillRectangle (Brush brush, Rectangle rect)
1608                 {
1609                         if (brush == null)
1610                                 throw new ArgumentNullException ("brush");
1611                         FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1612                 }
1613
1614                 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1615                 {
1616                         if (brush == null)
1617                                 throw new ArgumentNullException ("brush");
1618                         
1619                         Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
1620                         GDIPlus.CheckStatus (status);
1621                 }
1622
1623                 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1624                 {
1625                         if (brush == null)
1626                                 throw new ArgumentNullException ("brush");
1627                         
1628                         Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1629                         GDIPlus.CheckStatus (status);
1630                 }
1631
1632                 public void FillRectangles (Brush brush, Rectangle [] rects)
1633                 {
1634                         if (brush == null)
1635                                 throw new ArgumentNullException ("brush");
1636                         if (rects == null)
1637                                 throw new ArgumentNullException ("rects");
1638
1639                         Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
1640                         GDIPlus.CheckStatus (status);
1641                 }
1642
1643                 public void FillRectangles (Brush brush, RectangleF [] rects)
1644                 {
1645                         if (brush == null)
1646                                 throw new ArgumentNullException ("brush");
1647                         if (rects == null)
1648                                 throw new ArgumentNullException ("rects");
1649
1650                         Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
1651                         GDIPlus.CheckStatus (status);
1652                 }
1653
1654                 
1655                 public void FillRegion (Brush brush, Region region)
1656                 {
1657                         if (brush == null)
1658                                 throw new ArgumentNullException ("brush");
1659                         if (region == null)
1660                                 throw new ArgumentNullException ("region");
1661                         
1662                         Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);                  
1663                         GDIPlus.CheckStatus(status);
1664                 }
1665
1666                 
1667                 public void Flush ()
1668                 {
1669                         Flush (FlushIntention.Flush);
1670                 }
1671
1672                 
1673                 public void Flush (FlushIntention intention)
1674                 {
1675                         if (nativeObject == IntPtr.Zero) {
1676                                 return;
1677                         }
1678
1679                         Status status = GDIPlus.GdipFlush (nativeObject, intention);
1680                         GDIPlus.CheckStatus (status);                    
1681                         if (GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable)
1682                                 Carbon.CGContextSynchronize (GDIPlus.Display);
1683                 }
1684
1685                 [EditorBrowsable (EditorBrowsableState.Advanced)]               
1686                 public static Graphics FromHdc (IntPtr hdc)
1687                 {
1688                         IntPtr graphics;
1689                         Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
1690                         GDIPlus.CheckStatus (status);
1691                         return new Graphics (graphics);
1692                 }
1693
1694                 [MonoTODO]
1695                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1696                 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1697                 {
1698                         throw new NotImplementedException ();
1699                 }
1700
1701                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1702                 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1703                 public static Graphics FromHdcInternal (IntPtr hdc)
1704                 {
1705                         GDIPlus.Display = hdc;
1706                         return null;
1707                 }
1708
1709                 [EditorBrowsable (EditorBrowsableState.Advanced)]               
1710                 public static Graphics FromHwnd (IntPtr hwnd)
1711                 {
1712                         IntPtr graphics;
1713
1714                         if (GDIPlus.UseCocoaDrawable) {
1715                                 CarbonContext cgContext = Carbon.GetCGContextForNSView (hwnd);
1716                                 GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
1717                                 
1718                                 GDIPlus.Display = cgContext.ctx;
1719                                 return new Graphics (graphics);
1720                         }
1721                         if (GDIPlus.UseQuartzDrawable) {
1722                                 CarbonContext cgContext = Carbon.GetCGContextForView (hwnd);
1723                                 GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
1724                                 
1725                                 GDIPlus.Display = cgContext.ctx;
1726                                 return new Graphics (graphics);
1727                         }
1728                         if (GDIPlus.UseX11Drawable) {
1729                                 if (GDIPlus.Display == IntPtr.Zero) {
1730                                         GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
1731                                 }
1732
1733                                 return FromXDrawable (hwnd, GDIPlus.Display);
1734
1735                         }
1736
1737                         Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
1738                         GDIPlus.CheckStatus (status);
1739
1740                         return new Graphics (graphics);
1741                 }
1742                 
1743                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1744                 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1745                 public static Graphics FromHwndInternal (IntPtr hwnd)
1746                 {
1747                         return FromHwnd (hwnd);
1748                 }
1749
1750                 public static Graphics FromImage (Image image)
1751                 {
1752                         IntPtr graphics;
1753
1754                         if (image == null) 
1755                                 throw new ArgumentNullException ("image");
1756
1757                         if ((image.PixelFormat & PixelFormat.Indexed) != 0)
1758                                 throw new Exception (Locale.GetText ("Cannot create Graphics from an indexed bitmap."));
1759
1760                         Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1761                         GDIPlus.CheckStatus (status);
1762                         Graphics result = new Graphics (graphics);
1763                                 
1764                         if (GDIPlus.RunningOnUnix ()) {
1765                                 Rectangle rect  = new Rectangle (0,0, image.Width, image.Height);
1766                                 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
1767                         }
1768                                 
1769                         return result;
1770                 }
1771
1772                 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1773                 {
1774                         IntPtr graphics;
1775
1776                         Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1777                         GDIPlus.CheckStatus (s);
1778                         return new Graphics (graphics);
1779                 }
1780
1781                 [MonoTODO]
1782                 public static IntPtr GetHalftonePalette ()
1783                 {
1784                         throw new NotImplementedException ();
1785                 }
1786
1787 #if !NET_2_0
1788                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1789 #endif
1790                 public IntPtr GetHdc ()
1791                 {
1792                         IntPtr hdc;
1793                         GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out hdc));
1794 #if NET_2_0
1795                         deviceContextHdc = hdc;
1796 #endif
1797                         return hdc;
1798                 }
1799
1800                 
1801                 public Color GetNearestColor (Color color)
1802                 {
1803                         int argb;
1804                         
1805                         Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1806                         GDIPlus.CheckStatus (status);
1807
1808                         return Color.FromArgb (argb);
1809                 }
1810
1811                 
1812                 public void IntersectClip (Region region)
1813                 {
1814                         if (region == null)
1815                                 throw new ArgumentNullException ("region");
1816                         Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1817                         GDIPlus.CheckStatus (status);
1818                 }
1819                 
1820                 public void IntersectClip (RectangleF rect)
1821                 {
1822                         Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1823                         GDIPlus.CheckStatus (status);
1824                 }
1825
1826                 public void IntersectClip (Rectangle rect)
1827                 {                       
1828                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1829                         GDIPlus.CheckStatus (status);
1830                 }
1831
1832                 public bool IsVisible (Point point)
1833                 {
1834                         bool isVisible = false;
1835
1836                         Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1837                         GDIPlus.CheckStatus (status);
1838
1839                         return isVisible;
1840                 }
1841
1842                 
1843                 public bool IsVisible (RectangleF rect)
1844                 {
1845                         bool isVisible = false;
1846
1847                         Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1848                         GDIPlus.CheckStatus (status);
1849
1850                         return isVisible;
1851                 }
1852
1853                 public bool IsVisible (PointF point)
1854                 {
1855                         bool isVisible = false;
1856
1857                         Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1858                         GDIPlus.CheckStatus (status);
1859
1860                         return isVisible;
1861                 }
1862                 
1863                 public bool IsVisible (Rectangle rect)
1864                 {
1865                         bool isVisible = false;
1866
1867                         Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1868                         GDIPlus.CheckStatus (status);
1869
1870                         return isVisible;
1871                 }
1872                 
1873                 public bool IsVisible (float x, float y)
1874                 {
1875                         return IsVisible (new PointF (x, y));
1876                 }
1877                 
1878                 public bool IsVisible (int x, int y)
1879                 {
1880                         return IsVisible (new Point (x, y));
1881                 }
1882                 
1883                 public bool IsVisible (float x, float y, float width, float height)
1884                 {
1885                         return IsVisible (new RectangleF (x, y, width, height));
1886                 }
1887
1888                 
1889                 public bool IsVisible (int x, int y, int width, int height)
1890                 {
1891                         return IsVisible (new Rectangle (x, y, width, height));
1892                 }
1893
1894                 
1895                 public Region[] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1896                 {
1897                         if ((text == null) || (text.Length == 0))
1898                                 return new Region [0];
1899
1900                         if (font == null)
1901                                 throw new ArgumentNullException ("font");
1902
1903                         if (stringFormat == null)
1904                                 throw new ArgumentException ("stringFormat");
1905
1906                         int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
1907                         if (regcount == 0)
1908                                 return new Region[0];
1909
1910                         IntPtr[] native_regions = new IntPtr [regcount];
1911                         Region[] regions = new Region [regcount];
1912                         
1913                         for (int i = 0; i < regcount; i++) {
1914                                 regions[i] = new Region ();
1915                                 native_regions[i] = regions[i].NativeObject;
1916                         }
1917                         
1918                         Status status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
1919                                 font.NativeObject, ref layoutRect, stringFormat.NativeObject, regcount, out native_regions[0]); 
1920                         GDIPlus.CheckStatus (status);                           
1921
1922                         return regions;                                                 
1923                 }
1924
1925                 
1926                 public SizeF MeasureString (string text, Font font)
1927                 {
1928                         return MeasureString (text, font, SizeF.Empty);
1929                 }
1930
1931                 
1932                 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1933                 {
1934                         if (text == null || text.Length == 0)
1935                                 return SizeF.Empty;
1936
1937                         if (font == null)
1938                                 throw new ArgumentNullException ("font");
1939
1940                         int charactersFitted, linesFilled;
1941                         RectangleF boundingBox = new RectangleF ();
1942                         RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1943
1944                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1945                                                                    font.NativeObject, ref rect,
1946                                                                    IntPtr.Zero, out boundingBox,
1947                                                                    out charactersFitted, out linesFilled);
1948                         GDIPlus.CheckStatus (status);
1949
1950                         return new SizeF (boundingBox.Width, boundingBox.Height);
1951                 }
1952
1953                 
1954                 public SizeF MeasureString (string text, Font font, int width)
1955                 {                               
1956                         if (text == null || text.Length == 0)
1957                                 return SizeF.Empty;
1958
1959                         if (font == null)
1960                                 throw new ArgumentNullException ("font");
1961
1962                         RectangleF boundingBox = new RectangleF ();
1963                         RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
1964                         int charactersFitted, linesFilled;
1965
1966                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
1967                                                                    font.NativeObject, ref rect,
1968                                                                    IntPtr.Zero, out boundingBox,
1969                                                                    out charactersFitted, out linesFilled);
1970                         GDIPlus.CheckStatus (status);
1971
1972                         return new SizeF (boundingBox.Width, boundingBox.Height);
1973                 }
1974
1975                 
1976                 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
1977                                             StringFormat stringFormat)
1978                 {
1979                         int charactersFitted, linesFilled;                      
1980                         return MeasureString (text, font, layoutArea, stringFormat,
1981                                               out charactersFitted, out linesFilled);
1982                 }
1983
1984                 
1985                 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1986                 {
1987                         int charactersFitted, linesFilled;                      
1988                         return MeasureString (text, font, new SizeF (width, Int32.MaxValue), 
1989                                               format, out charactersFitted, out linesFilled);
1990                 }
1991
1992                 
1993                 public SizeF MeasureString (string text, Font font, PointF origin,
1994                                             StringFormat stringFormat)
1995                 {
1996                         if (text == null || text.Length == 0)
1997                                 return SizeF.Empty;
1998
1999                         if (font == null)
2000                                 throw new ArgumentNullException ("font");
2001
2002                         RectangleF boundingBox = new RectangleF ();
2003                         RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
2004                         int charactersFitted, linesFilled;
2005
2006                         IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
2007
2008                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
2009                                                                    font.NativeObject, ref rect, format, 
2010                                                                    out boundingBox,
2011                                                                    out charactersFitted,
2012                                                                    out linesFilled);
2013                         GDIPlus.CheckStatus (status);
2014
2015                         return new SizeF (boundingBox.Width, boundingBox.Height);
2016                 }
2017
2018                 
2019                 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
2020                                             StringFormat stringFormat, out int charactersFitted,
2021                                             out int linesFilled)
2022                 {       
2023                         charactersFitted = 0;
2024                         linesFilled = 0;
2025
2026                         if (text == null || text.Length == 0)
2027                                 return SizeF.Empty;
2028
2029                         if (font == null)
2030                                 throw new ArgumentNullException ("font");
2031
2032                         RectangleF boundingBox = new RectangleF ();
2033                         RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
2034
2035                         IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
2036
2037                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
2038                                                                    font.NativeObject, ref rect, format,
2039                                                                    out boundingBox,
2040                                                                    out charactersFitted,
2041                                                                    out linesFilled);
2042                         GDIPlus.CheckStatus (status);
2043
2044                         return new SizeF (boundingBox.Width, boundingBox.Height);
2045                 }
2046
2047                 public void MultiplyTransform (Matrix matrix)
2048                 {
2049                         MultiplyTransform (matrix, MatrixOrder.Prepend);
2050                 }
2051
2052                 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
2053                 {
2054                         Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject,
2055                                                                             matrix.nativeMatrix,
2056                                                                             order);
2057                         GDIPlus.CheckStatus (status);
2058                 }
2059
2060                 [EditorBrowsable (EditorBrowsableState.Advanced)]
2061                 public void ReleaseHdc (IntPtr hdc)
2062                 {
2063                         Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
2064                         GDIPlus.CheckStatus (status);
2065 #if NET_2_0
2066                         if (hdc == deviceContextHdc)
2067                                 deviceContextHdc = IntPtr.Zero;
2068 #endif
2069                 }
2070
2071 #if NET_2_0
2072                 public void ReleaseHdc ()
2073                 {
2074                         if (deviceContextHdc == IntPtr.Zero)
2075                                 throw new ArgumentException ("Invalid Handle");
2076
2077                         ReleaseHdc (deviceContextHdc);
2078                 }
2079 #endif
2080
2081                 [MonoTODO ("Parameter hdc doesn't map well into libgdiplus")]
2082 #if NET_2_0
2083                 [EditorBrowsable (EditorBrowsableState.Never)]
2084 #else
2085                 [EditorBrowsable (EditorBrowsableState.Advanced)]
2086 #endif
2087                 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
2088                 public void ReleaseHdcInternal (IntPtr hdc)
2089                 {
2090                         throw new NotImplementedException ();
2091                 }
2092
2093                 
2094                 public void ResetClip ()
2095                 {
2096                         Status status = GDIPlus.GdipResetClip (nativeObject);
2097                         GDIPlus.CheckStatus (status);
2098                 }
2099
2100                 public void ResetTransform ()
2101                 {
2102                         Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
2103                         GDIPlus.CheckStatus (status);
2104                 }
2105
2106                 public void Restore (GraphicsState gstate)
2107                 {                       
2108                         Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
2109                         GDIPlus.CheckStatus (status);
2110                 }
2111
2112
2113                 public void RotateTransform (float angle)
2114                 {
2115                         RotateTransform (angle, MatrixOrder.Prepend);
2116                 }
2117
2118                 public void RotateTransform (float angle, MatrixOrder order)
2119                 {
2120
2121                         Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
2122                         GDIPlus.CheckStatus (status);
2123                 }
2124
2125                 public GraphicsState Save ()
2126                 {                                               
2127                         uint saveState;
2128                         Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
2129                         GDIPlus.CheckStatus (status);
2130
2131                         GraphicsState state = new GraphicsState ();
2132                         state.nativeState = saveState;
2133                         return state;
2134                 }
2135
2136                 public void ScaleTransform (float sx, float sy)
2137                 {
2138                         ScaleTransform (sx, sy, MatrixOrder.Prepend);
2139                 }
2140
2141                 public void ScaleTransform (float sx, float sy, MatrixOrder order)
2142                 {
2143                         Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
2144                         GDIPlus.CheckStatus (status);
2145                 }
2146
2147                 
2148                 public void SetClip (RectangleF rect)
2149                 {
2150                         SetClip (rect, CombineMode.Replace);
2151                 }
2152
2153                 
2154                 public void SetClip (GraphicsPath path)
2155                 {
2156                         SetClip (path, CombineMode.Replace);
2157                 }
2158
2159                 
2160                 public void SetClip (Rectangle rect)
2161                 {
2162                         SetClip (rect, CombineMode.Replace);
2163                 }
2164
2165                 
2166                 public void SetClip (Graphics g)
2167                 {
2168                         SetClip (g, CombineMode.Replace);
2169                 }
2170
2171                 
2172                 public void SetClip (Graphics g, CombineMode combineMode)
2173                 {
2174                         if (g == null)
2175                                 throw new ArgumentNullException ("g");
2176                         
2177                         Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
2178                         GDIPlus.CheckStatus (status);
2179                 }
2180
2181                 
2182                 public void SetClip (Rectangle rect, CombineMode combineMode)
2183                 {
2184                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2185                         GDIPlus.CheckStatus (status);
2186                 }
2187
2188                 
2189                 public void SetClip (RectangleF rect, CombineMode combineMode)
2190                 {
2191                         Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2192                         GDIPlus.CheckStatus (status);
2193                 }
2194
2195                 
2196                 public void SetClip (Region region, CombineMode combineMode)
2197                 {
2198                         if (region == null)
2199                                 throw new ArgumentNullException ("region");
2200                         Status status =   GDIPlus.GdipSetClipRegion(nativeObject,  region.NativeObject, combineMode); 
2201                         GDIPlus.CheckStatus (status);
2202                 }
2203
2204                 
2205                 public void SetClip (GraphicsPath path, CombineMode combineMode)
2206                 {
2207                         if (path == null)
2208                                 throw new ArgumentNullException ("path");
2209                         Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
2210                         GDIPlus.CheckStatus (status);
2211                 }
2212
2213                 
2214                 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
2215                 {
2216                         if (pts == null)
2217                                 throw new ArgumentNullException ("pts");
2218
2219                         IntPtr ptrPt =  GDIPlus.FromPointToUnManagedMemory (pts);
2220             
2221                         Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace,  ptrPt, pts.Length);
2222                         GDIPlus.CheckStatus (status);
2223                         
2224                         GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
2225                 }
2226
2227
2228                 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
2229                 {                                               
2230                         if (pts == null)
2231                                 throw new ArgumentNullException ("pts");
2232                         IntPtr ptrPt =  GDIPlus.FromPointToUnManagedMemoryI (pts);
2233             
2234                         Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2235                         GDIPlus.CheckStatus (status);
2236                         
2237                         GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
2238                 }
2239
2240                 
2241                 public void TranslateClip (int dx, int dy)
2242                 {
2243                         Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
2244                         GDIPlus.CheckStatus (status);
2245                 }
2246
2247                 
2248                 public void TranslateClip (float dx, float dy)
2249                 {
2250                         Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
2251                         GDIPlus.CheckStatus (status);
2252                 }
2253
2254                 public void TranslateTransform (float dx, float dy)
2255                 {
2256                         TranslateTransform (dx, dy, MatrixOrder.Prepend);
2257                 }
2258
2259                 
2260                 public void TranslateTransform (float dx, float dy, MatrixOrder order)
2261                 {                       
2262                         Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
2263                         GDIPlus.CheckStatus (status);
2264                 }
2265
2266                 public Region Clip {
2267                         get {
2268                                 Region reg = new Region();
2269                                 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
2270                                 GDIPlus.CheckStatus (status);
2271                                 return reg;                             
2272                         }
2273                         set {
2274                                 SetClip (value, CombineMode.Replace);
2275                         }
2276                 }
2277
2278                 public RectangleF ClipBounds {
2279                         get {
2280                                 RectangleF rect = new RectangleF ();
2281                                 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
2282                                 GDIPlus.CheckStatus (status);
2283                                 return rect;
2284                         }
2285                 }
2286
2287                 public CompositingMode CompositingMode {
2288                         get {
2289                                 CompositingMode mode;
2290                                 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
2291                                 GDIPlus.CheckStatus (status);
2292
2293                                 return mode;
2294                         }
2295                         set {
2296                                 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
2297                                 GDIPlus.CheckStatus (status);
2298                         }
2299
2300                 }
2301
2302                 public CompositingQuality CompositingQuality {
2303                         get {
2304                                 CompositingQuality quality;
2305
2306                                 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
2307                                 GDIPlus.CheckStatus (status);
2308                                 return quality;
2309                         }
2310                         set {
2311                                 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
2312                                 GDIPlus.CheckStatus (status);
2313                         }
2314                 }
2315
2316                 public float DpiX {
2317                         get {
2318                                 float x;
2319
2320                                 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
2321                                 GDIPlus.CheckStatus (status);
2322                                 return x;
2323                         }
2324                 }
2325
2326                 public float DpiY {
2327                         get {
2328                                 float y;
2329
2330                                 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
2331                                 GDIPlus.CheckStatus (status);
2332                                 return y;
2333                         }
2334                 }
2335
2336                 public InterpolationMode InterpolationMode {
2337                         get {                           
2338                                 InterpolationMode imode = InterpolationMode.Invalid;
2339                                 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
2340                                 GDIPlus.CheckStatus (status);
2341                                 return imode;
2342                         }
2343                         set {
2344                                 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
2345                                 GDIPlus.CheckStatus (status);
2346                         }
2347                 }
2348
2349                 public bool IsClipEmpty {
2350                         get {
2351                                 bool isEmpty = false;
2352
2353                                 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
2354                                 GDIPlus.CheckStatus (status);
2355                                 return isEmpty;
2356                         }
2357                 }
2358
2359                 public bool IsVisibleClipEmpty {
2360                         get {
2361                                 bool isEmpty = false;
2362
2363                                 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
2364                                 GDIPlus.CheckStatus (status);
2365                                 return isEmpty;
2366                         }
2367                 }
2368
2369                 public float PageScale {
2370                         get {
2371                                 float scale;
2372
2373                                 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
2374                                 GDIPlus.CheckStatus (status);
2375                                 return scale;
2376                         }
2377                         set {
2378                                 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
2379                                 GDIPlus.CheckStatus (status);
2380                         }
2381                 }
2382
2383                 public GraphicsUnit PageUnit {
2384                         get {
2385                                 GraphicsUnit unit;
2386                                 
2387                                 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
2388                                 GDIPlus.CheckStatus (status);
2389                                 return unit;
2390                         }
2391                         set {
2392                                 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
2393                                 GDIPlus.CheckStatus (status);
2394                         }
2395                 }
2396
2397                 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2398                 public PixelOffsetMode PixelOffsetMode {
2399                         get {
2400                                 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
2401                                 
2402                                 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
2403                                 GDIPlus.CheckStatus (status);
2404                                 return pixelOffset;
2405                         }
2406                         set {
2407                                 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value); 
2408                                 GDIPlus.CheckStatus (status);
2409                         }
2410                 }
2411
2412                 public Point RenderingOrigin {
2413                         get {
2414                                 int x, y;
2415                                 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
2416                                 GDIPlus.CheckStatus (status);
2417                                 return new Point (x, y);
2418                         }
2419
2420                         set {
2421                                 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
2422                                 GDIPlus.CheckStatus (status);
2423                         }
2424                 }
2425
2426                 public SmoothingMode SmoothingMode {
2427                         get {
2428                                 SmoothingMode mode = SmoothingMode.Invalid;
2429
2430                                 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
2431                                 GDIPlus.CheckStatus (status);
2432                                 return mode;
2433                         }
2434
2435                         set {
2436                                 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
2437                                 GDIPlus.CheckStatus (status);
2438                         }
2439                 }
2440
2441                 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2442                 public int TextContrast {
2443                         get {   
2444                                 int contrast;
2445                                         
2446                                 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
2447                                 GDIPlus.CheckStatus (status);
2448                                 return contrast;
2449                         }
2450
2451                         set {
2452                                 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
2453                                 GDIPlus.CheckStatus (status);
2454                         }
2455                 }
2456
2457                 public TextRenderingHint TextRenderingHint {
2458                         get {
2459                                 TextRenderingHint hint;
2460
2461                                 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
2462                                 GDIPlus.CheckStatus (status);
2463                                 return hint;        
2464                         }
2465
2466                         set {
2467                                 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
2468                                 GDIPlus.CheckStatus (status);
2469                         }
2470                 }
2471
2472                 public Matrix Transform {
2473                         get {
2474                                 Matrix matrix = new Matrix ();
2475                                 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
2476                                 GDIPlus.CheckStatus (status);
2477                                 return matrix;
2478                         }
2479                         set {
2480                                 if (value == null)
2481                                         throw new ArgumentNullException ("value");
2482                                 
2483                                 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
2484                                 GDIPlus.CheckStatus (status);
2485                         }
2486                 }
2487
2488                 public RectangleF VisibleClipBounds {
2489                         get {
2490                                 RectangleF rect;
2491                                         
2492                                 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
2493                                 GDIPlus.CheckStatus (status);
2494                                 return rect;
2495                         }
2496                 }
2497
2498 #if NET_2_0
2499                 [MonoTODO]
2500                 [EditorBrowsable (EditorBrowsableState.Never)]
2501                 public object GetContextInfo ()
2502                 {
2503                         throw new NotImplementedException ();
2504                 }
2505 #endif
2506         }
2507 }