2 // System.Drawing.Graphics.cs
4 // (C) 2003 Ximian, Inc. http://www.ximian.com
7 // Gonzalo Paniagua Javier (gonzalo@ximian.com) (stubbed out)
8 // Alexandre Pigolkine(pigolkine@gmx.de)
9 // Jordi Mas i Hernandez (jordi@ximian.com)
12 using System.Drawing.Drawing2D;
13 using System.Drawing.Imaging;
14 using System.Drawing.Text;
15 using System.Runtime.InteropServices;
18 namespace System.Drawing
21 public sealed class Graphics : MarshalByRefObject, IDisposable
23 internal IntPtr nativeObject = IntPtr.Zero;
24 internal static float defDpiX = 0;
25 internal static float defDpiY = 0;
27 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
31 PlayRecordCallback callbackData);
33 public delegate bool DrawImageAbort (IntPtr callbackData);
35 private Graphics (IntPtr nativeGraphics)
37 nativeObject = nativeGraphics;
40 static internal float systemDpiX {
43 Bitmap bmp = new Bitmap(1,1);
44 Graphics g = Graphics.FromImage(bmp);
51 public float systemDpiY {
54 Bitmap bmp = new Bitmap(1,1);
55 Graphics g = Graphics.FromImage(bmp);
62 internal IntPtr NativeObject {
73 public void AddMetafileComment (byte [] data)
75 throw new NotImplementedException ();
79 public GraphicsContainer BeginContainer ()
83 GDIPlus.GdipBeginContainer2 (nativeObject, out state);
85 return new GraphicsContainer(state);
88 public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
92 GDIPlus.GdipBeginContainerI (nativeObject, dstrect, srcrect, unit, out state);
94 return new GraphicsContainer (state);
98 public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
102 GDIPlus.GdipBeginContainer (nativeObject, dstrect, srcrect, unit, out state);
104 return new GraphicsContainer (state);
108 public void Clear (Color color)
110 GDIPlus.GdipGraphicsClear(nativeObject, color.ToArgb());
114 public void Dispose ()
119 public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
121 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
125 public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
127 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
131 public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
133 GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
134 x, y, width, height, startAngle, sweepAngle);
137 public void DrawArc (Pen pen, int x, int y, int width, int height, float startAngle, float sweepAngle)
139 GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
140 x, y, width, height, startAngle, sweepAngle);
144 public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
146 GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
147 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
151 public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
153 GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
154 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
158 public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
160 GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1, y1, x2, y2, x3, y3, x4, y4);
164 public void DrawBeziers (Pen pen, Point [] points)
166 int length = points.Length;
171 for (int i = 0; i < length; i += 3) {
172 Point p1 = points [i];
173 Point p2 = points [i + 1];
174 Point p3 = points [i + 2];
175 Point p4 = points [i + 3];
177 GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
178 p1.X, p1.Y, p2.X, p2.Y,
179 p3.X, p3.Y, p4.X, p4.Y);
184 public void DrawBeziers (Pen pen, PointF [] points)
186 int length = points.Length;
191 for (int i = 0; i < length; i += 3) {
192 PointF p1 = points [i];
193 PointF p2 = points [i + 1];
194 PointF p3 = points [i + 2];
195 PointF p4 = points [i + 3];
197 GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
198 p1.X, p1.Y, p2.X, p2.Y,
199 p3.X, p3.Y, p4.X, p4.Y);
204 public void DrawClosedCurve (Pen pen, PointF [] points)
206 GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
209 public void DrawClosedCurve (Pen pen, Point [] points)
211 GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
214 public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
216 GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
219 public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
221 GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
224 public void DrawCurve (Pen pen, Point [] points)
226 GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
229 public void DrawCurve (Pen pen, PointF [] points)
231 GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
235 public void DrawCurve (Pen pen, PointF [] points, float tension)
237 GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
241 public void DrawCurve (Pen pen, Point [] points, float tension)
243 GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
248 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
253 public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
255 GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject, points, points.Length,
256 offset, numberOfSegments, tension);
260 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
262 GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject, points, points.Length,
263 offset, numberOfSegments, tension);
266 public void DrawEllipse (Pen pen, Rectangle rect)
268 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
271 public void DrawEllipse (Pen pen, RectangleF rect)
273 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
276 public void DrawEllipse (Pen pen, int x, int y, int width, int height)
278 GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
281 public void DrawEllipse (Pen pen, float x, float y, float width, float height)
283 GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
287 public void DrawIcon (Icon icon, Rectangle targetRect)
289 throw new NotImplementedException ();
293 public void DrawIcon (Icon icon, int x, int y)
295 throw new NotImplementedException ();
299 public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
301 throw new NotImplementedException ();
304 public void DrawImage (Image image, RectangleF rect)
306 GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y,
307 rect.Width, rect.Height);
311 public void DrawImage (Image image, PointF point)
313 GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
317 public void DrawImage (Image image, Point [] destPoints)
319 GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
323 public void DrawImage (Image image, Point point)
325 DrawImage (image, point.X, point.Y);
329 public void DrawImage (Image image, Rectangle rect)
331 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
335 public void DrawImage (Image image, PointF [] destPoints)
337 GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
341 public void DrawImage (Image image, int x, int y)
343 GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
347 public void DrawImage (Image image, float x, float y)
349 GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
353 public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
355 throw new NotImplementedException ();
359 public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
361 throw new NotImplementedException ();
365 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
367 throw new NotImplementedException ();
371 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
373 throw new NotImplementedException ();
377 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
378 ImageAttributes imageAttr)
380 throw new NotImplementedException ();
383 public void DrawImage (Image image, float x, float y, float width, float height)
385 GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
390 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
391 ImageAttributes imageAttr)
393 throw new NotImplementedException ();
397 public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
399 throw new NotImplementedException ();
402 public void DrawImage (Image image, int x, int y, int width, int height)
404 GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
407 public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
409 GDIPlus.GdipDrawImagePointRect(nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
413 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
414 ImageAttributes imageAttr, DrawImageAbort callback)
416 throw new NotImplementedException ();
420 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
421 ImageAttributes imageAttr, DrawImageAbort callback)
423 throw new NotImplementedException ();
427 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
428 ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
430 throw new NotImplementedException ();
434 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight,
435 GraphicsUnit srcUnit)
437 throw new NotImplementedException ();
441 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
442 ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
444 throw new NotImplementedException ();
448 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight,
449 GraphicsUnit srcUnit)
451 throw new NotImplementedException ();
455 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight,
456 GraphicsUnit srcUnit, ImageAttributes imageAttrs)
458 throw new NotImplementedException ();
461 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight,
462 GraphicsUnit srcUnit, ImageAttributes imageAttr)
464 GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
465 destRect.X, destRect.Y, destRect.Width, destRect.Height,
466 srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttr.NativeObject, IntPtr.Zero, 0);
471 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight,
472 GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
474 throw new NotImplementedException ();
478 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight,
479 GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback)
481 throw new NotImplementedException ();
485 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight,
486 GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
488 throw new NotImplementedException ();
492 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight,
493 GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
495 throw new NotImplementedException ();
498 public void DrawImageUnscaled (Image image, Point point)
500 DrawImage(image, point.X, point.Y);
503 public void DrawImageUnscaled (Image image, Rectangle rect)
505 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
508 public void DrawImageUnscaled (Image image, int x, int y)
510 DrawImage(image, x, y);
513 public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
515 DrawImage(image, x, y, width, height);
518 public void DrawLine (Pen pen, PointF pt1, PointF pt2)
520 GDIPlus.GdipDrawLine (
521 nativeObject, pen.nativeObject,
527 public void DrawLine (Pen pen, Point pt1, Point pt2)
529 GDIPlus.GdipDrawLineI (
530 nativeObject, pen.nativeObject,
535 public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
537 GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
540 public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
542 GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
545 public void DrawLines (Pen pen, PointF [] points)
547 GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
550 public void DrawLines (Pen pen, Point [] points)
552 GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
555 public void DrawPath (Pen pen, GraphicsPath path)
557 GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
560 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
562 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
565 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
567 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
570 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
572 GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
575 public void DrawPie (Pen pen, int x, int y, int width, int height, float startAngle, float sweepAngle)
577 GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
580 public void DrawPolygon (Pen pen, Point [] points)
582 GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
585 public void DrawPolygon (Pen pen, PointF [] points)
587 GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
590 public void DrawRectangle (Pen pen, RectangleF rect)
592 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
595 public void DrawRectangle (Pen pen, Rectangle rect)
597 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
600 public void DrawRectangle (Pen pen, float x, float y, float width, float height)
602 GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
605 public void DrawRectangle (Pen pen, int x, int y, int width, int height)
607 GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
610 public void DrawRectangles (Pen pen, RectangleF [] rects)
612 foreach (RectangleF rc in rects)
613 DrawRectangle (pen, rc.Left, rc.Top, rc.Width, rc.Height);
616 public void DrawRectangles (Pen pen, Rectangle [] rects)
618 foreach (RectangleF rc in rects)
619 DrawRectangle(pen, rc.Left, rc.Top, rc.Width, rc.Height);
623 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
625 GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, IntPtr.Zero, brush.nativeObject);
628 public void DrawString (string s, Font font, Brush brush, PointF point)
630 RectangleF rc = new RectangleF (point.X, point.Y, 0, 0);
631 GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref rc, IntPtr.Zero, brush.nativeObject);
634 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
636 RectangleF rc = new RectangleF (point.X, point.Y, 0, 0);
637 GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref rc, format.NativeObject, brush.nativeObject);
640 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
642 GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle,
643 format.NativeObject, brush.nativeObject);
646 public void DrawString (string s, Font font, Brush brush, float x, float y)
648 Console.WriteLine ("DrawString!");
649 RectangleF rc = new RectangleF (x, y, 0, 0);
651 GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject,
652 ref rc, IntPtr.Zero, brush.nativeObject);
656 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
658 //throw new NotImplementedException ();
662 public void EndContainer (GraphicsContainer container)
664 GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
668 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
670 throw new NotImplementedException ();
674 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
676 throw new NotImplementedException ();
680 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
682 throw new NotImplementedException ();
686 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
688 throw new NotImplementedException ();
692 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
694 throw new NotImplementedException ();
698 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
700 throw new NotImplementedException ();
704 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
706 throw new NotImplementedException ();
710 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
712 throw new NotImplementedException ();
716 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
718 throw new NotImplementedException ();
722 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
724 throw new NotImplementedException ();
728 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
730 throw new NotImplementedException ();
734 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
736 throw new NotImplementedException ();
740 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
742 throw new NotImplementedException ();
746 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
748 throw new NotImplementedException ();
752 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
754 throw new NotImplementedException ();
758 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
760 throw new NotImplementedException ();
764 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
766 throw new NotImplementedException ();
770 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
772 throw new NotImplementedException ();
776 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
778 throw new NotImplementedException ();
782 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
784 throw new NotImplementedException ();
788 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
790 throw new NotImplementedException ();
794 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
796 throw new NotImplementedException ();
800 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
802 throw new NotImplementedException ();
806 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
808 throw new NotImplementedException ();
812 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
814 throw new NotImplementedException ();
818 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
820 throw new NotImplementedException ();
824 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
826 throw new NotImplementedException ();
830 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
832 throw new NotImplementedException ();
836 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
838 throw new NotImplementedException ();
842 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
844 throw new NotImplementedException ();
848 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
850 throw new NotImplementedException ();
854 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
856 throw new NotImplementedException ();
860 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
862 throw new NotImplementedException ();
866 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
868 throw new NotImplementedException ();
872 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
874 throw new NotImplementedException ();
878 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
880 throw new NotImplementedException ();
883 public void ExcludeClip (Rectangle rect)
885 GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
889 public void ExcludeClip (Region region)
891 throw new NotImplementedException ();
895 public void FillClosedCurve (Brush brush, PointF [] points)
897 GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
901 public void FillClosedCurve (Brush brush, Point [] points)
903 GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
907 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
909 FillClosedCurve (brush, points, fillmode, 0.5f);
912 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
914 FillClosedCurve (brush, points, fillmode, 0.5f);
917 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
919 GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
922 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
924 GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
927 public void FillEllipse (Brush brush, Rectangle rect)
929 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
932 public void FillEllipse (Brush brush, RectangleF rect)
934 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
937 public void FillEllipse (Brush brush, float x, float y, float width, float height)
939 GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
942 public void FillEllipse (Brush brush, int x, int y, int width, int height)
944 GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
947 public void FillPath (Brush brush, GraphicsPath path)
949 GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
952 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
954 GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height,
955 startAngle, sweepAngle);
958 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
960 GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
963 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
965 GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
968 public void FillPolygon (Brush brush, PointF [] points)
970 GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
973 public void FillPolygon (Brush brush, Point [] points)
975 GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
978 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
980 GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
983 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
985 GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
988 public void FillRectangle (Brush brush, RectangleF rect)
990 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
993 public void FillRectangle (Brush brush, Rectangle rect)
995 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
998 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1000 GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, (float)x, (float)y, (float)width, (float)height);
1003 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1005 GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1008 public void FillRectangles (Brush brush, Rectangle [] rects)
1010 foreach (Rectangle rc in rects)
1011 FillRectangle(brush, rc);
1014 public void FillRectangles (Brush brush, RectangleF [] rects)
1016 foreach (RectangleF rc in rects)
1017 FillRectangle(brush, rc);
1021 public void FillRegion (Brush brush, Region region)
1023 throw new NotImplementedException ();
1027 public void Flush ()
1029 Flush (FlushIntention.Flush);
1033 public void Flush (FlushIntention intention)
1035 throw new NotImplementedException ();
1039 public static Graphics FromHdc (IntPtr hdc)
1042 GDIPlus.GdipCreateFromHDC (hdc, out graphics);
1043 Graphics result = new Graphics ((IntPtr) graphics);
1048 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1050 throw new NotImplementedException ();
1054 public static Graphics FromHdcInternal (IntPtr hdc)
1056 throw new NotImplementedException ();
1059 public static Graphics FromHwnd (IntPtr hwnd)
1063 GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
1065 return new Graphics (graphics);
1069 public static Graphics FromHwndInternal (IntPtr hwnd)
1071 throw new NotImplementedException ();
1075 public static Graphics FromImage (Image image)
1077 if (image == null) throw new ArgumentException ();
1079 GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1080 Graphics result = new Graphics ((IntPtr) graphics);
1085 public static IntPtr GetHalftonePalette ()
1087 throw new NotImplementedException ();
1091 public IntPtr GetHdc ()
1094 GDIPlus.GdipGetDC (nativeObject, out hdc);
1095 return (IntPtr) hdc;
1099 public Color GetNearestColor (Color color)
1103 GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1104 return Color.FromArgb (argb);
1108 public void IntersectClip (Region region)
1110 throw new NotImplementedException ();
1113 public void IntersectClip (RectangleF rect)
1115 GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1118 public void IntersectClip (Rectangle rect)
1120 GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1123 public bool IsVisible (Point point)
1125 bool isVisible = false;
1127 GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1133 public bool IsVisible (RectangleF rect)
1135 bool isVisible = false;
1137 GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1142 public bool IsVisible (PointF point)
1144 bool isVisible = false;
1146 GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1151 public bool IsVisible (Rectangle rect)
1153 bool isVisible = false;
1155 GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1160 public bool IsVisible (float x, float y)
1162 return IsVisible (new PointF (x, y));
1165 public bool IsVisible (int x, int y)
1167 return IsVisible (new Point (x, y));
1170 public bool IsVisible (float x, float y, float width, float height)
1172 return IsVisible (new RectangleF (x, y, width, height));
1176 public bool IsVisible (int x, int y, int width, int height)
1178 return IsVisible (new Rectangle (x, y, width, height));
1182 public Region [] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1184 throw new NotImplementedException ();
1188 public SizeF MeasureString (string text, Font font)
1190 throw new NotImplementedException ();
1194 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1196 throw new NotImplementedException ();
1200 public SizeF MeasureString (string text, Font font, int width)
1202 throw new NotImplementedException ();
1206 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat)
1208 throw new NotImplementedException ();
1212 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1214 throw new NotImplementedException ();
1218 public SizeF MeasureString (string text, Font font, PointF origin, StringFormat stringFormat)
1220 throw new NotImplementedException ();
1224 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat,
1225 out int charactersFitted, out int linesFilled)
1227 throw new NotImplementedException ();
1230 public void MultiplyTransform (Matrix matrix)
1232 MultiplyTransform (matrix, MatrixOrder.Prepend);
1235 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
1237 GDIPlus.GdipMultiplyWorldTransform (nativeObject, matrix.nativeMatrix, order);
1240 public void ReleaseHdc (IntPtr hdc)
1242 GDIPlus.GdipReleaseDC (nativeObject, hdc);
1246 public void ReleaseHdcInternal (IntPtr hdc)
1248 throw new NotImplementedException ();
1252 public void ResetClip ()
1254 GDIPlus.GdipResetClip(nativeObject);
1257 public void ResetTransform ()
1259 GDIPlus.GdipResetWorldTransform (nativeObject);
1263 public void Restore (GraphicsState gstate)
1265 Transform = gstate.matrix.Clone();
1266 GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
1270 public void RotateTransform (float angle)
1272 RotateTransform(angle, MatrixOrder.Prepend);
1276 public void RotateTransform (float angle, MatrixOrder order)
1278 //transform.Rotate(angle, order);
1279 GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
1283 public GraphicsState Save ()
1285 //return implementation.Save();
1286 GraphicsState state = new GraphicsState();
1287 state.matrix = Transform.Clone ();
1289 GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
1290 state.nativeState = saveState;
1294 public void ScaleTransform (float sx, float sy)
1296 ScaleTransform (sx, sy, MatrixOrder.Prepend);
1299 public void ScaleTransform (float sx, float sy, MatrixOrder order)
1301 GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
1305 public void SetClip (RectangleF rect)
1307 SetClip (rect, CombineMode.Replace);
1311 public void SetClip (GraphicsPath path)
1313 SetClip (path, CombineMode.Replace);
1317 public void SetClip (Rectangle rect)
1319 SetClip (rect, CombineMode.Replace);
1323 public void SetClip (Graphics g)
1325 SetClip (g, CombineMode.Replace);
1329 public void SetClip (Graphics g, CombineMode combineMode)
1331 GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
1335 public void SetClip (Rectangle rect, CombineMode combineMode)
1337 GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1341 public void SetClip (RectangleF rect, CombineMode combineMode)
1343 GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1347 public void SetClip (Region region, CombineMode combineMode)
1349 //GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode); //TODO: Region not implemented yet
1353 public void SetClip (GraphicsPath path, CombineMode combineMode)
1355 GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
1359 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
1361 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
1363 Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
1365 GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
1369 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
1371 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
1373 Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
1375 GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
1379 public void TranslateClip (int dx, int dy)
1381 GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
1385 public void TranslateClip (float dx, float dy)
1387 GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
1390 public void TranslateTransform (float dx, float dy)
1392 TranslateTransform (dx, dy, MatrixOrder.Prepend);
1396 public void TranslateTransform (float dx, float dy, MatrixOrder order)
1398 GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
1401 public Region Clip {
1403 throw new NotImplementedException ();
1406 //throw new NotImplementedException ();
1410 public RectangleF ClipBounds {
1412 RectangleF rect = new RectangleF ();
1413 GDIPlus.GdipGetClipBounds (nativeObject, out rect);
1418 public CompositingMode CompositingMode {
1420 CompositingMode mode;
1421 GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
1426 GDIPlus.GdipSetCompositingMode (nativeObject, value);
1431 public CompositingQuality CompositingQuality {
1433 CompositingQuality quality;
1435 GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
1439 GDIPlus.GdipSetCompositingQuality (nativeObject, value);
1447 GDIPlus.GdipGetDpiX (nativeObject, out x);
1456 GDIPlus.GdipGetDpiY (nativeObject, out y);
1461 public InterpolationMode InterpolationMode {
1463 InterpolationMode imode = InterpolationMode.Invalid;
1464 GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
1468 GDIPlus.GdipSetInterpolationMode (nativeObject, value);
1472 public bool IsClipEmpty {
1474 bool isEmpty = false;
1476 GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
1481 public bool IsVisibleClipEmpty {
1483 bool isEmpty = false;
1485 GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
1490 public float PageScale {
1494 GDIPlus.GdipGetPageScale (nativeObject, out scale);
1498 GDIPlus.GdipSetPageScale (nativeObject, value);
1502 public GraphicsUnit PageUnit {
1506 GDIPlus.GdipGetPageUnit (nativeObject, out unit);
1510 GDIPlus.GdipSetPageUnit (nativeObject, value);
1514 public PixelOffsetMode PixelOffsetMode {
1516 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
1518 GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
1523 GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
1527 public Point RenderingOrigin {
1530 GDIPlus.GdipGetRenderingOrigin (
1531 nativeObject, out x, out y);
1533 return new Point (x, y);
1537 GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
1541 public SmoothingMode SmoothingMode {
1543 SmoothingMode mode = SmoothingMode.Invalid;
1545 GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
1551 GDIPlus.GdipSetSmoothingMode (nativeObject, value);
1555 public int TextContrast {
1559 GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
1564 GDIPlus.GdipSetTextContrast (nativeObject, value);
1568 public TextRenderingHint TextRenderingHint {
1570 TextRenderingHint hint;
1572 GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
1577 GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
1581 public Matrix Transform {
1583 Matrix matrix = new Matrix ();
1584 GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
1589 GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
1593 public RectangleF VisibleClipBounds {
1597 GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);