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