error messages review
[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                         Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1287                         GDIPlus.CheckStatus (status);
1288                         Graphics result = new Graphics (graphics);
1289                                 
1290                         // check for Unix platforms - see FAQ for more details
1291                         // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1292                         int platform = (int) Environment.OSVersion.Platform;
1293                         if ((platform == 4) || (platform == 128)) {
1294                                 Rectangle rect  = new Rectangle (0,0, image.Width, image.Height);
1295                                 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
1296                         }
1297                                 
1298                         return result;
1299                 }
1300
1301                 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1302                 {
1303                         IntPtr graphics;
1304
1305                         Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1306                         GDIPlus.CheckStatus (s);
1307                         return new Graphics (graphics);
1308                 }
1309
1310                 [MonoTODO]
1311                 public static IntPtr GetHalftonePalette ()
1312                 {
1313                         throw new NotImplementedException ();
1314                 }
1315
1316                 [MonoTODO]
1317                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1318                 public IntPtr GetHdc ()
1319                 {
1320                         return nativeObject;
1321                 }
1322
1323                 
1324                 public Color GetNearestColor (Color color)
1325                 {
1326                         int argb;
1327                         
1328                         Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1329                         GDIPlus.CheckStatus (status);
1330
1331                         return Color.FromArgb (argb);
1332                 }
1333
1334                 
1335                 public void IntersectClip (Region region)
1336                 {
1337                         Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1338                         GDIPlus.CheckStatus (status);
1339                 }
1340                 
1341                 public void IntersectClip (RectangleF rect)
1342                 {
1343                         Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1344                         GDIPlus.CheckStatus (status);
1345                 }
1346
1347                 public void IntersectClip (Rectangle rect)
1348                 {                       
1349                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1350                         GDIPlus.CheckStatus (status);
1351                 }
1352
1353                 public bool IsVisible (Point point)
1354                 {
1355                         bool isVisible = false;
1356
1357                         Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1358                         GDIPlus.CheckStatus (status);
1359
1360                         return isVisible;
1361                 }
1362
1363                 
1364                 public bool IsVisible (RectangleF rect)
1365                 {
1366                         bool isVisible = false;
1367
1368                         Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1369                         GDIPlus.CheckStatus (status);
1370
1371                         return isVisible;
1372                 }
1373
1374                 public bool IsVisible (PointF point)
1375                 {
1376                         bool isVisible = false;
1377
1378                         Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1379                         GDIPlus.CheckStatus (status);
1380
1381                         return isVisible;
1382                 }
1383                 
1384                 public bool IsVisible (Rectangle rect)
1385                 {
1386                         bool isVisible = false;
1387
1388                         Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1389                         GDIPlus.CheckStatus (status);
1390
1391                         return isVisible;
1392                 }
1393                 
1394                 public bool IsVisible (float x, float y)
1395                 {
1396                         return IsVisible (new PointF (x, y));
1397                 }
1398                 
1399                 public bool IsVisible (int x, int y)
1400                 {
1401                         return IsVisible (new Point (x, y));
1402                 }
1403                 
1404                 public bool IsVisible (float x, float y, float width, float height)
1405                 {
1406                         return IsVisible (new RectangleF (x, y, width, height));
1407                 }
1408
1409                 
1410                 public bool IsVisible (int x, int y, int width, int height)
1411                 {
1412                         return IsVisible (new Rectangle (x, y, width, height));
1413                 }
1414
1415                 
1416                 public Region [] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1417                 {       
1418                         Status status;                  
1419                         int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
1420                         IntPtr[] native_regions = new IntPtr [regcount];
1421                         Region[] regions = new Region [regcount];
1422                         
1423                         for (int i = 0; i < regcount; i++) {
1424                                 regions[i] = new Region ();
1425                                 native_regions[i] = regions[i].NativeObject;
1426                         }
1427                         
1428                         status =  GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
1429                                 font.NativeObject, ref layoutRect, stringFormat.NativeObject, 
1430                                 regcount, out native_regions[0]); 
1431                         
1432                         GDIPlus.CheckStatus (status);                           
1433                                                         
1434                         return regions;                                                 
1435                 }
1436
1437                 
1438                 public SizeF MeasureString (string text, Font font)
1439                 {
1440                         return MeasureString (text, font, new Size (0, 0));
1441                 }
1442
1443                 
1444                 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1445                 {
1446                         int charactersFitted, linesFilled;
1447                         RectangleF boundingBox = new RectangleF ();
1448                         RectangleF rect = new RectangleF (0, 0, layoutArea.Width,
1449                                                           layoutArea.Height);
1450
1451                         if (text == null || text.Length == 0)
1452                                 return SizeF.Empty;
1453
1454                         if (font == null)
1455                                 throw new ArgumentNullException ("font");
1456
1457                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1458                                                                    font.NativeObject, ref rect,
1459                                                                    IntPtr.Zero, out boundingBox,
1460                                                                    out charactersFitted, out linesFilled);
1461                         GDIPlus.CheckStatus (status);
1462
1463                         return new SizeF (boundingBox.Width, boundingBox.Height);
1464                 }
1465
1466                 
1467                 public SizeF MeasureString (string text, Font font, int width)
1468                 {                               
1469                         RectangleF boundingBox = new RectangleF ();
1470                         RectangleF rect = new RectangleF (0, 0, width, 999999);
1471                         int charactersFitted, linesFilled;
1472
1473                         if (text == null || text.Length == 0)
1474                                 return SizeF.Empty;
1475
1476                         if (font == null)
1477                                 throw new ArgumentNullException ("font");
1478
1479                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
1480                                                                    font.NativeObject, ref rect,
1481                                                                    IntPtr.Zero, out boundingBox,
1482                                                                    out charactersFitted, out linesFilled);
1483                         GDIPlus.CheckStatus (status);
1484
1485                         return new SizeF (boundingBox.Width, boundingBox.Height);
1486                 }
1487
1488                 
1489                 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
1490                                             StringFormat stringFormat)
1491                 {
1492                         int charactersFitted, linesFilled;                      
1493                         return MeasureString (text, font, layoutArea, stringFormat,
1494                                               out charactersFitted, out linesFilled);
1495                 }
1496
1497                 
1498                 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1499                 {
1500                         int charactersFitted, linesFilled;                      
1501                         return MeasureString (text, font, new SizeF (width, 999999), 
1502                                               format, out charactersFitted, out linesFilled);
1503                 }
1504
1505                 
1506                 public SizeF MeasureString (string text, Font font, PointF origin,
1507                                             StringFormat stringFormat)
1508                 {
1509                         RectangleF boundingBox = new RectangleF ();
1510                         RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
1511                         int charactersFitted, linesFilled;
1512
1513                         if (text == null || text.Length == 0)
1514                                 return SizeF.Empty;
1515
1516                         if (font == null)
1517                                 throw new ArgumentNullException ("font");
1518
1519                         if (stringFormat == null)
1520                                 stringFormat = new StringFormat ();
1521
1522                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
1523                                                                    font.NativeObject, ref rect,
1524                                                                    stringFormat.NativeObject, 
1525                                                                    out boundingBox,
1526                                                                    out charactersFitted,
1527                                                                    out linesFilled);
1528                         GDIPlus.CheckStatus (status);
1529
1530                         return new SizeF (boundingBox.Width, boundingBox.Height);
1531                 }
1532
1533                 
1534                 public SizeF MeasureString (string text, Font font, SizeF layoutArea,
1535                                             StringFormat stringFormat, out int charactersFitted,
1536                                             out int linesFilled)
1537                 {       
1538                         RectangleF boundingBox = new RectangleF ();
1539                         RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
1540                         charactersFitted = 0;
1541                         linesFilled = 0;
1542
1543                         if (text == null || text.Length == 0)
1544                                 return SizeF.Empty;
1545
1546                         if (font == null)
1547                                 throw new ArgumentNullException ("font");
1548
1549                         if (stringFormat == null)
1550                                 stringFormat = new StringFormat ();
1551
1552                         Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
1553                                                                    font.NativeObject, ref rect,
1554                                                                    stringFormat.NativeObject,
1555                                                                    out boundingBox,
1556                                                                    out charactersFitted,
1557                                                                    out linesFilled);
1558                         GDIPlus.CheckStatus (status);
1559
1560                         return new SizeF (boundingBox.Width, boundingBox.Height);
1561                 }
1562
1563                 public void MultiplyTransform (Matrix matrix)
1564                 {
1565                         MultiplyTransform (matrix, MatrixOrder.Prepend);
1566                 }
1567
1568                 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
1569                 {
1570                         Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject,
1571                                                                             matrix.nativeMatrix,
1572                                                                             order);
1573                         GDIPlus.CheckStatus (status);
1574                 }
1575
1576                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1577                 public void ReleaseHdc (IntPtr hdc)
1578                 {
1579                         Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
1580                         GDIPlus.CheckStatus (status);
1581                 }
1582
1583                 [MonoTODO]
1584                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1585                 public void ReleaseHdcInternal (IntPtr hdc)
1586                 {
1587                         throw new NotImplementedException ();
1588                 }
1589
1590                 
1591                 public void ResetClip ()
1592                 {
1593                         Status status = GDIPlus.GdipResetClip (nativeObject);
1594                         GDIPlus.CheckStatus (status);
1595                 }
1596
1597                 public void ResetTransform ()
1598                 {
1599                         Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
1600                         GDIPlus.CheckStatus (status);
1601                 }
1602
1603                 public void Restore (GraphicsState gstate)
1604                 {                       
1605                         Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
1606                         GDIPlus.CheckStatus (status);
1607                 }
1608
1609
1610                 public void RotateTransform (float angle)
1611                 {
1612                         RotateTransform (angle, MatrixOrder.Prepend);
1613                 }
1614
1615                 public void RotateTransform (float angle, MatrixOrder order)
1616                 {
1617
1618                         Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
1619                         GDIPlus.CheckStatus (status);
1620                 }
1621
1622                 public GraphicsState Save ()
1623                 {                                               
1624                         uint saveState;
1625                         Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
1626                         GDIPlus.CheckStatus (status);
1627
1628                         GraphicsState state = new GraphicsState ();
1629                         state.nativeState = saveState;
1630                         return state;
1631                 }
1632
1633                 public void ScaleTransform (float sx, float sy)
1634                 {
1635                         ScaleTransform (sx, sy, MatrixOrder.Prepend);
1636                 }
1637
1638                 public void ScaleTransform (float sx, float sy, MatrixOrder order)
1639                 {
1640                         Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
1641                         GDIPlus.CheckStatus (status);
1642                 }
1643
1644                 
1645                 public void SetClip (RectangleF rect)
1646                 {
1647                         SetClip (rect, CombineMode.Replace);
1648                 }
1649
1650                 
1651                 public void SetClip (GraphicsPath path)
1652                 {
1653                         SetClip (path, CombineMode.Replace);
1654                 }
1655
1656                 
1657                 public void SetClip (Rectangle rect)
1658                 {
1659                         SetClip (rect, CombineMode.Replace);
1660                 }
1661
1662                 
1663                 public void SetClip (Graphics g)
1664                 {
1665                         SetClip (g, CombineMode.Replace);
1666                 }
1667
1668                 
1669                 public void SetClip (Graphics g, CombineMode combineMode)
1670                 {
1671                         Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
1672                         GDIPlus.CheckStatus (status);
1673                 }
1674
1675                 
1676                 public void SetClip (Rectangle rect, CombineMode combineMode)
1677                 {
1678                         Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1679                         GDIPlus.CheckStatus (status);
1680                 }
1681
1682                 
1683                 public void SetClip (RectangleF rect, CombineMode combineMode)
1684                 {
1685                         Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1686                         GDIPlus.CheckStatus (status);
1687                 }
1688
1689                 
1690                 public void SetClip (Region region, CombineMode combineMode)
1691                 {
1692                         Status status =   GDIPlus.GdipSetClipRegion(nativeObject,  region.NativeObject, combineMode); 
1693                         GDIPlus.CheckStatus (status);
1694                 }
1695
1696                 
1697                 public void SetClip (GraphicsPath path, CombineMode combineMode)
1698                 {
1699                         Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
1700                         GDIPlus.CheckStatus (status);
1701                 }
1702
1703                 
1704                 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
1705                 {
1706                         IntPtr ptrPt =  GDIPlus.FromPointToUnManagedMemory (pts);
1707             
1708                         Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace,  ptrPt, pts.Length);
1709                         GDIPlus.CheckStatus (status);
1710                         
1711                         GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
1712                 }
1713
1714
1715                 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
1716                 {                                               
1717                         IntPtr ptrPt =  GDIPlus.FromPointToUnManagedMemoryI (pts);
1718             
1719                         Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
1720                         GDIPlus.CheckStatus (status);
1721                         
1722                         GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
1723                 }
1724
1725                 
1726                 public void TranslateClip (int dx, int dy)
1727                 {
1728                         Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
1729                         GDIPlus.CheckStatus (status);
1730                 }
1731
1732                 
1733                 public void TranslateClip (float dx, float dy)
1734                 {
1735                         Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
1736                         GDIPlus.CheckStatus (status);
1737                 }
1738
1739                 public void TranslateTransform (float dx, float dy)
1740                 {
1741                         TranslateTransform (dx, dy, MatrixOrder.Prepend);
1742                 }
1743
1744                 
1745                 public void TranslateTransform (float dx, float dy, MatrixOrder order)
1746                 {                       
1747                         Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
1748                         GDIPlus.CheckStatus (status);
1749                 }
1750
1751                 public Region Clip {
1752                         get {
1753                                 Region reg = new Region();
1754                                 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
1755                                 GDIPlus.CheckStatus (status);
1756                                 return reg;                             
1757                         }
1758                         set {
1759                                 SetClip (value, CombineMode.Replace);
1760                         }
1761                 }
1762
1763                 public RectangleF ClipBounds {
1764                         get {
1765                                 RectangleF rect = new RectangleF ();
1766                                 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
1767                                 GDIPlus.CheckStatus (status);
1768                                 return rect;
1769                         }
1770                 }
1771
1772                 public CompositingMode CompositingMode {
1773                         get {
1774                                 CompositingMode mode;
1775                                 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
1776                                 GDIPlus.CheckStatus (status);
1777
1778                                 return mode;
1779                         }
1780                         set {
1781                                 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
1782                                 GDIPlus.CheckStatus (status);
1783                         }
1784
1785                 }
1786
1787                 public CompositingQuality CompositingQuality {
1788                         get {
1789                                 CompositingQuality quality;
1790
1791                                 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
1792                                 GDIPlus.CheckStatus (status);
1793                                 return quality;
1794                         }
1795                         set {
1796                                 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
1797                                 GDIPlus.CheckStatus (status);
1798                         }
1799                 }
1800
1801                 public float DpiX {
1802                         get {
1803                                 float x;
1804
1805                                 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
1806                                 GDIPlus.CheckStatus (status);
1807                                 return x;
1808                         }
1809                 }
1810
1811                 public float DpiY {
1812                         get {
1813                                 float y;
1814
1815                                 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
1816                                 GDIPlus.CheckStatus (status);
1817                                 return y;
1818                         }
1819                 }
1820
1821                 public InterpolationMode InterpolationMode {
1822                         get {                           
1823                                 InterpolationMode imode = InterpolationMode.Invalid;
1824                                 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
1825                                 GDIPlus.CheckStatus (status);
1826                                 return imode;
1827                         }
1828                         set {
1829                                 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
1830                                 GDIPlus.CheckStatus (status);
1831                         }
1832                 }
1833
1834                 public bool IsClipEmpty {
1835                         get {
1836                                 bool isEmpty = false;
1837
1838                                 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
1839                                 GDIPlus.CheckStatus (status);
1840                                 return isEmpty;
1841                         }
1842                 }
1843
1844                 public bool IsVisibleClipEmpty {
1845                         get {
1846                                 bool isEmpty = false;
1847
1848                                 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
1849                                 GDIPlus.CheckStatus (status);
1850                                 return isEmpty;
1851                         }
1852                 }
1853
1854                 public float PageScale {
1855                         get {
1856                                 float scale;
1857
1858                                 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
1859                                 GDIPlus.CheckStatus (status);
1860                                 return scale;
1861                         }
1862                         set {
1863                                 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
1864                                 GDIPlus.CheckStatus (status);
1865                         }
1866                 }
1867
1868                 public GraphicsUnit PageUnit {
1869                         get {
1870                                 GraphicsUnit unit;
1871                                 
1872                                 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
1873                                 GDIPlus.CheckStatus (status);
1874                                 return unit;
1875                         }
1876                         set {
1877                                 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
1878                                 GDIPlus.CheckStatus (status);
1879                         }
1880                 }
1881
1882                 public PixelOffsetMode PixelOffsetMode {
1883                         get {
1884                                 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
1885                                 
1886                                 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
1887                                 GDIPlus.CheckStatus (status);
1888                                 return pixelOffset;
1889                         }
1890                         set {
1891                                 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value); 
1892                                 GDIPlus.CheckStatus (status);
1893                         }
1894                 }
1895
1896                 public Point RenderingOrigin {
1897                         get {
1898                                 int x, y;
1899                                 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
1900                                 GDIPlus.CheckStatus (status);
1901                                 return new Point (x, y);
1902                         }
1903
1904                         set {
1905                                 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
1906                                 GDIPlus.CheckStatus (status);
1907                         }
1908                 }
1909
1910                 public SmoothingMode SmoothingMode {
1911                         get {
1912                                 SmoothingMode mode = SmoothingMode.Invalid;
1913
1914                                 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
1915                                 GDIPlus.CheckStatus (status);
1916                                 return mode;
1917                         }
1918
1919                         set {
1920                                 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
1921                                 GDIPlus.CheckStatus (status);
1922                         }
1923                 }
1924
1925                 public int TextContrast {
1926                         get {   
1927                                 int contrast;
1928                                         
1929                                 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
1930                                 GDIPlus.CheckStatus (status);
1931                                 return contrast;
1932                         }
1933
1934                         set {
1935                                 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
1936                                 GDIPlus.CheckStatus (status);
1937                         }
1938                 }
1939
1940                 public TextRenderingHint TextRenderingHint {
1941                         get {
1942                                 TextRenderingHint hint;
1943
1944                                 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
1945                                 GDIPlus.CheckStatus (status);
1946                                 return hint;        
1947                         }
1948
1949                         set {
1950                                 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
1951                                 GDIPlus.CheckStatus (status);
1952                         }
1953                 }
1954
1955                 public Matrix Transform {
1956                         get {
1957                                 Matrix matrix = new Matrix ();
1958                                 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
1959                                 GDIPlus.CheckStatus (status);
1960                                 return matrix;
1961                         }
1962                         set {
1963                                 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
1964                                 GDIPlus.CheckStatus (status);
1965                         }
1966                 }
1967
1968                 public RectangleF VisibleClipBounds {
1969                         get {
1970                                 RectangleF rect;
1971                                         
1972                                 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
1973                                 GDIPlus.CheckStatus (status);
1974                                 return rect;
1975                         }
1976                 }
1977         }
1978 }
1979