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.ComponentModel;
16 using System.Runtime.InteropServices;
19 namespace System.Drawing
22 public sealed class Graphics : MarshalByRefObject, IDisposable
24 internal IntPtr nativeObject = IntPtr.Zero;
26 private static float defDpiX = 0;
27 private static float defDpiY = 0;
30 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
34 PlayRecordCallback callbackData);
37 public delegate bool DrawImageAbort (IntPtr callbackData);
39 private Graphics (IntPtr nativeGraphics)
41 if (nativeGraphics == IntPtr.Zero)
42 Console.WriteLine ("Here: " + Environment.StackTrace);
43 nativeObject = nativeGraphics;
46 static internal float systemDpiX {
49 Bitmap bmp = new Bitmap(1,1);
50 Graphics g = Graphics.FromImage(bmp);
57 static internal float systemDpiY {
60 Bitmap bmp = new Bitmap(1,1);
61 Graphics g = Graphics.FromImage(bmp);
68 internal IntPtr NativeObject {
79 public void AddMetafileComment (byte [] data)
81 throw new NotImplementedException ();
85 public GraphicsContainer BeginContainer ()
89 status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
90 GDIPlus.CheckStatus (status);
92 return new GraphicsContainer(state);
95 public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
99 status = GDIPlus.GdipBeginContainerI (nativeObject, dstrect, srcrect, unit, out state);
100 GDIPlus.CheckStatus (status);
102 return new GraphicsContainer (state);
106 public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
110 status = GDIPlus.GdipBeginContainer (nativeObject, dstrect, srcrect, unit, out state);
111 GDIPlus.CheckStatus (status);
113 return new GraphicsContainer (state);
117 public void Clear (Color color)
120 status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ()); GDIPlus.CheckStatus (status);
124 public void Dispose ()
129 public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
131 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
135 public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
137 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
141 public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
144 status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
145 x, y, width, height, startAngle, sweepAngle);
146 GDIPlus.CheckStatus (status);
149 // Microsoft documentation states that the signature for this member should be
150 // public void DrawArc( Pen pen, int x, int y, int width, int height, int startAngle,
151 // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
152 public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
155 status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
156 x, y, width, height, startAngle, sweepAngle);
157 GDIPlus.CheckStatus (status);
160 public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
163 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
164 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
165 pt3.Y, pt4.X, pt4.Y);
166 GDIPlus.CheckStatus (status);
169 public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
172 status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
173 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
174 pt3.Y, pt4.X, pt4.Y);
175 GDIPlus.CheckStatus (status);
178 public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
181 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
182 y1, x2, y2, x3, y3, x4, y4);
183 GDIPlus.CheckStatus (status);
186 public void DrawBeziers (Pen pen, Point [] points)
188 int length = points.Length;
194 for (int i = 0; i < length; i += 3) {
195 Point p1 = points [i];
196 Point p2 = points [i + 1];
197 Point p3 = points [i + 2];
198 Point p4 = points [i + 3];
200 status = GDIPlus.GdipDrawBezier (nativeObject,
202 p1.X, p1.Y, p2.X, p2.Y,
203 p3.X, p3.Y, p4.X, p4.Y);
204 GDIPlus.CheckStatus (status);
208 public void DrawBeziers (Pen pen, PointF [] points)
210 int length = points.Length;
216 for (int i = 0; i < length; i += 3) {
217 PointF p1 = points [i];
218 PointF p2 = points [i + 1];
219 PointF p3 = points [i + 2];
220 PointF p4 = points [i + 3];
222 status = GDIPlus.GdipDrawBezier (nativeObject,
224 p1.X, p1.Y, p2.X, p2.Y,
225 p3.X, p3.Y, p4.X, p4.Y);
226 GDIPlus.CheckStatus (status);
231 public void DrawClosedCurve (Pen pen, PointF [] points)
234 status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
235 GDIPlus.CheckStatus (status);
238 public void DrawClosedCurve (Pen pen, Point [] points)
241 status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
242 GDIPlus.CheckStatus (status);
245 public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
248 status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
249 GDIPlus.CheckStatus (status);
252 public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
255 status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
256 GDIPlus.CheckStatus (status);
259 public void DrawCurve (Pen pen, Point [] points)
262 status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
263 GDIPlus.CheckStatus (status);
266 public void DrawCurve (Pen pen, PointF [] points)
269 status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
270 GDIPlus.CheckStatus (status);
273 public void DrawCurve (Pen pen, PointF [] points, float tension)
276 status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
277 GDIPlus.CheckStatus (status);
280 public void DrawCurve (Pen pen, Point [] points, float tension)
283 status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
284 GDIPlus.CheckStatus (status);
288 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
291 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
292 points, points.Length, offset,
293 numberOfSegments, 0.5f);
294 GDIPlus.CheckStatus (status);
297 public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
300 status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
301 points, points.Length, offset,
302 numberOfSegments, tension);
303 GDIPlus.CheckStatus (status);
307 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
310 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
311 points, points.Length, offset,
312 numberOfSegments, tension);
313 GDIPlus.CheckStatus (status);
316 public void DrawEllipse (Pen pen, Rectangle rect)
318 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
321 public void DrawEllipse (Pen pen, RectangleF rect)
323 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
326 public void DrawEllipse (Pen pen, int x, int y, int width, int height)
329 status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
330 GDIPlus.CheckStatus (status);
333 public void DrawEllipse (Pen pen, float x, float y, float width, float height)
335 Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
336 GDIPlus.CheckStatus (status);
340 public void DrawIcon (Icon icon, Rectangle targetRect)
342 throw new NotImplementedException ();
346 public void DrawIcon (Icon icon, int x, int y)
348 throw new NotImplementedException ();
352 public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
354 throw new NotImplementedException ();
357 public void DrawImage (Image image, RectangleF rect)
359 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
360 GDIPlus.CheckStatus (status);
364 public void DrawImage (Image image, PointF point)
366 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
367 GDIPlus.CheckStatus (status);
371 public void DrawImage (Image image, Point [] destPoints)
373 Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
374 GDIPlus.CheckStatus (status);
378 public void DrawImage (Image image, Point point)
380 DrawImage (image, point.X, point.Y);
384 public void DrawImage (Image image, Rectangle rect)
386 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
390 public void DrawImage (Image image, PointF [] destPoints)
392 Status status = GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
393 GDIPlus.CheckStatus (status);
397 public void DrawImage (Image image, int x, int y)
399 Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
400 GDIPlus.CheckStatus (status);
404 public void DrawImage (Image image, float x, float y)
406 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
407 GDIPlus.CheckStatus (status);
411 public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
413 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
414 destRect.X, destRect.Y, destRect.Width, destRect.Height,
415 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
416 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
417 GDIPlus.CheckStatus (status);
420 public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
422 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
423 destRect.X, destRect.Y, destRect.Width, destRect.Height,
424 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
425 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
426 GDIPlus.CheckStatus (status);
430 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
432 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
433 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
434 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
436 GDIPlus.CheckStatus (status);
440 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
443 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
444 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
445 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
447 GDIPlus.CheckStatus (status);
451 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
452 ImageAttributes imageAttr)
454 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
455 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
456 srcRect.Width, srcRect.Height, srcUnit,
457 imageAttr.NativeObject, null, IntPtr.Zero);
458 GDIPlus.CheckStatus (status);
461 public void DrawImage (Image image, float x, float y, float width, float height)
463 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
465 GDIPlus.CheckStatus (status);
469 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
470 ImageAttributes imageAttr)
472 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
473 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
474 srcRect.Width, srcRect.Height, srcUnit,
475 imageAttr.NativeObject, null, IntPtr.Zero);
476 GDIPlus.CheckStatus (status);
480 public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
482 Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
483 GDIPlus.CheckStatus (status);
486 public void DrawImage (Image image, int x, int y, int width, int height)
488 Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
489 GDIPlus.CheckStatus (status);
492 public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
494 Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
495 GDIPlus.CheckStatus (status);
499 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
501 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
502 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
503 srcRect.Width, srcRect.Height, srcUnit,
504 imageAttr.NativeObject, callback, IntPtr.Zero);
505 GDIPlus.CheckStatus (status);
509 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
512 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
513 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
514 srcRect.Width, srcRect.Height, srcUnit,
515 imageAttr.NativeObject, callback, IntPtr.Zero);
516 GDIPlus.CheckStatus (status);
520 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
523 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
524 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
525 srcRect.Width, srcRect.Height, srcUnit,
526 imageAttr.NativeObject, callback, (IntPtr) callbackData);
527 GDIPlus.CheckStatus (status);
531 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
533 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
534 destRect.X, destRect.Y, destRect.Width, destRect.Height,
535 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
537 GDIPlus.CheckStatus (status);
540 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
542 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
543 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
544 srcRect.Width, srcRect.Height, srcUnit,
545 imageAttr.NativeObject, callback, (IntPtr) callbackData);
546 GDIPlus.CheckStatus (status);
550 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
552 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
553 destRect.X, destRect.Y, destRect.Width, destRect.Height,
554 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
556 GDIPlus.CheckStatus (status);
560 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
562 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
563 destRect.X, destRect.Y, destRect.Width, destRect.Height,
564 srcX, srcY, srcWidth, srcHeight, srcUnit,
565 imageAttrs.NativeObject, null, IntPtr.Zero);
566 GDIPlus.CheckStatus (status);
569 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
571 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
572 destRect.X, destRect.Y, destRect.Width,
573 destRect.Height, srcX, srcY, srcWidth, srcHeight,
574 srcUnit, imageAttr.NativeObject, null, IntPtr.Zero);
575 GDIPlus.CheckStatus (status);
578 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
580 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
581 destRect.X, destRect.Y, destRect.Width,
582 destRect.Height, srcX, srcY, srcWidth, srcHeight,
583 srcUnit, imageAttr.NativeObject, callback,
585 GDIPlus.CheckStatus (status);
588 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
590 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
591 destRect.X, destRect.Y, destRect.Width,
592 destRect.Height, srcX, srcY, srcWidth, srcHeight,
593 srcUnit, imageAttr.NativeObject,
594 callback, IntPtr.Zero);
595 GDIPlus.CheckStatus (status);
599 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
601 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
602 destRect.X, destRect.Y, destRect.Width, destRect.Height,
603 srcX, srcY, srcWidth, srcHeight, srcUnit,
604 imageAttr.NativeObject, callback, callbackData);
605 GDIPlus.CheckStatus (status);
609 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
611 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
612 destRect.X, destRect.Y, destRect.Width, destRect.Height,
613 srcX, srcY, srcWidth, srcHeight, srcUnit,
614 imageAttr.NativeObject, callback, callbackData);
615 GDIPlus.CheckStatus (status);
618 public void DrawImageUnscaled (Image image, Point point)
620 DrawImage(image, point.X, point.Y);
623 public void DrawImageUnscaled (Image image, Rectangle rect)
625 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
628 public void DrawImageUnscaled (Image image, int x, int y)
630 DrawImage(image, x, y);
633 public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
635 DrawImage(image, x, y, width, height);
638 public void DrawLine (Pen pen, PointF pt1, PointF pt2)
640 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
641 pt1.X, pt1.Y, pt2.X, pt2.Y);
642 GDIPlus.CheckStatus (status);
645 public void DrawLine (Pen pen, Point pt1, Point pt2)
647 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
648 pt1.X, pt1.Y, pt2.X, pt2.Y);
649 GDIPlus.CheckStatus (status);
652 public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
654 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
655 GDIPlus.CheckStatus (status);
658 public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
660 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
661 GDIPlus.CheckStatus (status);
664 public void DrawLines (Pen pen, PointF [] points)
666 Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
667 GDIPlus.CheckStatus (status);
670 public void DrawLines (Pen pen, Point [] points)
672 Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
673 GDIPlus.CheckStatus (status);
676 public void DrawPath (Pen pen, GraphicsPath path)
678 Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
679 GDIPlus.CheckStatus (status);
682 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
684 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
687 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
689 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
692 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
694 Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
695 GDIPlus.CheckStatus (status);
698 // Microsoft documentation states that the signature for this member should be
699 // public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle
700 // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
701 public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
703 Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
704 GDIPlus.CheckStatus (status);
707 public void DrawPolygon (Pen pen, Point [] points)
709 Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
710 GDIPlus.CheckStatus (status);
713 public void DrawPolygon (Pen pen, PointF [] points)
715 Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
716 GDIPlus.CheckStatus (status);
719 internal void DrawRectangle (Pen pen, RectangleF rect)
721 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
724 public void DrawRectangle (Pen pen, Rectangle rect)
726 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
729 public void DrawRectangle (Pen pen, float x, float y, float width, float height)
731 Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
732 GDIPlus.CheckStatus (status);
735 public void DrawRectangle (Pen pen, int x, int y, int width, int height)
737 Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
738 GDIPlus.CheckStatus (status);
741 public void DrawRectangles (Pen pen, RectangleF [] rects)
743 foreach (RectangleF rc in rects)
744 DrawRectangle (pen, rc.Left, rc.Top, rc.Width, rc.Height);
747 public void DrawRectangles (Pen pen, Rectangle [] rects)
749 foreach (RectangleF rc in rects)
750 DrawRectangle(pen, rc.Left, rc.Top, rc.Width, rc.Height);
754 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
756 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, IntPtr.Zero, brush.nativeObject);
757 GDIPlus.CheckStatus (status);
760 public void DrawString (string s, Font font, Brush brush, PointF point)
762 RectangleF rc = new RectangleF (point.X, point.Y, 0, 0);
763 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref rc, IntPtr.Zero, brush.nativeObject);
764 GDIPlus.CheckStatus (status);
767 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
769 RectangleF rc = new RectangleF (point.X, point.Y, 0, 0);
770 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref rc, format.NativeObject, brush.nativeObject);
771 GDIPlus.CheckStatus (status);
774 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
776 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format.NativeObject, brush.nativeObject);
777 GDIPlus.CheckStatus (status);
780 public void DrawString (string s, Font font, Brush brush, float x, float y)
782 RectangleF rc = new RectangleF (x, y, 0, 0);
784 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject,
785 ref rc, IntPtr.Zero, brush.nativeObject);
786 GDIPlus.CheckStatus (status);
789 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
791 RectangleF rc = new RectangleF (x, y, 0, 0);
793 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject,
794 ref rc, format.NativeObject, brush.nativeObject);
795 GDIPlus.CheckStatus (status);
799 public void EndContainer (GraphicsContainer container)
801 Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
802 GDIPlus.CheckStatus (status);
806 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
808 throw new NotImplementedException ();
812 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
814 throw new NotImplementedException ();
818 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
820 throw new NotImplementedException ();
824 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
826 throw new NotImplementedException ();
830 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
832 throw new NotImplementedException ();
836 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
838 throw new NotImplementedException ();
842 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
844 throw new NotImplementedException ();
848 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
850 throw new NotImplementedException ();
854 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
856 throw new NotImplementedException ();
860 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
862 throw new NotImplementedException ();
866 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
868 throw new NotImplementedException ();
872 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
874 throw new NotImplementedException ();
878 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
880 throw new NotImplementedException ();
884 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
886 throw new NotImplementedException ();
890 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
892 throw new NotImplementedException ();
896 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
898 throw new NotImplementedException ();
902 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
904 throw new NotImplementedException ();
908 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
910 throw new NotImplementedException ();
914 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
916 throw new NotImplementedException ();
920 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
922 throw new NotImplementedException ();
926 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
928 throw new NotImplementedException ();
932 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
934 throw new NotImplementedException ();
938 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
940 throw new NotImplementedException ();
944 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
946 throw new NotImplementedException ();
950 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
952 throw new NotImplementedException ();
956 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
958 throw new NotImplementedException ();
962 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
964 throw new NotImplementedException ();
968 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
970 throw new NotImplementedException ();
974 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
976 throw new NotImplementedException ();
980 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
982 throw new NotImplementedException ();
986 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
988 throw new NotImplementedException ();
992 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
994 throw new NotImplementedException ();
998 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1000 throw new NotImplementedException ();
1004 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1006 throw new NotImplementedException ();
1010 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1012 throw new NotImplementedException ();
1016 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1018 throw new NotImplementedException ();
1021 public void ExcludeClip (Rectangle rect)
1023 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1024 GDIPlus.CheckStatus (status);
1028 public void ExcludeClip (Region region)
1030 throw new NotImplementedException ();
1034 public void FillClosedCurve (Brush brush, PointF [] points)
1036 Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1037 GDIPlus.CheckStatus (status);
1041 public void FillClosedCurve (Brush brush, Point [] points)
1043 Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1044 GDIPlus.CheckStatus (status);
1048 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1050 FillClosedCurve (brush, points, fillmode, 0.5f);
1053 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1055 FillClosedCurve (brush, points, fillmode, 0.5f);
1058 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1060 Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1061 GDIPlus.CheckStatus (status);
1064 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1066 Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1067 GDIPlus.CheckStatus (status);
1070 public void FillEllipse (Brush brush, Rectangle rect)
1072 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1075 public void FillEllipse (Brush brush, RectangleF rect)
1077 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1080 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1082 Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1083 GDIPlus.CheckStatus (status);
1086 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1088 Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1089 GDIPlus.CheckStatus (status);
1092 public void FillPath (Brush brush, GraphicsPath path)
1094 Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
1095 GDIPlus.CheckStatus (status);
1098 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1100 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1101 GDIPlus.CheckStatus (status);
1104 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1106 Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1107 GDIPlus.CheckStatus (status);
1110 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1112 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1113 GDIPlus.CheckStatus (status);
1116 public void FillPolygon (Brush brush, PointF [] points)
1118 Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1119 GDIPlus.CheckStatus (status);
1122 public void FillPolygon (Brush brush, Point [] points)
1124 Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1125 GDIPlus.CheckStatus (status);
1128 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1130 Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1131 GDIPlus.CheckStatus (status);
1134 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1136 Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1137 GDIPlus.CheckStatus (status);
1140 public void FillRectangle (Brush brush, RectangleF rect)
1142 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1145 public void FillRectangle (Brush brush, Rectangle rect)
1147 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1150 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1152 Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, (float)x, (float)y, (float)width, (float)height);
1153 GDIPlus.CheckStatus (status);
1156 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1158 Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1159 GDIPlus.CheckStatus (status);
1162 public void FillRectangles (Brush brush, Rectangle [] rects)
1164 foreach (Rectangle rc in rects)
1165 FillRectangle(brush, rc);
1168 public void FillRectangles (Brush brush, RectangleF [] rects)
1170 foreach (RectangleF rc in rects)
1171 FillRectangle(brush, rc);
1175 public void FillRegion (Brush brush, Region region)
1177 Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);
1178 GDIPlus.CheckStatus(status);
1182 public void Flush ()
1184 Flush (FlushIntention.Flush);
1188 public void Flush (FlushIntention intention)
1190 Status status = GDIPlus.GdipFlush (nativeObject, intention);
1191 GDIPlus.CheckStatus (status);
1194 [EditorBrowsable (EditorBrowsableState.Advanced)]
1195 public static Graphics FromHdc (IntPtr hdc)
1198 Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics); GDIPlus.CheckStatus (status);
1200 Graphics result = new Graphics ((IntPtr) graphics);
1205 [EditorBrowsable (EditorBrowsableState.Advanced)]
1206 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1208 throw new NotImplementedException ();
1212 [EditorBrowsable (EditorBrowsableState.Advanced)]
1213 public static Graphics FromHdcInternal (IntPtr hdc)
1215 throw new NotImplementedException ();
1218 [EditorBrowsable (EditorBrowsableState.Advanced)]
1219 public static Graphics FromHwnd (IntPtr hwnd)
1223 Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics); GDIPlus.CheckStatus (status);
1225 return new Graphics (graphics);
1229 [EditorBrowsable (EditorBrowsableState.Advanced)]
1230 public static Graphics FromHwndInternal (IntPtr hwnd)
1232 throw new NotImplementedException ();
1236 public static Graphics FromImage (Image image)
1238 if (image == null) throw new ArgumentException ();
1240 Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1241 GDIPlus.CheckStatus (status);
1242 Graphics result = new Graphics ((IntPtr) graphics);
1246 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1249 Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1250 GDIPlus.CheckStatus (s);
1251 return new Graphics (graphics);
1255 public static IntPtr GetHalftonePalette ()
1257 throw new NotImplementedException ();
1261 [EditorBrowsable (EditorBrowsableState.Advanced)]
1262 public IntPtr GetHdc ()
1265 Status status = GDIPlus.GdipGetDC (nativeObject, out hdc);
1266 GDIPlus.CheckStatus (status);
1268 return (IntPtr) hdc;
1272 public Color GetNearestColor (Color color)
1276 Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1277 GDIPlus.CheckStatus (status);
1279 return Color.FromArgb (argb);
1283 public void IntersectClip (Region region)
1285 throw new NotImplementedException ();
1288 public void IntersectClip (RectangleF rect)
1290 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1291 GDIPlus.CheckStatus (status);
1294 public void IntersectClip (Rectangle rect)
1296 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1297 GDIPlus.CheckStatus (status);
1300 public bool IsVisible (Point point)
1302 bool isVisible = false;
1304 Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1305 GDIPlus.CheckStatus (status);
1311 public bool IsVisible (RectangleF rect)
1313 bool isVisible = false;
1315 Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1316 GDIPlus.CheckStatus (status);
1321 public bool IsVisible (PointF point)
1323 bool isVisible = false;
1325 Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1326 GDIPlus.CheckStatus (status);
1331 public bool IsVisible (Rectangle rect)
1333 bool isVisible = false;
1335 Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1336 GDIPlus.CheckStatus (status);
1341 public bool IsVisible (float x, float y)
1343 return IsVisible (new PointF (x, y));
1346 public bool IsVisible (int x, int y)
1348 return IsVisible (new Point (x, y));
1351 public bool IsVisible (float x, float y, float width, float height)
1353 return IsVisible (new RectangleF (x, y, width, height));
1357 public bool IsVisible (int x, int y, int width, int height)
1359 return IsVisible (new Rectangle (x, y, width, height));
1363 public Region [] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1365 Region [] result=new Region[stringFormat.GetCharRanges.Length];
1366 string textFragment;
1369 for (int i=0; i<stringFormat.GetCharRanges.Length; i++) {
1370 textFragment=text.Substring(stringFormat.GetCharRanges[i].First, stringFormat.GetCharRanges[i].Length);
1371 fragmentSize=MeasureString(textFragment, font, new SizeF(layoutRect.Width, layoutRect.Height), stringFormat);
1372 result[i]=new Region(new RectangleF(layoutRect.X, layoutRect.Y, layoutRect.X+fragmentSize.Width, layoutRect.Y+fragmentSize.Height));
1379 public SizeF MeasureString (string text, Font font)
1381 return MeasureString (text, font, new Size(0,0));
1385 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1387 int charactersFitted, linesFilled;
1388 RectangleF boundingBox = new RectangleF ();
1389 RectangleF rect = new RectangleF (0,0,layoutArea.Width, layoutArea.Height);
1391 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1392 font.NativeObject, ref rect, IntPtr.Zero, out boundingBox,
1393 out charactersFitted, out linesFilled);
1394 GDIPlus.CheckStatus (status);
1396 return new SizeF(boundingBox.Width, boundingBox.Height);
1400 public SizeF MeasureString (string text, Font font, int width)
1402 throw new NotImplementedException ();
1406 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat)
1408 int charactersFitted, linesFilled;
1409 return MeasureString (text, font, layoutArea, stringFormat, out charactersFitted, out linesFilled);
1413 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1415 throw new NotImplementedException ();
1419 public SizeF MeasureString (string text, Font font, PointF origin, StringFormat stringFormat)
1421 RectangleF boundingBox = new RectangleF ();
1422 RectangleF rect = new RectangleF (origin.X, origin.Y, 0,0);
1423 int charactersFitted, linesFilled;
1425 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1426 font.NativeObject, ref rect, stringFormat.NativeObject,
1427 out boundingBox, out charactersFitted, out linesFilled);
1428 GDIPlus.CheckStatus (status);
1430 return new SizeF (boundingBox.Width, boundingBox.Height);
1434 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat, out int charactersFitted, out int linesFilled)
1436 RectangleF boundingBox = new RectangleF ();
1437 RectangleF rect = new RectangleF (0,0,layoutArea.Width, layoutArea.Height);
1438 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1439 font.NativeObject, ref rect, stringFormat.NativeObject,
1440 out boundingBox, out charactersFitted, out linesFilled);
1441 GDIPlus.CheckStatus (status);
1443 return new SizeF (boundingBox.Width, boundingBox.Height);
1446 public void MultiplyTransform (Matrix matrix)
1448 MultiplyTransform (matrix, MatrixOrder.Prepend);
1451 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
1453 Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject, matrix.nativeMatrix, order);
1454 GDIPlus.CheckStatus (status);
1457 [EditorBrowsable (EditorBrowsableState.Advanced)]
1458 public void ReleaseHdc (IntPtr hdc)
1460 Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
1461 GDIPlus.CheckStatus (status);
1465 [EditorBrowsable (EditorBrowsableState.Advanced)]
1466 public void ReleaseHdcInternal (IntPtr hdc)
1468 throw new NotImplementedException ();
1472 public void ResetClip ()
1474 Status status = GDIPlus.GdipResetClip (nativeObject);
1475 GDIPlus.CheckStatus (status);
1478 public void ResetTransform ()
1480 Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
1481 GDIPlus.CheckStatus (status);
1484 public void Restore (GraphicsState gstate)
1486 Transform = gstate.matrix.Clone ();
1487 Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
1488 GDIPlus.CheckStatus (status);
1492 public void RotateTransform (float angle)
1494 RotateTransform (angle, MatrixOrder.Prepend);
1497 public void RotateTransform (float angle, MatrixOrder order)
1500 Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
1501 GDIPlus.CheckStatus (status);
1504 public GraphicsState Save ()
1506 GraphicsState state = new GraphicsState ();
1507 state.matrix = Transform.Clone ();
1509 Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
1510 GDIPlus.CheckStatus (status);
1512 state.nativeState = saveState;
1516 public void ScaleTransform (float sx, float sy)
1518 ScaleTransform (sx, sy, MatrixOrder.Prepend);
1521 public void ScaleTransform (float sx, float sy, MatrixOrder order)
1523 Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
1524 GDIPlus.CheckStatus (status);
1528 public void SetClip (RectangleF rect)
1530 SetClip (rect, CombineMode.Replace);
1534 public void SetClip (GraphicsPath path)
1536 SetClip (path, CombineMode.Replace);
1540 public void SetClip (Rectangle rect)
1542 SetClip (rect, CombineMode.Replace);
1546 public void SetClip (Graphics g)
1548 SetClip (g, CombineMode.Replace);
1552 public void SetClip (Graphics g, CombineMode combineMode)
1554 Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
1555 GDIPlus.CheckStatus (status);
1559 public void SetClip (Rectangle rect, CombineMode combineMode)
1561 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1562 GDIPlus.CheckStatus (status);
1566 public void SetClip (RectangleF rect, CombineMode combineMode)
1568 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1569 GDIPlus.CheckStatus (status);
1573 public void SetClip (Region region, CombineMode combineMode)
1575 //GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode); //TODO: Region not implemented yet
1576 throw new NotImplementedException();
1580 public void SetClip (GraphicsPath path, CombineMode combineMode)
1582 Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
1583 GDIPlus.CheckStatus (status);
1587 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
1589 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
1591 Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
1592 GDIPlus.CheckStatus (status);
1594 GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
1598 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
1600 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
1602 Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
1603 GDIPlus.CheckStatus (status);
1605 GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
1609 public void TranslateClip (int dx, int dy)
1611 Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
1612 GDIPlus.CheckStatus (status);
1616 public void TranslateClip (float dx, float dy)
1618 Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
1619 GDIPlus.CheckStatus (status);
1622 public void TranslateTransform (float dx, float dy)
1624 TranslateTransform (dx, dy, MatrixOrder.Prepend);
1628 public void TranslateTransform (float dx, float dy, MatrixOrder order)
1630 Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
1631 GDIPlus.CheckStatus (status);
1634 public Region Clip {
1636 throw new NotImplementedException ();
1639 //throw new NotImplementedException ();
1643 public RectangleF ClipBounds {
1645 RectangleF rect = new RectangleF ();
1646 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
1647 GDIPlus.CheckStatus (status);
1652 public CompositingMode CompositingMode {
1654 CompositingMode mode;
1655 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
1656 GDIPlus.CheckStatus (status);
1661 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
1662 GDIPlus.CheckStatus (status);
1667 public CompositingQuality CompositingQuality {
1669 CompositingQuality quality;
1671 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
1672 GDIPlus.CheckStatus (status);
1676 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
1677 GDIPlus.CheckStatus (status);
1685 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
1686 GDIPlus.CheckStatus (status);
1695 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
1696 GDIPlus.CheckStatus (status);
1701 public InterpolationMode InterpolationMode {
1703 InterpolationMode imode = InterpolationMode.Invalid;
1704 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
1705 GDIPlus.CheckStatus (status);
1709 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
1710 GDIPlus.CheckStatus (status);
1714 public bool IsClipEmpty {
1716 bool isEmpty = false;
1718 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
1719 GDIPlus.CheckStatus (status);
1724 public bool IsVisibleClipEmpty {
1726 bool isEmpty = false;
1728 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
1729 GDIPlus.CheckStatus (status);
1734 public float PageScale {
1738 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
1739 GDIPlus.CheckStatus (status);
1743 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
1744 GDIPlus.CheckStatus (status);
1748 public GraphicsUnit PageUnit {
1752 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
1753 GDIPlus.CheckStatus (status);
1757 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
1758 GDIPlus.CheckStatus (status);
1762 public PixelOffsetMode PixelOffsetMode {
1764 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
1766 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
1767 GDIPlus.CheckStatus (status);
1771 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
1772 GDIPlus.CheckStatus (status);
1776 public Point RenderingOrigin {
1779 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
1780 GDIPlus.CheckStatus (status);
1781 return new Point (x, y);
1785 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
1786 GDIPlus.CheckStatus (status);
1790 public SmoothingMode SmoothingMode {
1792 SmoothingMode mode = SmoothingMode.Invalid;
1794 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
1795 GDIPlus.CheckStatus (status);
1800 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
1801 GDIPlus.CheckStatus (status);
1805 public int TextContrast {
1809 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
1810 GDIPlus.CheckStatus (status);
1815 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
1816 GDIPlus.CheckStatus (status);
1820 public TextRenderingHint TextRenderingHint {
1822 TextRenderingHint hint;
1824 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
1825 GDIPlus.CheckStatus (status);
1830 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
1831 GDIPlus.CheckStatus (status);
1835 public Matrix Transform {
1837 Matrix matrix = new Matrix ();
1838 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
1839 GDIPlus.CheckStatus (status);
1843 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
1844 GDIPlus.CheckStatus (status);
1848 public RectangleF VisibleClipBounds {
1852 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
1853 GDIPlus.CheckStatus (status);