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