2 // System.Drawing.Graphics.cs
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com) (stubbed out)
6 // Alexandre Pigolkine(pigolkine@gmx.de)
7 // Jordi Mas i Hernandez (jordi@ximian.com)
9 // Copyright (C) 2003 Ximian, Inc. http://www.ximian.com
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Drawing.Drawing2D;
34 using System.Drawing.Imaging;
35 using System.Drawing.Text;
36 using System.ComponentModel;
37 using System.Runtime.InteropServices;
40 namespace System.Drawing
43 public sealed class Graphics : MarshalByRefObject, IDisposable
45 internal IntPtr nativeObject = IntPtr.Zero;
46 private bool disposed = false;
47 private static float defDpiX = 0;
48 private static float defDpiY = 0;
49 private static IntPtr display = IntPtr.Zero;
52 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
56 PlayRecordCallback callbackData);
59 public delegate bool DrawImageAbort (IntPtr callbackData);
61 private Graphics (IntPtr nativeGraphics)
63 nativeObject = nativeGraphics;
71 static internal float systemDpiX {
74 Bitmap bmp = new Bitmap(1,1);
75 Graphics g = Graphics.FromImage(bmp);
82 static internal float systemDpiY {
85 Bitmap bmp = new Bitmap(1,1);
86 Graphics g = Graphics.FromImage(bmp);
93 internal IntPtr NativeObject {
104 public void AddMetafileComment (byte [] data)
106 throw new NotImplementedException ();
110 public GraphicsContainer BeginContainer ()
114 status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
115 GDIPlus.CheckStatus (status);
117 return new GraphicsContainer(state);
120 public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
124 status = GDIPlus.GdipBeginContainerI (nativeObject, dstrect, srcrect, unit, out state);
125 GDIPlus.CheckStatus (status);
127 return new GraphicsContainer (state);
131 public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
135 status = GDIPlus.GdipBeginContainer (nativeObject, dstrect, srcrect, unit, out state);
136 GDIPlus.CheckStatus (status);
138 return new GraphicsContainer (state);
142 public void Clear (Color color)
145 status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ()); GDIPlus.CheckStatus (status);
148 public void Dispose ()
154 status = GDIPlus.GdipDeleteGraphics (nativeObject);
155 GDIPlus.CheckStatus (status);
162 public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
164 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
168 public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
170 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
174 public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
177 status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
178 x, y, width, height, startAngle, sweepAngle);
179 GDIPlus.CheckStatus (status);
182 // Microsoft documentation states that the signature for this member should be
183 // public void DrawArc( Pen pen, int x, int y, int width, int height, int startAngle,
184 // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
185 public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
188 status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
189 x, y, width, height, startAngle, sweepAngle);
190 GDIPlus.CheckStatus (status);
193 public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
196 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
197 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
198 pt3.Y, pt4.X, pt4.Y);
199 GDIPlus.CheckStatus (status);
202 public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
205 status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
206 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
207 pt3.Y, pt4.X, pt4.Y);
208 GDIPlus.CheckStatus (status);
211 public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
214 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
215 y1, x2, y2, x3, y3, x4, y4);
216 GDIPlus.CheckStatus (status);
219 public void DrawBeziers (Pen pen, Point [] points)
221 int length = points.Length;
227 for (int i = 0; i < length; i += 3) {
228 Point p1 = points [i];
229 Point p2 = points [i + 1];
230 Point p3 = points [i + 2];
231 Point p4 = points [i + 3];
233 status = GDIPlus.GdipDrawBezier (nativeObject,
235 p1.X, p1.Y, p2.X, p2.Y,
236 p3.X, p3.Y, p4.X, p4.Y);
237 GDIPlus.CheckStatus (status);
241 public void DrawBeziers (Pen pen, PointF [] points)
243 int length = points.Length;
249 for (int i = 0; i < length; i += 3) {
250 PointF p1 = points [i];
251 PointF p2 = points [i + 1];
252 PointF p3 = points [i + 2];
253 PointF p4 = points [i + 3];
255 status = GDIPlus.GdipDrawBezier (nativeObject,
257 p1.X, p1.Y, p2.X, p2.Y,
258 p3.X, p3.Y, p4.X, p4.Y);
259 GDIPlus.CheckStatus (status);
264 public void DrawClosedCurve (Pen pen, PointF [] points)
267 status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
268 GDIPlus.CheckStatus (status);
271 public void DrawClosedCurve (Pen pen, Point [] points)
274 status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
275 GDIPlus.CheckStatus (status);
278 public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
281 status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
282 GDIPlus.CheckStatus (status);
285 public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
288 status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
289 GDIPlus.CheckStatus (status);
292 public void DrawCurve (Pen pen, Point [] points)
295 status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
296 GDIPlus.CheckStatus (status);
299 public void DrawCurve (Pen pen, PointF [] points)
302 status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
303 GDIPlus.CheckStatus (status);
306 public void DrawCurve (Pen pen, PointF [] points, float tension)
309 status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
310 GDIPlus.CheckStatus (status);
313 public void DrawCurve (Pen pen, Point [] points, float tension)
316 status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
317 GDIPlus.CheckStatus (status);
321 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
324 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
325 points, points.Length, offset,
326 numberOfSegments, 0.5f);
327 GDIPlus.CheckStatus (status);
330 public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
333 status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
334 points, points.Length, offset,
335 numberOfSegments, tension);
336 GDIPlus.CheckStatus (status);
340 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
343 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
344 points, points.Length, offset,
345 numberOfSegments, tension);
346 GDIPlus.CheckStatus (status);
349 public void DrawEllipse (Pen pen, Rectangle rect)
351 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
354 public void DrawEllipse (Pen pen, RectangleF rect)
356 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
359 public void DrawEllipse (Pen pen, int x, int y, int width, int height)
362 status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
363 GDIPlus.CheckStatus (status);
366 public void DrawEllipse (Pen pen, float x, float y, float width, float height)
368 Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
369 GDIPlus.CheckStatus (status);
373 public void DrawIcon (Icon icon, Rectangle targetRect)
375 throw new NotImplementedException ();
379 public void DrawIcon (Icon icon, int x, int y)
381 throw new NotImplementedException ();
385 public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
387 throw new NotImplementedException ();
390 public void DrawImage (Image image, RectangleF rect)
392 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
393 GDIPlus.CheckStatus (status);
397 public void DrawImage (Image image, PointF point)
399 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
400 GDIPlus.CheckStatus (status);
404 public void DrawImage (Image image, Point [] destPoints)
406 Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
407 GDIPlus.CheckStatus (status);
411 public void DrawImage (Image image, Point point)
413 DrawImage (image, point.X, point.Y);
417 public void DrawImage (Image image, Rectangle rect)
419 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
423 public void DrawImage (Image image, PointF [] destPoints)
425 Status status = GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
426 GDIPlus.CheckStatus (status);
430 public void DrawImage (Image image, int x, int y)
432 Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
433 GDIPlus.CheckStatus (status);
437 public void DrawImage (Image image, float x, float y)
439 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
440 GDIPlus.CheckStatus (status);
444 public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
446 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
447 destRect.X, destRect.Y, destRect.Width, destRect.Height,
448 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
449 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
450 GDIPlus.CheckStatus (status);
453 public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
455 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
456 destRect.X, destRect.Y, destRect.Width, destRect.Height,
457 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
458 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
459 GDIPlus.CheckStatus (status);
463 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
465 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
466 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
467 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
469 GDIPlus.CheckStatus (status);
473 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
476 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
477 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
478 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
480 GDIPlus.CheckStatus (status);
484 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
485 ImageAttributes imageAttr)
487 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
488 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
489 srcRect.Width, srcRect.Height, srcUnit,
490 imageAttr.NativeObject, null, IntPtr.Zero);
491 GDIPlus.CheckStatus (status);
494 public void DrawImage (Image image, float x, float y, float width, float height)
496 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
498 GDIPlus.CheckStatus (status);
502 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
503 ImageAttributes imageAttr)
505 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
506 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
507 srcRect.Width, srcRect.Height, srcUnit,
508 imageAttr.NativeObject, null, IntPtr.Zero);
509 GDIPlus.CheckStatus (status);
513 public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
515 Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
516 GDIPlus.CheckStatus (status);
519 public void DrawImage (Image image, int x, int y, int width, int height)
521 Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
522 GDIPlus.CheckStatus (status);
525 public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
527 Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
528 GDIPlus.CheckStatus (status);
532 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
534 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
535 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
536 srcRect.Width, srcRect.Height, srcUnit,
537 imageAttr.NativeObject, callback, IntPtr.Zero);
538 GDIPlus.CheckStatus (status);
542 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
545 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
546 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
547 srcRect.Width, srcRect.Height, srcUnit,
548 imageAttr.NativeObject, callback, IntPtr.Zero);
549 GDIPlus.CheckStatus (status);
553 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
556 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
557 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
558 srcRect.Width, srcRect.Height, srcUnit,
559 imageAttr.NativeObject, callback, (IntPtr) callbackData);
560 GDIPlus.CheckStatus (status);
564 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
566 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
567 destRect.X, destRect.Y, destRect.Width, destRect.Height,
568 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
570 GDIPlus.CheckStatus (status);
573 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
575 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
576 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
577 srcRect.Width, srcRect.Height, srcUnit,
578 imageAttr.NativeObject, callback, (IntPtr) callbackData);
579 GDIPlus.CheckStatus (status);
583 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
585 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
586 destRect.X, destRect.Y, destRect.Width, destRect.Height,
587 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
589 GDIPlus.CheckStatus (status);
593 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
595 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
596 destRect.X, destRect.Y, destRect.Width, destRect.Height,
597 srcX, srcY, srcWidth, srcHeight, srcUnit,
598 imageAttrs.NativeObject, null, IntPtr.Zero);
599 GDIPlus.CheckStatus (status);
602 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
604 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
605 destRect.X, destRect.Y, destRect.Width,
606 destRect.Height, srcX, srcY, srcWidth, srcHeight,
607 srcUnit, imageAttr.NativeObject, null, IntPtr.Zero);
608 GDIPlus.CheckStatus (status);
611 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
613 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
614 destRect.X, destRect.Y, destRect.Width,
615 destRect.Height, srcX, srcY, srcWidth, srcHeight,
616 srcUnit, imageAttr.NativeObject, callback,
618 GDIPlus.CheckStatus (status);
621 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
623 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
624 destRect.X, destRect.Y, destRect.Width,
625 destRect.Height, srcX, srcY, srcWidth, srcHeight,
626 srcUnit, imageAttr.NativeObject,
627 callback, IntPtr.Zero);
628 GDIPlus.CheckStatus (status);
632 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
634 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
635 destRect.X, destRect.Y, destRect.Width, destRect.Height,
636 srcX, srcY, srcWidth, srcHeight, srcUnit,
637 imageAttr.NativeObject, callback, callbackData);
638 GDIPlus.CheckStatus (status);
642 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
644 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
645 destRect.X, destRect.Y, destRect.Width, destRect.Height,
646 srcX, srcY, srcWidth, srcHeight, srcUnit,
647 imageAttr.NativeObject, callback, callbackData);
648 GDIPlus.CheckStatus (status);
651 public void DrawImageUnscaled (Image image, Point point)
653 DrawImage(image, point.X, point.Y);
656 public void DrawImageUnscaled (Image image, Rectangle rect)
658 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
661 public void DrawImageUnscaled (Image image, int x, int y)
663 DrawImage(image, x, y);
666 public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
668 DrawImage(image, x, y, width, height);
671 public void DrawLine (Pen pen, PointF pt1, PointF pt2)
673 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
674 pt1.X, pt1.Y, pt2.X, pt2.Y);
675 GDIPlus.CheckStatus (status);
678 public void DrawLine (Pen pen, Point pt1, Point pt2)
680 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
681 pt1.X, pt1.Y, pt2.X, pt2.Y);
682 GDIPlus.CheckStatus (status);
685 public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
687 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
688 GDIPlus.CheckStatus (status);
691 public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
693 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
694 GDIPlus.CheckStatus (status);
697 public void DrawLines (Pen pen, PointF [] points)
699 Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
700 GDIPlus.CheckStatus (status);
703 public void DrawLines (Pen pen, Point [] points)
705 Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
706 GDIPlus.CheckStatus (status);
709 public void DrawPath (Pen pen, GraphicsPath path)
711 Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
712 GDIPlus.CheckStatus (status);
715 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
717 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
720 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
722 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
725 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
727 Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
728 GDIPlus.CheckStatus (status);
731 // Microsoft documentation states that the signature for this member should be
732 // public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle
733 // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
734 public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
736 Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
737 GDIPlus.CheckStatus (status);
740 public void DrawPolygon (Pen pen, Point [] points)
742 Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
743 GDIPlus.CheckStatus (status);
746 public void DrawPolygon (Pen pen, PointF [] points)
748 Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
749 GDIPlus.CheckStatus (status);
752 internal void DrawRectangle (Pen pen, RectangleF rect)
754 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
757 public void DrawRectangle (Pen pen, Rectangle rect)
759 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
762 public void DrawRectangle (Pen pen, float x, float y, float width, float height)
764 Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
765 GDIPlus.CheckStatus (status);
768 public void DrawRectangle (Pen pen, int x, int y, int width, int height)
770 Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
771 GDIPlus.CheckStatus (status);
774 public void DrawRectangles (Pen pen, RectangleF [] rects)
776 Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
777 GDIPlus.CheckStatus (status);
780 public void DrawRectangles (Pen pen, Rectangle [] rects)
782 Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
783 GDIPlus.CheckStatus (status);
786 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
788 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, IntPtr.Zero, brush.nativeObject);
789 GDIPlus.CheckStatus (status);
792 public void DrawString (string s, Font font, Brush brush, PointF point)
794 RectangleF rc = new RectangleF (point.X, point.Y, 0, 0);
795 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref rc, IntPtr.Zero, brush.nativeObject);
796 GDIPlus.CheckStatus (status);
799 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
801 RectangleF rc = new RectangleF (point.X, point.Y, 0, 0);
802 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref rc, format.NativeObject, brush.nativeObject);
803 GDIPlus.CheckStatus (status);
806 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
808 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format.NativeObject, brush.nativeObject);
809 GDIPlus.CheckStatus (status);
812 public void DrawString (string s, Font font, Brush brush, float x, float y)
814 RectangleF rc = new RectangleF (x, y, 0, 0);
816 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject,
817 ref rc, IntPtr.Zero, brush.nativeObject);
818 GDIPlus.CheckStatus (status);
821 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
823 RectangleF rc = new RectangleF (x, y, 0, 0);
825 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject,
826 ref rc, format.NativeObject, brush.nativeObject);
827 GDIPlus.CheckStatus (status);
831 public void EndContainer (GraphicsContainer container)
833 Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
834 GDIPlus.CheckStatus (status);
838 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
840 throw new NotImplementedException ();
844 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
846 throw new NotImplementedException ();
850 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
852 throw new NotImplementedException ();
856 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
858 throw new NotImplementedException ();
862 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
864 throw new NotImplementedException ();
868 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
870 throw new NotImplementedException ();
874 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
876 throw new NotImplementedException ();
880 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
882 throw new NotImplementedException ();
886 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
888 throw new NotImplementedException ();
892 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
894 throw new NotImplementedException ();
898 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
900 throw new NotImplementedException ();
904 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
906 throw new NotImplementedException ();
910 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
912 throw new NotImplementedException ();
916 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
918 throw new NotImplementedException ();
922 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
924 throw new NotImplementedException ();
928 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
930 throw new NotImplementedException ();
934 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
936 throw new NotImplementedException ();
940 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
942 throw new NotImplementedException ();
946 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
948 throw new NotImplementedException ();
952 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
954 throw new NotImplementedException ();
958 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
960 throw new NotImplementedException ();
964 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
966 throw new NotImplementedException ();
970 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
972 throw new NotImplementedException ();
976 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
978 throw new NotImplementedException ();
982 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
984 throw new NotImplementedException ();
988 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
990 throw new NotImplementedException ();
994 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
996 throw new NotImplementedException ();
1000 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1002 throw new NotImplementedException ();
1006 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1008 throw new NotImplementedException ();
1012 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1014 throw new NotImplementedException ();
1018 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1020 throw new NotImplementedException ();
1024 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1026 throw new NotImplementedException ();
1030 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1032 throw new NotImplementedException ();
1036 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1038 throw new NotImplementedException ();
1042 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1044 throw new NotImplementedException ();
1048 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1050 throw new NotImplementedException ();
1053 public void ExcludeClip (Rectangle rect)
1055 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1056 GDIPlus.CheckStatus (status);
1059 public void ExcludeClip (Region region)
1061 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
1062 GDIPlus.CheckStatus (status);
1066 public void FillClosedCurve (Brush brush, PointF [] points)
1068 Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1069 GDIPlus.CheckStatus (status);
1073 public void FillClosedCurve (Brush brush, Point [] points)
1075 Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1076 GDIPlus.CheckStatus (status);
1080 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1082 FillClosedCurve (brush, points, fillmode, 0.5f);
1085 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1087 FillClosedCurve (brush, points, fillmode, 0.5f);
1090 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1092 Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1093 GDIPlus.CheckStatus (status);
1096 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1098 Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1099 GDIPlus.CheckStatus (status);
1102 public void FillEllipse (Brush brush, Rectangle rect)
1104 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1107 public void FillEllipse (Brush brush, RectangleF rect)
1109 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1112 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1114 Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1115 GDIPlus.CheckStatus (status);
1118 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1120 Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1121 GDIPlus.CheckStatus (status);
1124 public void FillPath (Brush brush, GraphicsPath path)
1126 Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
1127 GDIPlus.CheckStatus (status);
1130 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1132 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1133 GDIPlus.CheckStatus (status);
1136 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1138 Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1139 GDIPlus.CheckStatus (status);
1142 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1144 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1145 GDIPlus.CheckStatus (status);
1148 public void FillPolygon (Brush brush, PointF [] points)
1150 Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1151 GDIPlus.CheckStatus (status);
1154 public void FillPolygon (Brush brush, Point [] points)
1156 Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1157 GDIPlus.CheckStatus (status);
1160 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1162 Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1163 GDIPlus.CheckStatus (status);
1166 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1168 Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1169 GDIPlus.CheckStatus (status);
1172 public void FillRectangle (Brush brush, RectangleF rect)
1174 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1177 public void FillRectangle (Brush brush, Rectangle rect)
1179 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1182 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1184 Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
1185 GDIPlus.CheckStatus (status);
1188 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1190 Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1191 GDIPlus.CheckStatus (status);
1194 public void FillRectangles (Brush brush, Rectangle [] rects)
1196 Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
1197 GDIPlus.CheckStatus (status);
1200 public void FillRectangles (Brush brush, RectangleF [] rects)
1202 Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
1203 GDIPlus.CheckStatus (status);
1207 public void FillRegion (Brush brush, Region region)
1209 Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);
1210 GDIPlus.CheckStatus(status);
1214 public void Flush ()
1216 Flush (FlushIntention.Flush);
1220 public void Flush (FlushIntention intention)
1222 Status status = GDIPlus.GdipFlush (nativeObject, intention);
1223 GDIPlus.CheckStatus (status);
1226 [EditorBrowsable (EditorBrowsableState.Advanced)]
1227 public static Graphics FromHdc (IntPtr hdc)
1230 Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics); GDIPlus.CheckStatus (status);
1232 Graphics result = new Graphics ((IntPtr) graphics);
1237 [EditorBrowsable (EditorBrowsableState.Advanced)]
1238 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1240 throw new NotImplementedException ();
1244 [EditorBrowsable (EditorBrowsableState.Advanced)]
1245 public static Graphics FromHdcInternal (IntPtr hdc)
1247 throw new NotImplementedException ();
1250 [EditorBrowsable (EditorBrowsableState.Advanced)]
1251 public static Graphics FromHwnd (IntPtr hwnd)
1255 // This needs some working over to support wine in the future
1256 if (Environment.OSVersion.Platform==(PlatformID)128) {
1258 if (display==IntPtr.Zero) {
1259 display=GDIPlus.XOpenDisplay(IntPtr.Zero);
1261 return FromHwnd(hwnd, display);
1263 Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics); GDIPlus.CheckStatus (status);
1265 return new Graphics (graphics);
1268 [EditorBrowsable (EditorBrowsableState.Advanced)]
1269 public static Graphics FromHwnd (IntPtr hwnd, IntPtr display)
1271 lock (typeof (Graphics))
1274 Status s = GDIPlus.GdipCreateFromXDrawable_linux (hwnd, display, out graphics);
1275 GDIPlus.CheckStatus (s);
1276 return new Graphics (graphics);
1281 [EditorBrowsable (EditorBrowsableState.Advanced)]
1282 public static Graphics FromHwndInternal (IntPtr hwnd)
1284 throw new NotImplementedException ();
1287 public static Graphics FromImage (Image image)
1289 lock (typeof (Graphics))
1291 if (image == null) throw new ArgumentException ();
1293 Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1294 GDIPlus.CheckStatus (status);
1295 Graphics result = new Graphics ((IntPtr) graphics);
1297 if (Environment.OSVersion.Platform == (PlatformID) 128) {
1298 Rectangle rect = new Rectangle (0,0, image.Width, image.Height);
1299 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
1306 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1308 lock (typeof (Graphics))
1311 Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1312 GDIPlus.CheckStatus (s);
1313 return new Graphics (graphics);
1318 public static IntPtr GetHalftonePalette ()
1320 throw new NotImplementedException ();
1324 [EditorBrowsable (EditorBrowsableState.Advanced)]
1325 public IntPtr GetHdc ()
1328 Status status = GDIPlus.GdipGetDC (nativeObject, out hdc);
1329 GDIPlus.CheckStatus (status);
1331 return (IntPtr) hdc;
1335 public Color GetNearestColor (Color color)
1339 Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1340 GDIPlus.CheckStatus (status);
1342 return Color.FromArgb (argb);
1346 public void IntersectClip (Region region)
1348 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1349 GDIPlus.CheckStatus (status);
1352 public void IntersectClip (RectangleF rect)
1354 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1355 GDIPlus.CheckStatus (status);
1358 public void IntersectClip (Rectangle rect)
1360 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1361 GDIPlus.CheckStatus (status);
1364 public bool IsVisible (Point point)
1366 bool isVisible = false;
1368 Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1369 GDIPlus.CheckStatus (status);
1375 public bool IsVisible (RectangleF rect)
1377 bool isVisible = false;
1379 Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1380 GDIPlus.CheckStatus (status);
1385 public bool IsVisible (PointF point)
1387 bool isVisible = false;
1389 Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1390 GDIPlus.CheckStatus (status);
1395 public bool IsVisible (Rectangle rect)
1397 bool isVisible = false;
1399 Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1400 GDIPlus.CheckStatus (status);
1405 public bool IsVisible (float x, float y)
1407 return IsVisible (new PointF (x, y));
1410 public bool IsVisible (int x, int y)
1412 return IsVisible (new Point (x, y));
1415 public bool IsVisible (float x, float y, float width, float height)
1417 return IsVisible (new RectangleF (x, y, width, height));
1421 public bool IsVisible (int x, int y, int width, int height)
1423 return IsVisible (new Rectangle (x, y, width, height));
1427 public Region [] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1430 int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
1431 IntPtr[] native_regions = new IntPtr [regcount];
1432 Region[] regions = new Region [regcount];
1434 for (int i = 0; i < regcount; i++) {
1435 regions[i] = new Region ();
1436 native_regions[i] = regions[i].NativeObject;
1439 status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
1440 font.NativeObject, ref layoutRect, stringFormat.NativeObject,
1441 regcount, out native_regions[0]);
1443 GDIPlus.CheckStatus (status);
1449 public SizeF MeasureString (string text, Font font)
1451 return MeasureString (text, font, new Size(0,0));
1455 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1457 int charactersFitted, linesFilled;
1458 RectangleF boundingBox = new RectangleF ();
1459 RectangleF rect = new RectangleF (0,0,layoutArea.Width, layoutArea.Height);
1461 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1462 font.NativeObject, ref rect, IntPtr.Zero, out boundingBox,
1463 out charactersFitted, out linesFilled);
1464 GDIPlus.CheckStatus (status);
1466 return new SizeF(boundingBox.Width, boundingBox.Height);
1470 public SizeF MeasureString (string text, Font font, int width)
1472 RectangleF boundingBox = new RectangleF ();
1473 RectangleF rect = new RectangleF (0, 0, width, 999999);
1474 int charactersFitted, linesFilled;
1476 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1477 font.NativeObject, ref rect, IntPtr.Zero,
1478 out boundingBox, out charactersFitted, out linesFilled);
1479 GDIPlus.CheckStatus (status);
1481 return new SizeF (boundingBox.Width, boundingBox.Height);
1485 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat)
1487 int charactersFitted, linesFilled;
1488 return MeasureString (text, font, layoutArea, stringFormat, out charactersFitted, out linesFilled);
1492 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1494 int charactersFitted, linesFilled;
1495 return MeasureString (text, font, new SizeF (width, 999999),
1496 format, out charactersFitted, out linesFilled);
1500 public SizeF MeasureString (string text, Font font, PointF origin, StringFormat stringFormat)
1502 RectangleF boundingBox = new RectangleF ();
1503 RectangleF rect = new RectangleF (origin.X, origin.Y, 0,0);
1504 int charactersFitted, linesFilled;
1506 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1507 font.NativeObject, ref rect, stringFormat.NativeObject,
1508 out boundingBox, out charactersFitted, out linesFilled);
1509 GDIPlus.CheckStatus (status);
1511 return new SizeF (boundingBox.Width, boundingBox.Height);
1515 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat, out int charactersFitted, out int linesFilled)
1517 RectangleF boundingBox = new RectangleF ();
1518 RectangleF rect = new RectangleF (0,0,layoutArea.Width, layoutArea.Height);
1519 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1520 font.NativeObject, ref rect, stringFormat.NativeObject,
1521 out boundingBox, out charactersFitted, out linesFilled);
1522 GDIPlus.CheckStatus (status);
1524 return new SizeF (boundingBox.Width, boundingBox.Height);
1527 public void MultiplyTransform (Matrix matrix)
1529 MultiplyTransform (matrix, MatrixOrder.Prepend);
1532 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
1534 Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject, matrix.nativeMatrix, order);
1535 GDIPlus.CheckStatus (status);
1538 [EditorBrowsable (EditorBrowsableState.Advanced)]
1539 public void ReleaseHdc (IntPtr hdc)
1541 Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
1542 GDIPlus.CheckStatus (status);
1546 [EditorBrowsable (EditorBrowsableState.Advanced)]
1547 public void ReleaseHdcInternal (IntPtr hdc)
1549 throw new NotImplementedException ();
1553 public void ResetClip ()
1555 Status status = GDIPlus.GdipResetClip (nativeObject);
1556 GDIPlus.CheckStatus (status);
1559 public void ResetTransform ()
1561 Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
1562 GDIPlus.CheckStatus (status);
1565 public void Restore (GraphicsState gstate)
1567 Transform = gstate.matrix.Clone ();
1568 Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
1569 GDIPlus.CheckStatus (status);
1573 public void RotateTransform (float angle)
1575 RotateTransform (angle, MatrixOrder.Prepend);
1578 public void RotateTransform (float angle, MatrixOrder order)
1581 Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
1582 GDIPlus.CheckStatus (status);
1585 public GraphicsState Save ()
1587 GraphicsState state = new GraphicsState ();
1588 state.matrix = Transform.Clone ();
1590 Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
1591 GDIPlus.CheckStatus (status);
1593 state.nativeState = saveState;
1597 public void ScaleTransform (float sx, float sy)
1599 ScaleTransform (sx, sy, MatrixOrder.Prepend);
1602 public void ScaleTransform (float sx, float sy, MatrixOrder order)
1604 Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
1605 GDIPlus.CheckStatus (status);
1609 public void SetClip (RectangleF rect)
1611 SetClip (rect, CombineMode.Replace);
1615 public void SetClip (GraphicsPath path)
1617 SetClip (path, CombineMode.Replace);
1621 public void SetClip (Rectangle rect)
1623 SetClip (rect, CombineMode.Replace);
1627 public void SetClip (Graphics g)
1629 SetClip (g, CombineMode.Replace);
1633 public void SetClip (Graphics g, CombineMode combineMode)
1635 Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
1636 GDIPlus.CheckStatus (status);
1640 public void SetClip (Rectangle rect, CombineMode combineMode)
1642 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1643 GDIPlus.CheckStatus (status);
1647 public void SetClip (RectangleF rect, CombineMode combineMode)
1649 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1650 GDIPlus.CheckStatus (status);
1654 public void SetClip (Region region, CombineMode combineMode)
1656 Status status = GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode);
1657 GDIPlus.CheckStatus (status);
1661 public void SetClip (GraphicsPath path, CombineMode combineMode)
1663 Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
1664 GDIPlus.CheckStatus (status);
1668 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
1670 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
1672 Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
1673 GDIPlus.CheckStatus (status);
1675 GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
1679 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
1681 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
1683 Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
1684 GDIPlus.CheckStatus (status);
1686 GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
1690 public void TranslateClip (int dx, int dy)
1692 Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
1693 GDIPlus.CheckStatus (status);
1697 public void TranslateClip (float dx, float dy)
1699 Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
1700 GDIPlus.CheckStatus (status);
1703 public void TranslateTransform (float dx, float dy)
1705 TranslateTransform (dx, dy, MatrixOrder.Prepend);
1709 public void TranslateTransform (float dx, float dy, MatrixOrder order)
1711 Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
1712 GDIPlus.CheckStatus (status);
1715 public Region Clip {
1717 Region reg = new Region();
1718 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
1719 GDIPlus.CheckStatus (status);
1723 SetClip (value, CombineMode.Replace);
1727 public RectangleF ClipBounds {
1729 RectangleF rect = new RectangleF ();
1730 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
1731 GDIPlus.CheckStatus (status);
1736 public CompositingMode CompositingMode {
1738 CompositingMode mode;
1739 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
1740 GDIPlus.CheckStatus (status);
1745 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
1746 GDIPlus.CheckStatus (status);
1751 public CompositingQuality CompositingQuality {
1753 CompositingQuality quality;
1755 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
1756 GDIPlus.CheckStatus (status);
1760 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
1761 GDIPlus.CheckStatus (status);
1769 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
1770 GDIPlus.CheckStatus (status);
1779 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
1780 GDIPlus.CheckStatus (status);
1785 public InterpolationMode InterpolationMode {
1787 InterpolationMode imode = InterpolationMode.Invalid;
1788 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
1789 GDIPlus.CheckStatus (status);
1793 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
1794 GDIPlus.CheckStatus (status);
1798 public bool IsClipEmpty {
1800 bool isEmpty = false;
1802 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
1803 GDIPlus.CheckStatus (status);
1808 public bool IsVisibleClipEmpty {
1810 bool isEmpty = false;
1812 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
1813 GDIPlus.CheckStatus (status);
1818 public float PageScale {
1822 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
1823 GDIPlus.CheckStatus (status);
1827 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
1828 GDIPlus.CheckStatus (status);
1832 public GraphicsUnit PageUnit {
1836 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
1837 GDIPlus.CheckStatus (status);
1841 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
1842 GDIPlus.CheckStatus (status);
1846 public PixelOffsetMode PixelOffsetMode {
1848 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
1850 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
1851 GDIPlus.CheckStatus (status);
1855 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
1856 GDIPlus.CheckStatus (status);
1860 public Point RenderingOrigin {
1863 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
1864 GDIPlus.CheckStatus (status);
1865 return new Point (x, y);
1869 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
1870 GDIPlus.CheckStatus (status);
1874 public SmoothingMode SmoothingMode {
1876 SmoothingMode mode = SmoothingMode.Invalid;
1878 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
1879 GDIPlus.CheckStatus (status);
1884 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
1885 GDIPlus.CheckStatus (status);
1889 public int TextContrast {
1893 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
1894 GDIPlus.CheckStatus (status);
1899 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
1900 GDIPlus.CheckStatus (status);
1904 public TextRenderingHint TextRenderingHint {
1906 TextRenderingHint hint;
1908 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
1909 GDIPlus.CheckStatus (status);
1914 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
1915 GDIPlus.CheckStatus (status);
1919 public Matrix Transform {
1921 Matrix matrix = new Matrix ();
1922 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
1923 GDIPlus.CheckStatus (status);
1927 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
1928 GDIPlus.CheckStatus (status);
1932 public RectangleF VisibleClipBounds {
1936 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
1937 GDIPlus.CheckStatus (status);