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