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