2007-02-28 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / System.Drawing / System.Drawing / Graphics.cs
1 //
2 // System.Drawing.Graphics.cs
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com) (stubbed out)
6 //      Alexandre Pigolkine(pigolkine@gmx.de)
7 //      Jordi Mas i Hernandez (jordi@ximian.com)
8 //      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                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1205                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
1206                 {
1207                         throw new NotImplementedException ();
1208                 }
1209
1210                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1211                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
1212                 {
1213                         throw new NotImplementedException ();
1214                 }
1215
1216                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1217                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
1218                 {
1219                         throw new NotImplementedException ();
1220                 }
1221
1222                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1223                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
1224                 {
1225                         throw new NotImplementedException ();
1226                 }
1227
1228                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1229                 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
1230                 {
1231                         throw new NotImplementedException ();
1232                 }
1233
1234                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1235                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
1236                 {
1237                         throw new NotImplementedException ();
1238                 }
1239
1240                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1241                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1242                 {
1243                         throw new NotImplementedException ();
1244                 }
1245
1246                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1247                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1248                 {
1249                         throw new NotImplementedException ();
1250                 }
1251
1252                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1253                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1254                 {
1255                         throw new NotImplementedException ();
1256                 }
1257
1258                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1259                 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1260                 {
1261                         throw new NotImplementedException ();
1262                 }
1263
1264                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1265                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1266                 {
1267                         throw new NotImplementedException ();
1268                 }
1269
1270                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1271                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1272                 {
1273                         throw new NotImplementedException ();
1274                 }
1275
1276                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1277                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1278                 {
1279                         throw new NotImplementedException ();
1280                 }
1281
1282                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1283                 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1284                 {
1285                         throw new NotImplementedException ();
1286                 }
1287
1288                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1289                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1290                 {
1291                         throw new NotImplementedException ();
1292                 }
1293
1294                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1295                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1296                 {
1297                         throw new NotImplementedException ();
1298                 }
1299
1300                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1301                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1302                 {
1303                         throw new NotImplementedException ();
1304                 }
1305
1306                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1307                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1308                 {
1309                         throw new NotImplementedException ();
1310                 }
1311
1312                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1313                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1314                 {
1315                         throw new NotImplementedException ();
1316                 }
1317
1318                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1319                 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1320                 {
1321                         throw new NotImplementedException ();
1322                 }
1323
1324                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1325                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1326                 {
1327                         throw new NotImplementedException ();
1328                 }
1329
1330                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1331                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1332                 {
1333                         throw new NotImplementedException ();
1334                 }
1335
1336                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1337                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1338                 {
1339                         throw new NotImplementedException ();
1340                 }
1341
1342                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1343                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1344                 {
1345                         throw new NotImplementedException ();
1346                 }
1347
1348                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1349                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1350                 {
1351                         throw new NotImplementedException ();
1352                 }
1353
1354                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1355                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1356                 {
1357                         throw new NotImplementedException ();
1358                 }
1359
1360                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1361                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1362                 {
1363                         throw new NotImplementedException ();
1364                 }
1365
1366                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1367                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1368                 {
1369                         throw new NotImplementedException ();
1370                 }
1371
1372                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1373                 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1374                 {
1375                         throw new NotImplementedException ();
1376                 }
1377
1378                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1379                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1380                 {
1381                         throw new NotImplementedException ();
1382                 }
1383
1384                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1385                 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1386                 {
1387                         throw new NotImplementedException ();
1388                 }
1389
1390                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1391                 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1392                 {
1393                         throw new NotImplementedException ();
1394                 }
1395
1396                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1397                 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1398                 {
1399                         throw new NotImplementedException ();
1400                 }
1401
1402                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1403                 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1404                 {
1405                         throw new NotImplementedException ();
1406                 }
1407
1408                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1409                 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1410                 {
1411                         throw new NotImplementedException ();
1412                 }
1413
1414                 [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
1415                 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1416                 {
1417                         throw new NotImplementedException ();
1418                 }
1419         
1420                 public void ExcludeClip (Rectangle rect)
1421                 {
1422                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1423                         GDIPlus.CheckStatus (status);
1424                 }
1425
1426                 public void ExcludeClip (Region region)
1427                 {
1428                         if (region == null)
1429                                 throw new ArgumentNullException ("region");
1430                         Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
1431                         GDIPlus.CheckStatus (status);
1432                 }
1433
1434                 
1435                 public void FillClosedCurve (Brush brush, PointF [] points)
1436                 {
1437                         if (brush == null)
1438                                 throw new ArgumentNullException ("brush");
1439                         if (points == null)
1440                                 throw new ArgumentNullException ("points");
1441                         Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1442                         GDIPlus.CheckStatus (status);
1443                 }
1444                 
1445                 public void FillClosedCurve (Brush brush, Point [] points)
1446                 {
1447                         if (brush == null)
1448                                 throw new ArgumentNullException ("brush");
1449                         if (points == null)
1450                                 throw new ArgumentNullException ("points");
1451                         Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1452                         GDIPlus.CheckStatus (status);
1453                 }
1454
1455                 
1456                 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1457                 {
1458                         if (brush == null)
1459                                 throw new ArgumentNullException ("brush");
1460                         if (points == null)
1461                                 throw new ArgumentNullException ("points");
1462                         FillClosedCurve (brush, points, fillmode, 0.5f);
1463                 }
1464                 
1465                 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1466                 {
1467                         if (brush == null)
1468                                 throw new ArgumentNullException ("brush");
1469                         if (points == null)
1470                                 throw new ArgumentNullException ("points");
1471                         FillClosedCurve (brush, points, fillmode, 0.5f);
1472                 }
1473
1474                 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1475                 {
1476                         if (brush == null)
1477                                 throw new ArgumentNullException ("brush");
1478                         if (points == null)
1479                                 throw new ArgumentNullException ("points");
1480                         Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1481                         GDIPlus.CheckStatus (status);
1482                 }
1483
1484                 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1485                 {
1486                         if (brush == null)
1487                                 throw new ArgumentNullException ("brush");
1488                         if (points == null)
1489                                 throw new ArgumentNullException ("points");
1490                         Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1491                         GDIPlus.CheckStatus (status);
1492                 }
1493
1494                 public void FillEllipse (Brush brush, Rectangle rect)
1495                 {
1496                         if (brush == null)
1497                                 throw new ArgumentNullException ("brush");
1498                         FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1499                 }
1500
1501                 public void FillEllipse (Brush brush, RectangleF rect)
1502                 {
1503                         if (brush == null)
1504                                 throw new ArgumentNullException ("brush");
1505                         FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1506                 }
1507
1508                 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1509                 {
1510                         if (brush == null)
1511                                 throw new ArgumentNullException ("brush");
1512                         Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1513                         GDIPlus.CheckStatus (status);
1514                 }
1515
1516                 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1517                 {
1518                         if (brush == null)
1519                                 throw new ArgumentNullException ("brush");
1520                         Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1521                         GDIPlus.CheckStatus (status);
1522                 }
1523
1524                 public void FillPath (Brush brush, GraphicsPath path)
1525                 {
1526                         if (brush == null)
1527                                 throw new ArgumentNullException ("brush");
1528                         if (path == null)
1529                                 throw new ArgumentNullException ("path");
1530                         Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject,  path.NativeObject);
1531                         GDIPlus.CheckStatus (status);
1532                 }
1533
1534                 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1535                 {
1536                         if (brush == null)
1537                                 throw new ArgumentNullException ("brush");
1538                         Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1539                         GDIPlus.CheckStatus (status);
1540                 }
1541
1542                 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1543                 {
1544                         if (brush == null)
1545                                 throw new ArgumentNullException ("brush");
1546                         Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1547                         GDIPlus.CheckStatus (status);
1548                 }
1549
1550                 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1551                 {
1552                         if (brush == null)
1553                                 throw new ArgumentNullException ("brush");
1554                         Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1555                         GDIPlus.CheckStatus (status);
1556                 }
1557
1558                 public void FillPolygon (Brush brush, PointF [] points)
1559                 {
1560                         if (brush == null)
1561                                 throw new ArgumentNullException ("brush");
1562                         if (points == null)
1563                                 throw new ArgumentNullException ("points");
1564                         Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1565                         GDIPlus.CheckStatus (status);
1566                 }
1567
1568                 public void FillPolygon (Brush brush, Point [] points)
1569                 {
1570                         if (brush == null)
1571                                 throw new ArgumentNullException ("brush");
1572                         if (points == null)
1573                                 throw new ArgumentNullException ("points");
1574                         Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1575                         GDIPlus.CheckStatus (status);
1576                 }
1577
1578                 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1579                 {
1580                         if (brush == null)
1581                                 throw new ArgumentNullException ("brush");
1582                         if (points == null)
1583                                 throw new ArgumentNullException ("points");
1584                         Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1585                         GDIPlus.CheckStatus (status);
1586                 }
1587
1588                 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1589                 {
1590                         if (brush == null)
1591                                 throw new ArgumentNullException ("brush");
1592                         if (points == null)
1593                                 throw new ArgumentNullException ("points");
1594                         Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1595                         GDIPlus.CheckStatus (status);
1596                 }
1597
1598                 public void FillRectangle (Brush brush, RectangleF rect)
1599                 {
1600                         if (brush == null)
1601                                 throw new ArgumentNullException ("brush");
1602                         FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1603                 }
1604
1605                 public void FillRectangle (Brush brush, Rectangle rect)
1606                 {
1607                         if (brush == null)
1608                                 throw new ArgumentNullException ("brush");
1609                         FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1610                 }
1611
1612                 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1613                 {
1614                         if (brush == null)
1615                                 throw new ArgumentNullException ("brush");
1616                         
1617                         Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
1618                         GDIPlus.CheckStatus (status);
1619                 }
1620
1621                 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1622                 {
1623                         if (brush == null)
1624                                 throw new ArgumentNullException ("brush");
1625                         
1626                         Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1627                         GDIPlus.CheckStatus (status);
1628                 }
1629
1630                 public void FillRectangles (Brush brush, Rectangle [] rects)
1631                 {
1632                         if (brush == null)
1633                                 throw new ArgumentNullException ("brush");
1634                         if (rects == null)
1635                                 throw new ArgumentNullException ("rects");
1636
1637                         Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
1638                         GDIPlus.CheckStatus (status);
1639                 }
1640
1641                 public void FillRectangles (Brush brush, RectangleF [] rects)
1642                 {
1643                         if (brush == null)
1644                                 throw new ArgumentNullException ("brush");
1645                         if (rects == null)
1646                                 throw new ArgumentNullException ("rects");
1647
1648                         Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
1649                         GDIPlus.CheckStatus (status);
1650                 }
1651
1652                 
1653                 public void FillRegion (Brush brush, Region region)
1654                 {
1655                         if (brush == null)
1656                                 throw new ArgumentNullException ("brush");
1657                         if (region == null)
1658                                 throw new ArgumentNullException ("region");
1659                         
1660                         Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);                  
1661                         GDIPlus.CheckStatus(status);
1662                 }
1663
1664                 
1665                 public void Flush ()
1666                 {
1667                         Flush (FlushIntention.Flush);
1668                 }
1669
1670                 
1671                 public void Flush (FlushIntention intention)
1672                 {
1673                         if (nativeObject == IntPtr.Zero) {
1674                                 return;
1675                         }
1676
1677                         Status status = GDIPlus.GdipFlush (nativeObject, intention);
1678                         GDIPlus.CheckStatus (status);                    
1679                         if (GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable)
1680                                 Carbon.CGContextSynchronize (GDIPlus.Display);
1681                 }
1682
1683                 [EditorBrowsable (EditorBrowsableState.Advanced)]               
1684                 public static Graphics FromHdc (IntPtr hdc)
1685                 {
1686                         IntPtr graphics;
1687                         Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
1688                         GDIPlus.CheckStatus (status);
1689                         return new Graphics (graphics);
1690                 }
1691
1692                 [MonoTODO]
1693                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1694                 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1695                 {
1696                         throw new NotImplementedException ();
1697                 }
1698
1699                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1700                 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1701                 public static Graphics FromHdcInternal (IntPtr hdc)
1702                 {
1703                         GDIPlus.Display = hdc;
1704                         return null;
1705                 }
1706
1707                 [EditorBrowsable (EditorBrowsableState.Advanced)]               
1708                 public static Graphics FromHwnd (IntPtr hwnd)
1709                 {
1710                         IntPtr graphics;
1711
1712                         if (GDIPlus.UseCocoaDrawable) {
1713                                 CarbonContext cgContext = Carbon.GetCGContextForNSView (hwnd);
1714                                 GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
1715                                 
1716                                 GDIPlus.Display = cgContext.ctx;
1717                                 return new Graphics (graphics);
1718                         }
1719                         if (GDIPlus.UseQuartzDrawable) {
1720                                 CarbonContext cgContext = Carbon.GetCGContextForView (hwnd);
1721                                 GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
1722                                 
1723                                 GDIPlus.Display = cgContext.ctx;
1724                                 return new Graphics (graphics);
1725                         }
1726                         if (GDIPlus.UseX11Drawable) {
1727                                 if (GDIPlus.Display == IntPtr.Zero) {
1728                                         GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
1729                                 }
1730
1731                                 return FromXDrawable (hwnd, GDIPlus.Display);
1732
1733                         }
1734
1735                         Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
1736                         GDIPlus.CheckStatus (status);
1737
1738                         return new Graphics (graphics);
1739                 }
1740                 
1741                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1742                 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
1743                 public static Graphics FromHwndInternal (IntPtr hwnd)
1744                 {
1745                         return FromHwnd (hwnd);
1746                 }
1747
1748                 public static Graphics FromImage (Image image)
1749                 {
1750                         IntPtr graphics;
1751
1752                         if (image == null) 
1753                                 throw new ArgumentNullException ("image");
1754
1755                         if ((image.PixelFormat & PixelFormat.Indexed) != 0)
1756                                 throw new Exception (Locale.GetText ("Cannot create Graphics from an indexed bitmap."));
1757
1758                         Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1759                         GDIPlus.CheckStatus (status);
1760                         Graphics result = new Graphics (graphics);
1761                                 
1762                         if (GDIPlus.RunningOnUnix ()) {
1763                                 Rectangle rect  = new Rectangle (0,0, image.Width, image.Height);
1764                                 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
1765                         }
1766                                 
1767                         return result;
1768                 }
1769
1770                 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1771                 {
1772                         IntPtr graphics;
1773
1774                         Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1775                         GDIPlus.CheckStatus (s);
1776                         return new Graphics (graphics);
1777                 }
1778
1779                 [MonoTODO]
1780                 public static IntPtr GetHalftonePalette ()
1781                 {
1782                         throw new NotImplementedException ();
1783                 }
1784
1785 #if !NET_2_0
1786                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1787 #endif
1788                 public IntPtr GetHdc ()
1789                 {
1790                         IntPtr hdc;
1791                         GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out hdc));
1792 #if NET_2_0
1793                         deviceContextHdc = hdc;
1794 #endif
1795                         return hdc;
1796                 }
1797
1798                 
1799                 public Color GetNearestColor (Color color)
1800                 {
1801                         int argb;
1802                         
1803                         Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1804                         GDIPlus.CheckStatus (status);
1805
1806                         return Color.FromArgb (argb);
1807                 }
1808
1809                 
1810                 public void IntersectClip (Region region)
1811                 {
1812                         if (region == null)
1813                                 throw new ArgumentNullException ("region");
1814                         Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1815                         GDIPlus.CheckStatus (status);
1816                 }
1817                 
1818                 public void IntersectClip (RectangleF rect)
1819                 {
1820                         Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1821                         GDIPlus.CheckStatus (status);
1822                 }
1823
1824                 public void IntersectClip (Rectangle rect)
1825                 {                       
1826                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1827                         GDIPlus.CheckStatus (status);
1828                 }
1829
1830                 public bool IsVisible (Point point)
1831                 {
1832                         bool isVisible = false;
1833
1834                         Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1835                         GDIPlus.CheckStatus (status);
1836
1837                         return isVisible;
1838                 }
1839
1840                 
1841                 public bool IsVisible (RectangleF rect)
1842                 {
1843                         bool isVisible = false;
1844
1845                         Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1846                         GDIPlus.CheckStatus (status);
1847
1848                         return isVisible;
1849                 }
1850
1851                 public bool IsVisible (PointF point)
1852                 {
1853                         bool isVisible = false;
1854
1855                         Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1856                         GDIPlus.CheckStatus (status);
1857
1858                         return isVisible;
1859                 }
1860                 
1861                 public bool IsVisible (Rectangle rect)
1862                 {
1863                         bool isVisible = false;
1864
1865                         Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1866                         GDIPlus.CheckStatus (status);
1867
1868                         return isVisible;
1869                 }
1870                 
1871                 public bool IsVisible (float x, float y)
1872                 {
1873                         return IsVisible (new PointF (x, y));
1874                 }
1875                 
1876                 public bool IsVisible (int x, int y)
1877                 {
1878                         return IsVisible (new Point (x, y));
1879                 }
1880                 
1881                 public bool IsVisible (float x, float y, float width, float height)
1882                 {
1883                         return IsVisible (new RectangleF (x, y, width, height));
1884                 }
1885
1886                 
1887                 public bool IsVisible (int x, int y, int width, int height)
1888                 {
1889                         return IsVisible (new Rectangle (x, y, width, height));
1890                 }
1891
1892                 
1893                 public Region[] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1894                 {
1895                         if ((text == null) || (text.Length == 0))
1896                                 return new Region [0];
1897
1898                         if (font == null)
1899                                 throw new ArgumentNullException ("font");
1900
1901                         if (stringFormat == null)
1902                                 throw new ArgumentException ("stringFormat");
1903
1904                         int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
1905                         if (regcount == 0)
1906                                 return new Region[0];
1907
1908                         IntPtr[] native_regions = new IntPtr [regcount];
1909                         Region[] regions = new Region [regcount];
1910                         
1911                         for (int i = 0; i < regcount; i++) {
1912                                 regions[i] = new Region ();
1913                                 native_regions[i] = regions[i].NativeObject;
1914                         }
1915                         
1916                         Status status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
1917                                 font.NativeObject, ref layoutRect, stringFormat.NativeObject, regcount, out native_regions[0]); 
1918                         GDIPlus.CheckStatus (status);                           
1919
1920                         return regions;                                                 
1921                 }
1922
1923                 
1924                 public SizeF MeasureString (string text, Font font)
1925                 {
1926                         return MeasureString (text, font, SizeF.Empty);
1927                 }
1928
1929                 
1930                 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1931                 {
1932                         if (text == null || text.Length == 0)
1933                                 return SizeF.Empty;
1934
1935                         if (font == null)
1936                                 throw new ArgumentNullException ("font");
1937
1938                         int charactersFitted, linesFilled;
1939                         RectangleF boundingBox = new RectangleF ();
1940                         RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1941
1942                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1943                                                                    font.NativeObject, ref rect,
1944                                                                    IntPtr.Zero, out boundingBox,
1945                                                                    out charactersFitted, out linesFilled);
1946                         GDIPlus.CheckStatus (status);
1947
1948                         return new SizeF (boundingBox.Width, boundingBox.Height);
1949                 }
1950
1951                 
1952                 public SizeF MeasureString (string text, Font font, int width)
1953                 {                               
1954                         if (text == null || text.Length == 0)
1955                                 return SizeF.Empty;
1956
1957                         if (font == null)
1958                                 throw new ArgumentNullException ("font");
1959
1960                         RectangleF boundingBox = new RectangleF ();
1961                         RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
1962                         int charactersFitted, linesFilled;
1963
1964                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
1965                                                                    font.NativeObject, ref rect,
1966                                                                    IntPtr.Zero, out boundingBox,
1967                                                                    out charactersFitted, out linesFilled);
1968                         GDIPlus.CheckStatus (status);
1969
1970                         return new SizeF (boundingBox.Width, boundingBox.Height);
1971                 }
1972
1973                 
1974                 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
1975                                             StringFormat stringFormat)
1976                 {
1977                         int charactersFitted, linesFilled;                      
1978                         return MeasureString (text, font, layoutArea, stringFormat,
1979                                               out charactersFitted, out linesFilled);
1980                 }
1981
1982                 
1983                 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1984                 {
1985                         int charactersFitted, linesFilled;                      
1986                         return MeasureString (text, font, new SizeF (width, Int32.MaxValue), 
1987                                               format, out charactersFitted, out linesFilled);
1988                 }
1989
1990                 
1991                 public SizeF MeasureString (string text, Font font, PointF origin,
1992                                             StringFormat stringFormat)
1993                 {
1994                         if (text == null || text.Length == 0)
1995                                 return SizeF.Empty;
1996
1997                         if (font == null)
1998                                 throw new ArgumentNullException ("font");
1999
2000                         RectangleF boundingBox = new RectangleF ();
2001                         RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
2002                         int charactersFitted, linesFilled;
2003
2004                         IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
2005
2006                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
2007                                                                    font.NativeObject, ref rect, format, 
2008                                                                    out boundingBox,
2009                                                                    out charactersFitted,
2010                                                                    out linesFilled);
2011                         GDIPlus.CheckStatus (status);
2012
2013                         return new SizeF (boundingBox.Width, boundingBox.Height);
2014                 }
2015
2016                 
2017                 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
2018                                             StringFormat stringFormat, out int charactersFitted,
2019                                             out int linesFilled)
2020                 {       
2021                         charactersFitted = 0;
2022                         linesFilled = 0;
2023
2024                         if (text == null || text.Length == 0)
2025                                 return SizeF.Empty;
2026
2027                         if (font == null)
2028                                 throw new ArgumentNullException ("font");
2029
2030                         RectangleF boundingBox = new RectangleF ();
2031                         RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
2032
2033                         IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
2034
2035                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
2036                                                                    font.NativeObject, ref rect, format,
2037                                                                    out boundingBox,
2038                                                                    out charactersFitted,
2039                                                                    out linesFilled);
2040                         GDIPlus.CheckStatus (status);
2041
2042                         return new SizeF (boundingBox.Width, boundingBox.Height);
2043                 }
2044
2045                 public void MultiplyTransform (Matrix matrix)
2046                 {
2047                         MultiplyTransform (matrix, MatrixOrder.Prepend);
2048                 }
2049
2050                 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
2051                 {
2052                         Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject,
2053                                                                             matrix.nativeMatrix,
2054                                                                             order);
2055                         GDIPlus.CheckStatus (status);
2056                 }
2057
2058                 [EditorBrowsable (EditorBrowsableState.Advanced)]
2059                 public void ReleaseHdc (IntPtr hdc)
2060                 {
2061                         Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
2062                         GDIPlus.CheckStatus (status);
2063 #if NET_2_0
2064                         if (hdc == deviceContextHdc)
2065                                 deviceContextHdc = IntPtr.Zero;
2066 #endif
2067                 }
2068
2069 #if NET_2_0
2070                 public void ReleaseHdc ()
2071                 {
2072                         if (deviceContextHdc == IntPtr.Zero)
2073                                 throw new ArgumentException ("Invalid Handle");
2074
2075                         ReleaseHdc (deviceContextHdc);
2076                 }
2077 #endif
2078
2079                 [MonoTODO ("Parameter hdc doesn't map well into libgdiplus")]
2080 #if NET_2_0
2081                 [EditorBrowsable (EditorBrowsableState.Never)]
2082 #else
2083                 [EditorBrowsable (EditorBrowsableState.Advanced)]
2084 #endif
2085                 [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
2086                 public void ReleaseHdcInternal (IntPtr hdc)
2087                 {
2088                         throw new NotImplementedException ();
2089                 }
2090
2091                 
2092                 public void ResetClip ()
2093                 {
2094                         Status status = GDIPlus.GdipResetClip (nativeObject);
2095                         GDIPlus.CheckStatus (status);
2096                 }
2097
2098                 public void ResetTransform ()
2099                 {
2100                         Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
2101                         GDIPlus.CheckStatus (status);
2102                 }
2103
2104                 public void Restore (GraphicsState gstate)
2105                 {                       
2106                         Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
2107                         GDIPlus.CheckStatus (status);
2108                 }
2109
2110
2111                 public void RotateTransform (float angle)
2112                 {
2113                         RotateTransform (angle, MatrixOrder.Prepend);
2114                 }
2115
2116                 public void RotateTransform (float angle, MatrixOrder order)
2117                 {
2118
2119                         Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
2120                         GDIPlus.CheckStatus (status);
2121                 }
2122
2123                 public GraphicsState Save ()
2124                 {                                               
2125                         uint saveState;
2126                         Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
2127                         GDIPlus.CheckStatus (status);
2128
2129                         GraphicsState state = new GraphicsState ();
2130                         state.nativeState = saveState;
2131                         return state;
2132                 }
2133
2134                 public void ScaleTransform (float sx, float sy)
2135                 {
2136                         ScaleTransform (sx, sy, MatrixOrder.Prepend);
2137                 }
2138
2139                 public void ScaleTransform (float sx, float sy, MatrixOrder order)
2140                 {
2141                         Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
2142                         GDIPlus.CheckStatus (status);
2143                 }
2144
2145                 
2146                 public void SetClip (RectangleF rect)
2147                 {
2148                         SetClip (rect, CombineMode.Replace);
2149                 }
2150
2151                 
2152                 public void SetClip (GraphicsPath path)
2153                 {
2154                         SetClip (path, CombineMode.Replace);
2155                 }
2156
2157                 
2158                 public void SetClip (Rectangle rect)
2159                 {
2160                         SetClip (rect, CombineMode.Replace);
2161                 }
2162
2163                 
2164                 public void SetClip (Graphics g)
2165                 {
2166                         SetClip (g, CombineMode.Replace);
2167                 }
2168
2169                 
2170                 public void SetClip (Graphics g, CombineMode combineMode)
2171                 {
2172                         if (g == null)
2173                                 throw new ArgumentNullException ("g");
2174                         
2175                         Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
2176                         GDIPlus.CheckStatus (status);
2177                 }
2178
2179                 
2180                 public void SetClip (Rectangle rect, CombineMode combineMode)
2181                 {
2182                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2183                         GDIPlus.CheckStatus (status);
2184                 }
2185
2186                 
2187                 public void SetClip (RectangleF rect, CombineMode combineMode)
2188                 {
2189                         Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
2190                         GDIPlus.CheckStatus (status);
2191                 }
2192
2193                 
2194                 public void SetClip (Region region, CombineMode combineMode)
2195                 {
2196                         if (region == null)
2197                                 throw new ArgumentNullException ("region");
2198                         Status status =   GDIPlus.GdipSetClipRegion(nativeObject,  region.NativeObject, combineMode); 
2199                         GDIPlus.CheckStatus (status);
2200                 }
2201
2202                 
2203                 public void SetClip (GraphicsPath path, CombineMode combineMode)
2204                 {
2205                         if (path == null)
2206                                 throw new ArgumentNullException ("path");
2207                         Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
2208                         GDIPlus.CheckStatus (status);
2209                 }
2210
2211                 
2212                 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
2213                 {
2214                         if (pts == null)
2215                                 throw new ArgumentNullException ("pts");
2216
2217                         IntPtr ptrPt =  GDIPlus.FromPointToUnManagedMemory (pts);
2218             
2219                         Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace,  ptrPt, pts.Length);
2220                         GDIPlus.CheckStatus (status);
2221                         
2222                         GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
2223                 }
2224
2225
2226                 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
2227                 {                                               
2228                         if (pts == null)
2229                                 throw new ArgumentNullException ("pts");
2230                         IntPtr ptrPt =  GDIPlus.FromPointToUnManagedMemoryI (pts);
2231             
2232                         Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
2233                         GDIPlus.CheckStatus (status);
2234                         
2235                         GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
2236                 }
2237
2238                 
2239                 public void TranslateClip (int dx, int dy)
2240                 {
2241                         Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
2242                         GDIPlus.CheckStatus (status);
2243                 }
2244
2245                 
2246                 public void TranslateClip (float dx, float dy)
2247                 {
2248                         Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
2249                         GDIPlus.CheckStatus (status);
2250                 }
2251
2252                 public void TranslateTransform (float dx, float dy)
2253                 {
2254                         TranslateTransform (dx, dy, MatrixOrder.Prepend);
2255                 }
2256
2257                 
2258                 public void TranslateTransform (float dx, float dy, MatrixOrder order)
2259                 {                       
2260                         Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
2261                         GDIPlus.CheckStatus (status);
2262                 }
2263
2264                 public Region Clip {
2265                         get {
2266                                 Region reg = new Region();
2267                                 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
2268                                 GDIPlus.CheckStatus (status);
2269                                 return reg;                             
2270                         }
2271                         set {
2272                                 SetClip (value, CombineMode.Replace);
2273                         }
2274                 }
2275
2276                 public RectangleF ClipBounds {
2277                         get {
2278                                 RectangleF rect = new RectangleF ();
2279                                 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
2280                                 GDIPlus.CheckStatus (status);
2281                                 return rect;
2282                         }
2283                 }
2284
2285                 public CompositingMode CompositingMode {
2286                         get {
2287                                 CompositingMode mode;
2288                                 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
2289                                 GDIPlus.CheckStatus (status);
2290
2291                                 return mode;
2292                         }
2293                         set {
2294                                 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
2295                                 GDIPlus.CheckStatus (status);
2296                         }
2297
2298                 }
2299
2300                 public CompositingQuality CompositingQuality {
2301                         get {
2302                                 CompositingQuality quality;
2303
2304                                 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
2305                                 GDIPlus.CheckStatus (status);
2306                                 return quality;
2307                         }
2308                         set {
2309                                 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
2310                                 GDIPlus.CheckStatus (status);
2311                         }
2312                 }
2313
2314                 public float DpiX {
2315                         get {
2316                                 float x;
2317
2318                                 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
2319                                 GDIPlus.CheckStatus (status);
2320                                 return x;
2321                         }
2322                 }
2323
2324                 public float DpiY {
2325                         get {
2326                                 float y;
2327
2328                                 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
2329                                 GDIPlus.CheckStatus (status);
2330                                 return y;
2331                         }
2332                 }
2333
2334                 public InterpolationMode InterpolationMode {
2335                         get {                           
2336                                 InterpolationMode imode = InterpolationMode.Invalid;
2337                                 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
2338                                 GDIPlus.CheckStatus (status);
2339                                 return imode;
2340                         }
2341                         set {
2342                                 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
2343                                 GDIPlus.CheckStatus (status);
2344                         }
2345                 }
2346
2347                 public bool IsClipEmpty {
2348                         get {
2349                                 bool isEmpty = false;
2350
2351                                 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
2352                                 GDIPlus.CheckStatus (status);
2353                                 return isEmpty;
2354                         }
2355                 }
2356
2357                 public bool IsVisibleClipEmpty {
2358                         get {
2359                                 bool isEmpty = false;
2360
2361                                 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
2362                                 GDIPlus.CheckStatus (status);
2363                                 return isEmpty;
2364                         }
2365                 }
2366
2367                 public float PageScale {
2368                         get {
2369                                 float scale;
2370
2371                                 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
2372                                 GDIPlus.CheckStatus (status);
2373                                 return scale;
2374                         }
2375                         set {
2376                                 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
2377                                 GDIPlus.CheckStatus (status);
2378                         }
2379                 }
2380
2381                 public GraphicsUnit PageUnit {
2382                         get {
2383                                 GraphicsUnit unit;
2384                                 
2385                                 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
2386                                 GDIPlus.CheckStatus (status);
2387                                 return unit;
2388                         }
2389                         set {
2390                                 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
2391                                 GDIPlus.CheckStatus (status);
2392                         }
2393                 }
2394
2395                 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2396                 public PixelOffsetMode PixelOffsetMode {
2397                         get {
2398                                 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
2399                                 
2400                                 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
2401                                 GDIPlus.CheckStatus (status);
2402                                 return pixelOffset;
2403                         }
2404                         set {
2405                                 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value); 
2406                                 GDIPlus.CheckStatus (status);
2407                         }
2408                 }
2409
2410                 public Point RenderingOrigin {
2411                         get {
2412                                 int x, y;
2413                                 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
2414                                 GDIPlus.CheckStatus (status);
2415                                 return new Point (x, y);
2416                         }
2417
2418                         set {
2419                                 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
2420                                 GDIPlus.CheckStatus (status);
2421                         }
2422                 }
2423
2424                 public SmoothingMode SmoothingMode {
2425                         get {
2426                                 SmoothingMode mode = SmoothingMode.Invalid;
2427
2428                                 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
2429                                 GDIPlus.CheckStatus (status);
2430                                 return mode;
2431                         }
2432
2433                         set {
2434                                 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
2435                                 GDIPlus.CheckStatus (status);
2436                         }
2437                 }
2438
2439                 [MonoTODO ("This property does not do anything when used with libgdiplus.")]
2440                 public int TextContrast {
2441                         get {   
2442                                 int contrast;
2443                                         
2444                                 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
2445                                 GDIPlus.CheckStatus (status);
2446                                 return contrast;
2447                         }
2448
2449                         set {
2450                                 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
2451                                 GDIPlus.CheckStatus (status);
2452                         }
2453                 }
2454
2455                 public TextRenderingHint TextRenderingHint {
2456                         get {
2457                                 TextRenderingHint hint;
2458
2459                                 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
2460                                 GDIPlus.CheckStatus (status);
2461                                 return hint;        
2462                         }
2463
2464                         set {
2465                                 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
2466                                 GDIPlus.CheckStatus (status);
2467                         }
2468                 }
2469
2470                 public Matrix Transform {
2471                         get {
2472                                 Matrix matrix = new Matrix ();
2473                                 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
2474                                 GDIPlus.CheckStatus (status);
2475                                 return matrix;
2476                         }
2477                         set {
2478                                 if (value == null)
2479                                         throw new ArgumentNullException ("value");
2480                                 
2481                                 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
2482                                 GDIPlus.CheckStatus (status);
2483                         }
2484                 }
2485
2486                 public RectangleF VisibleClipBounds {
2487                         get {
2488                                 RectangleF rect;
2489                                         
2490                                 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
2491                                 GDIPlus.CheckStatus (status);
2492                                 return rect;
2493                         }
2494                 }
2495
2496 #if NET_2_0
2497                 [MonoTODO]
2498                 [EditorBrowsable (EditorBrowsableState.Never)]
2499                 public object GetContextInfo ()
2500                 {
2501                         throw new NotImplementedException ();
2502                 }
2503 #endif
2504         }
2505 }