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