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