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