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