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