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