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