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