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)
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using System.Drawing.Drawing2D;
36 using System.Drawing.Imaging;
37 using System.Drawing.Text;
38 using System.ComponentModel;
39 using System.Runtime.InteropServices;
42 namespace System.Drawing
45 public sealed class Graphics : MarshalByRefObject, IDisposable
47 internal IntPtr nativeObject = IntPtr.Zero;
48 private bool disposed = false;
49 private static float defDpiX = 0;
50 private static float defDpiY = 0;
53 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
57 PlayRecordCallback callbackData);
60 public delegate bool DrawImageAbort (IntPtr callbackData);
62 private Graphics (IntPtr nativeGraphics)
64 nativeObject = nativeGraphics;
72 static internal float systemDpiX {
75 Bitmap bmp = new Bitmap(1,1);
76 Graphics g = Graphics.FromImage(bmp);
83 static internal float systemDpiY {
86 Bitmap bmp = new Bitmap(1,1);
87 Graphics g = Graphics.FromImage(bmp);
94 internal IntPtr NativeObject {
100 nativeObject = value;
105 public void AddMetafileComment (byte [] data)
107 throw new NotImplementedException ();
111 public GraphicsContainer BeginContainer ()
115 status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
116 GDIPlus.CheckStatus (status);
118 return new GraphicsContainer(state);
121 public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
125 status = GDIPlus.GdipBeginContainerI (nativeObject, dstrect, srcrect, unit, out state);
126 GDIPlus.CheckStatus (status);
128 return new GraphicsContainer (state);
132 public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
136 status = GDIPlus.GdipBeginContainer (nativeObject, dstrect, srcrect, unit, out state);
137 GDIPlus.CheckStatus (status);
139 return new GraphicsContainer (state);
143 public void Clear (Color color)
146 status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ()); GDIPlus.CheckStatus (status);
149 public void Dispose ()
155 status = GDIPlus.GdipDeleteGraphics (nativeObject);
156 GDIPlus.CheckStatus (status);
163 public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
165 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
169 public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
171 DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
175 public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
178 status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
179 x, y, width, height, startAngle, sweepAngle);
180 GDIPlus.CheckStatus (status);
183 // Microsoft documentation states that the signature for this member should be
184 // public void DrawArc( Pen pen, int x, int y, int width, int height, int startAngle,
185 // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
186 public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
189 status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
190 x, y, width, height, startAngle, sweepAngle);
191 GDIPlus.CheckStatus (status);
194 public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
197 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
198 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
199 pt3.Y, pt4.X, pt4.Y);
200 GDIPlus.CheckStatus (status);
203 public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
206 status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
207 pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
208 pt3.Y, pt4.X, pt4.Y);
209 GDIPlus.CheckStatus (status);
212 public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
215 status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
216 y1, x2, y2, x3, y3, x4, y4);
217 GDIPlus.CheckStatus (status);
220 public void DrawBeziers (Pen pen, Point [] points)
222 int length = points.Length;
228 for (int i = 0; i < length; i += 3) {
229 Point p1 = points [i];
230 Point p2 = points [i + 1];
231 Point p3 = points [i + 2];
232 Point p4 = points [i + 3];
234 status = GDIPlus.GdipDrawBezier (nativeObject,
236 p1.X, p1.Y, p2.X, p2.Y,
237 p3.X, p3.Y, p4.X, p4.Y);
238 GDIPlus.CheckStatus (status);
242 public void DrawBeziers (Pen pen, PointF [] points)
244 int length = points.Length;
250 for (int i = 0; i < length; i += 3) {
251 PointF p1 = points [i];
252 PointF p2 = points [i + 1];
253 PointF p3 = points [i + 2];
254 PointF p4 = points [i + 3];
256 status = GDIPlus.GdipDrawBezier (nativeObject,
258 p1.X, p1.Y, p2.X, p2.Y,
259 p3.X, p3.Y, p4.X, p4.Y);
260 GDIPlus.CheckStatus (status);
265 public void DrawClosedCurve (Pen pen, PointF [] points)
268 status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
269 GDIPlus.CheckStatus (status);
272 public void DrawClosedCurve (Pen pen, Point [] points)
275 status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
276 GDIPlus.CheckStatus (status);
279 public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
282 status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
283 GDIPlus.CheckStatus (status);
286 public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
289 status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
290 GDIPlus.CheckStatus (status);
293 public void DrawCurve (Pen pen, Point [] points)
296 status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
297 GDIPlus.CheckStatus (status);
300 public void DrawCurve (Pen pen, PointF [] points)
303 status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
304 GDIPlus.CheckStatus (status);
307 public void DrawCurve (Pen pen, PointF [] points, float tension)
310 status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
311 GDIPlus.CheckStatus (status);
314 public void DrawCurve (Pen pen, Point [] points, float tension)
317 status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
318 GDIPlus.CheckStatus (status);
322 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
325 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
326 points, points.Length, offset,
327 numberOfSegments, 0.5f);
328 GDIPlus.CheckStatus (status);
331 public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
334 status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
335 points, points.Length, offset,
336 numberOfSegments, tension);
337 GDIPlus.CheckStatus (status);
341 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
344 status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
345 points, points.Length, offset,
346 numberOfSegments, tension);
347 GDIPlus.CheckStatus (status);
350 public void DrawEllipse (Pen pen, Rectangle rect)
352 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
355 public void DrawEllipse (Pen pen, RectangleF rect)
357 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
360 public void DrawEllipse (Pen pen, int x, int y, int width, int height)
363 status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
364 GDIPlus.CheckStatus (status);
367 public void DrawEllipse (Pen pen, float x, float y, float width, float height)
369 Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
370 GDIPlus.CheckStatus (status);
374 public void DrawIcon (Icon icon, Rectangle targetRect)
376 throw new NotImplementedException ();
380 public void DrawIcon (Icon icon, int x, int y)
382 throw new NotImplementedException ();
386 public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
388 throw new NotImplementedException ();
391 public void DrawImage (Image image, RectangleF rect)
393 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
394 GDIPlus.CheckStatus (status);
398 public void DrawImage (Image image, PointF point)
400 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
401 GDIPlus.CheckStatus (status);
405 public void DrawImage (Image image, Point [] destPoints)
407 Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
408 GDIPlus.CheckStatus (status);
412 public void DrawImage (Image image, Point point)
414 DrawImage (image, point.X, point.Y);
418 public void DrawImage (Image image, Rectangle rect)
420 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
424 public void DrawImage (Image image, PointF [] destPoints)
426 Status status = GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
427 GDIPlus.CheckStatus (status);
431 public void DrawImage (Image image, int x, int y)
433 Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
434 GDIPlus.CheckStatus (status);
438 public void DrawImage (Image image, float x, float y)
440 Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
441 GDIPlus.CheckStatus (status);
445 public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
447 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
448 destRect.X, destRect.Y, destRect.Width, destRect.Height,
449 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
450 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
451 GDIPlus.CheckStatus (status);
454 public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
456 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
457 destRect.X, destRect.Y, destRect.Width, destRect.Height,
458 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
459 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
460 GDIPlus.CheckStatus (status);
464 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
466 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
467 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
468 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
470 GDIPlus.CheckStatus (status);
474 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
477 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
478 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
479 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
481 GDIPlus.CheckStatus (status);
485 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
486 ImageAttributes imageAttr)
488 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
489 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
490 srcRect.Width, srcRect.Height, srcUnit,
491 imageAttr.NativeObject, null, IntPtr.Zero);
492 GDIPlus.CheckStatus (status);
495 public void DrawImage (Image image, float x, float y, float width, float height)
497 Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
499 GDIPlus.CheckStatus (status);
503 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
504 ImageAttributes imageAttr)
506 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
507 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
508 srcRect.Width, srcRect.Height, srcUnit,
509 imageAttr.NativeObject, null, IntPtr.Zero);
510 GDIPlus.CheckStatus (status);
514 public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
516 Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
517 GDIPlus.CheckStatus (status);
520 public void DrawImage (Image image, int x, int y, int width, int height)
522 Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
523 GDIPlus.CheckStatus (status);
526 public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
528 Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
529 GDIPlus.CheckStatus (status);
533 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
535 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
536 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
537 srcRect.Width, srcRect.Height, srcUnit,
538 imageAttr.NativeObject, callback, IntPtr.Zero);
539 GDIPlus.CheckStatus (status);
543 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
546 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
547 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
548 srcRect.Width, srcRect.Height, srcUnit,
549 imageAttr.NativeObject, callback, IntPtr.Zero);
550 GDIPlus.CheckStatus (status);
554 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
557 Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
558 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
559 srcRect.Width, srcRect.Height, srcUnit,
560 imageAttr.NativeObject, callback, (IntPtr) callbackData);
561 GDIPlus.CheckStatus (status);
565 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
567 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
568 destRect.X, destRect.Y, destRect.Width, destRect.Height,
569 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
571 GDIPlus.CheckStatus (status);
574 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
576 Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
577 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
578 srcRect.Width, srcRect.Height, srcUnit,
579 imageAttr.NativeObject, callback, (IntPtr) callbackData);
580 GDIPlus.CheckStatus (status);
584 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
586 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
587 destRect.X, destRect.Y, destRect.Width, destRect.Height,
588 srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
590 GDIPlus.CheckStatus (status);
594 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
596 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
597 destRect.X, destRect.Y, destRect.Width, destRect.Height,
598 srcX, srcY, srcWidth, srcHeight, srcUnit,
599 imageAttrs.NativeObject, null, IntPtr.Zero);
600 GDIPlus.CheckStatus (status);
603 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
605 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
606 destRect.X, destRect.Y, destRect.Width,
607 destRect.Height, srcX, srcY, srcWidth, srcHeight,
608 srcUnit, imageAttr.NativeObject, null, IntPtr.Zero);
609 GDIPlus.CheckStatus (status);
612 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
614 Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
615 destRect.X, destRect.Y, destRect.Width,
616 destRect.Height, srcX, srcY, srcWidth, srcHeight,
617 srcUnit, imageAttr.NativeObject, callback,
619 GDIPlus.CheckStatus (status);
622 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
624 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
625 destRect.X, destRect.Y, destRect.Width,
626 destRect.Height, srcX, srcY, srcWidth, srcHeight,
627 srcUnit, imageAttr.NativeObject,
628 callback, IntPtr.Zero);
629 GDIPlus.CheckStatus (status);
633 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
635 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
636 destRect.X, destRect.Y, destRect.Width, destRect.Height,
637 srcX, srcY, srcWidth, srcHeight, srcUnit,
638 imageAttr.NativeObject, callback, callbackData);
639 GDIPlus.CheckStatus (status);
643 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
645 Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
646 destRect.X, destRect.Y, destRect.Width, destRect.Height,
647 srcX, srcY, srcWidth, srcHeight, srcUnit,
648 imageAttr.NativeObject, callback, callbackData);
649 GDIPlus.CheckStatus (status);
652 public void DrawImageUnscaled (Image image, Point point)
654 DrawImage(image, point.X, point.Y);
657 public void DrawImageUnscaled (Image image, Rectangle rect)
659 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
662 public void DrawImageUnscaled (Image image, int x, int y)
664 DrawImage(image, x, y);
667 public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
669 DrawImage(image, x, y, width, height);
672 public void DrawLine (Pen pen, PointF pt1, PointF pt2)
674 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
675 pt1.X, pt1.Y, pt2.X, pt2.Y);
676 GDIPlus.CheckStatus (status);
679 public void DrawLine (Pen pen, Point pt1, Point pt2)
681 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
682 pt1.X, pt1.Y, pt2.X, pt2.Y);
683 GDIPlus.CheckStatus (status);
686 public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
688 Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
689 GDIPlus.CheckStatus (status);
692 public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
694 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
695 GDIPlus.CheckStatus (status);
698 public void DrawLines (Pen pen, PointF [] points)
700 Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
701 GDIPlus.CheckStatus (status);
704 public void DrawLines (Pen pen, Point [] points)
706 Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
707 GDIPlus.CheckStatus (status);
710 public void DrawPath (Pen pen, GraphicsPath path)
712 Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
713 GDIPlus.CheckStatus (status);
716 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
718 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
721 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
723 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
726 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
728 Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
729 GDIPlus.CheckStatus (status);
732 // Microsoft documentation states that the signature for this member should be
733 // public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle
734 // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
735 public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
737 Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
738 GDIPlus.CheckStatus (status);
741 public void DrawPolygon (Pen pen, Point [] points)
743 Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
744 GDIPlus.CheckStatus (status);
747 public void DrawPolygon (Pen pen, PointF [] points)
749 Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
750 GDIPlus.CheckStatus (status);
753 internal void DrawRectangle (Pen pen, RectangleF rect)
755 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
758 public void DrawRectangle (Pen pen, Rectangle rect)
760 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
763 public void DrawRectangle (Pen pen, float x, float y, float width, float height)
765 Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
766 GDIPlus.CheckStatus (status);
769 public void DrawRectangle (Pen pen, int x, int y, int width, int height)
771 Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
772 GDIPlus.CheckStatus (status);
775 public void DrawRectangles (Pen pen, RectangleF [] rects)
777 Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
778 GDIPlus.CheckStatus (status);
781 public void DrawRectangles (Pen pen, Rectangle [] rects)
783 Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
784 GDIPlus.CheckStatus (status);
787 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
789 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, IntPtr.Zero, brush.nativeObject);
790 GDIPlus.CheckStatus (status);
793 public void DrawString (string s, Font font, Brush brush, PointF point)
795 RectangleF rc = new RectangleF (point.X, point.Y, 0, 0);
796 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref rc, IntPtr.Zero, brush.nativeObject);
797 GDIPlus.CheckStatus (status);
800 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
802 RectangleF rc = new RectangleF (point.X, point.Y, 0, 0);
803 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref rc, format.NativeObject, brush.nativeObject);
804 GDIPlus.CheckStatus (status);
807 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
809 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format.NativeObject, brush.nativeObject);
810 GDIPlus.CheckStatus (status);
813 public void DrawString (string s, Font font, Brush brush, float x, float y)
815 RectangleF rc = new RectangleF (x, y, 0, 0);
817 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject,
818 ref rc, IntPtr.Zero, brush.nativeObject);
819 GDIPlus.CheckStatus (status);
822 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
824 RectangleF rc = new RectangleF (x, y, 0, 0);
826 Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject,
827 ref rc, format.NativeObject, brush.nativeObject);
828 GDIPlus.CheckStatus (status);
832 public void EndContainer (GraphicsContainer container)
834 Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
835 GDIPlus.CheckStatus (status);
839 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
841 throw new NotImplementedException ();
845 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
847 throw new NotImplementedException ();
851 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
853 throw new NotImplementedException ();
857 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
859 throw new NotImplementedException ();
863 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
865 throw new NotImplementedException ();
869 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
871 throw new NotImplementedException ();
875 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
877 throw new NotImplementedException ();
881 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
883 throw new NotImplementedException ();
887 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
889 throw new NotImplementedException ();
893 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
895 throw new NotImplementedException ();
899 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
901 throw new NotImplementedException ();
905 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
907 throw new NotImplementedException ();
911 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
913 throw new NotImplementedException ();
917 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
919 throw new NotImplementedException ();
923 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
925 throw new NotImplementedException ();
929 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
931 throw new NotImplementedException ();
935 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
937 throw new NotImplementedException ();
941 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
943 throw new NotImplementedException ();
947 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
949 throw new NotImplementedException ();
953 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
955 throw new NotImplementedException ();
959 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
961 throw new NotImplementedException ();
965 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
967 throw new NotImplementedException ();
971 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
973 throw new NotImplementedException ();
977 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
979 throw new NotImplementedException ();
983 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
985 throw new NotImplementedException ();
989 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
991 throw new NotImplementedException ();
995 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
997 throw new NotImplementedException ();
1001 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1003 throw new NotImplementedException ();
1007 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1009 throw new NotImplementedException ();
1013 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1015 throw new NotImplementedException ();
1019 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1021 throw new NotImplementedException ();
1025 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1027 throw new NotImplementedException ();
1031 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1033 throw new NotImplementedException ();
1037 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1039 throw new NotImplementedException ();
1043 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1045 throw new NotImplementedException ();
1049 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1051 throw new NotImplementedException ();
1054 public void ExcludeClip (Rectangle rect)
1056 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
1057 GDIPlus.CheckStatus (status);
1060 public void ExcludeClip (Region region)
1062 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
1063 GDIPlus.CheckStatus (status);
1067 public void FillClosedCurve (Brush brush, PointF [] points)
1069 Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
1070 GDIPlus.CheckStatus (status);
1074 public void FillClosedCurve (Brush brush, Point [] points)
1076 Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
1077 GDIPlus.CheckStatus (status);
1081 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
1083 FillClosedCurve (brush, points, fillmode, 0.5f);
1086 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
1088 FillClosedCurve (brush, points, fillmode, 0.5f);
1091 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
1093 Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1094 GDIPlus.CheckStatus (status);
1097 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
1099 Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
1100 GDIPlus.CheckStatus (status);
1103 public void FillEllipse (Brush brush, Rectangle rect)
1105 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1108 public void FillEllipse (Brush brush, RectangleF rect)
1110 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1113 public void FillEllipse (Brush brush, float x, float y, float width, float height)
1115 Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
1116 GDIPlus.CheckStatus (status);
1119 public void FillEllipse (Brush brush, int x, int y, int width, int height)
1121 Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
1122 GDIPlus.CheckStatus (status);
1125 public void FillPath (Brush brush, GraphicsPath path)
1127 Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
1128 GDIPlus.CheckStatus (status);
1131 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
1133 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1134 GDIPlus.CheckStatus (status);
1137 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
1139 Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1140 GDIPlus.CheckStatus (status);
1143 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
1145 Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
1146 GDIPlus.CheckStatus (status);
1149 public void FillPolygon (Brush brush, PointF [] points)
1151 Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
1152 GDIPlus.CheckStatus (status);
1155 public void FillPolygon (Brush brush, Point [] points)
1157 Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
1158 GDIPlus.CheckStatus (status);
1161 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
1163 Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1164 GDIPlus.CheckStatus (status);
1167 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
1169 Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
1170 GDIPlus.CheckStatus (status);
1173 public void FillRectangle (Brush brush, RectangleF rect)
1175 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1178 public void FillRectangle (Brush brush, Rectangle rect)
1180 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1183 public void FillRectangle (Brush brush, int x, int y, int width, int height)
1185 Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
1186 GDIPlus.CheckStatus (status);
1189 public void FillRectangle (Brush brush, float x, float y, float width, float height)
1191 Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
1192 GDIPlus.CheckStatus (status);
1195 public void FillRectangles (Brush brush, Rectangle [] rects)
1197 Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
1198 GDIPlus.CheckStatus (status);
1201 public void FillRectangles (Brush brush, RectangleF [] rects)
1203 Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
1204 GDIPlus.CheckStatus (status);
1208 public void FillRegion (Brush brush, Region region)
1210 Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);
1211 GDIPlus.CheckStatus(status);
1215 public void Flush ()
1217 Flush (FlushIntention.Flush);
1221 public void Flush (FlushIntention intention)
1223 Status status = GDIPlus.GdipFlush (nativeObject, intention);
1224 GDIPlus.CheckStatus (status);
1227 [EditorBrowsable (EditorBrowsableState.Advanced)]
1228 public static Graphics FromHdc (IntPtr hdc)
1231 Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics); GDIPlus.CheckStatus (status);
1233 Graphics result = new Graphics ((IntPtr) graphics);
1238 [EditorBrowsable (EditorBrowsableState.Advanced)]
1239 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1241 throw new NotImplementedException ();
1245 [EditorBrowsable (EditorBrowsableState.Advanced)]
1246 public static Graphics FromHdcInternal (IntPtr hdc)
1248 throw new NotImplementedException ();
1251 [EditorBrowsable (EditorBrowsableState.Advanced)]
1252 public static Graphics FromHwnd (IntPtr hwnd)
1256 Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics); GDIPlus.CheckStatus (status);
1258 return new Graphics (graphics);
1262 [EditorBrowsable (EditorBrowsableState.Advanced)]
1263 public static Graphics FromHwndInternal (IntPtr hwnd)
1265 throw new NotImplementedException ();
1268 public static Graphics FromImage (Image image)
1270 lock (typeof (Graphics))
1272 if (image == null) throw new ArgumentException ();
1274 Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
1275 GDIPlus.CheckStatus (status);
1276 Graphics result = new Graphics ((IntPtr) graphics);
1281 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1283 lock (typeof (Graphics))
1286 Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
1287 GDIPlus.CheckStatus (s);
1288 return new Graphics (graphics);
1293 public static IntPtr GetHalftonePalette ()
1295 throw new NotImplementedException ();
1299 [EditorBrowsable (EditorBrowsableState.Advanced)]
1300 public IntPtr GetHdc ()
1303 Status status = GDIPlus.GdipGetDC (nativeObject, out hdc);
1304 GDIPlus.CheckStatus (status);
1306 return (IntPtr) hdc;
1310 public Color GetNearestColor (Color color)
1314 Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
1315 GDIPlus.CheckStatus (status);
1317 return Color.FromArgb (argb);
1321 public void IntersectClip (Region region)
1323 Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
1324 GDIPlus.CheckStatus (status);
1327 public void IntersectClip (RectangleF rect)
1329 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1330 GDIPlus.CheckStatus (status);
1333 public void IntersectClip (Rectangle rect)
1335 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
1336 GDIPlus.CheckStatus (status);
1339 public bool IsVisible (Point point)
1341 bool isVisible = false;
1343 Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
1344 GDIPlus.CheckStatus (status);
1350 public bool IsVisible (RectangleF rect)
1352 bool isVisible = false;
1354 Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1355 GDIPlus.CheckStatus (status);
1360 public bool IsVisible (PointF point)
1362 bool isVisible = false;
1364 Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
1365 GDIPlus.CheckStatus (status);
1370 public bool IsVisible (Rectangle rect)
1372 bool isVisible = false;
1374 Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
1375 GDIPlus.CheckStatus (status);
1380 public bool IsVisible (float x, float y)
1382 return IsVisible (new PointF (x, y));
1385 public bool IsVisible (int x, int y)
1387 return IsVisible (new Point (x, y));
1390 public bool IsVisible (float x, float y, float width, float height)
1392 return IsVisible (new RectangleF (x, y, width, height));
1396 public bool IsVisible (int x, int y, int width, int height)
1398 return IsVisible (new Rectangle (x, y, width, height));
1402 public Region [] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
1404 Region [] result=new Region[stringFormat.GetCharRanges.Length];
1405 string textFragment;
1408 for (int i=0; i<stringFormat.GetCharRanges.Length; i++) {
1409 textFragment=text.Substring(stringFormat.GetCharRanges[i].First, stringFormat.GetCharRanges[i].Length);
1410 fragmentSize=MeasureString(textFragment, font, new SizeF(layoutRect.Width, layoutRect.Height), stringFormat);
1411 result[i]=new Region(new RectangleF(layoutRect.X, layoutRect.Y, layoutRect.X+fragmentSize.Width, layoutRect.Y+fragmentSize.Height));
1418 public SizeF MeasureString (string text, Font font)
1420 return MeasureString (text, font, new Size(0,0));
1424 public SizeF MeasureString (string text, Font font, SizeF layoutArea)
1426 int charactersFitted, linesFilled;
1427 RectangleF boundingBox = new RectangleF ();
1428 RectangleF rect = new RectangleF (0,0,layoutArea.Width, layoutArea.Height);
1430 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1431 font.NativeObject, ref rect, IntPtr.Zero, out boundingBox,
1432 out charactersFitted, out linesFilled);
1433 GDIPlus.CheckStatus (status);
1435 return new SizeF(boundingBox.Width, boundingBox.Height);
1439 public SizeF MeasureString (string text, Font font, int width)
1441 throw new NotImplementedException ();
1445 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat)
1447 int charactersFitted, linesFilled;
1448 return MeasureString (text, font, layoutArea, stringFormat, out charactersFitted, out linesFilled);
1452 public SizeF MeasureString (string text, Font font, int width, StringFormat format)
1454 throw new NotImplementedException ();
1458 public SizeF MeasureString (string text, Font font, PointF origin, StringFormat stringFormat)
1460 RectangleF boundingBox = new RectangleF ();
1461 RectangleF rect = new RectangleF (origin.X, origin.Y, 0,0);
1462 int charactersFitted, linesFilled;
1464 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1465 font.NativeObject, ref rect, stringFormat.NativeObject,
1466 out boundingBox, out charactersFitted, out linesFilled);
1467 GDIPlus.CheckStatus (status);
1469 return new SizeF (boundingBox.Width, boundingBox.Height);
1473 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat, out int charactersFitted, out int linesFilled)
1475 RectangleF boundingBox = new RectangleF ();
1476 RectangleF rect = new RectangleF (0,0,layoutArea.Width, layoutArea.Height);
1477 Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
1478 font.NativeObject, ref rect, stringFormat.NativeObject,
1479 out boundingBox, out charactersFitted, out linesFilled);
1480 GDIPlus.CheckStatus (status);
1482 return new SizeF (boundingBox.Width, boundingBox.Height);
1485 public void MultiplyTransform (Matrix matrix)
1487 MultiplyTransform (matrix, MatrixOrder.Prepend);
1490 public void MultiplyTransform (Matrix matrix, MatrixOrder order)
1492 Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject, matrix.nativeMatrix, order);
1493 GDIPlus.CheckStatus (status);
1496 [EditorBrowsable (EditorBrowsableState.Advanced)]
1497 public void ReleaseHdc (IntPtr hdc)
1499 Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
1500 GDIPlus.CheckStatus (status);
1504 [EditorBrowsable (EditorBrowsableState.Advanced)]
1505 public void ReleaseHdcInternal (IntPtr hdc)
1507 throw new NotImplementedException ();
1511 public void ResetClip ()
1513 Status status = GDIPlus.GdipResetClip (nativeObject);
1514 GDIPlus.CheckStatus (status);
1517 public void ResetTransform ()
1519 Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
1520 GDIPlus.CheckStatus (status);
1523 public void Restore (GraphicsState gstate)
1525 Transform = gstate.matrix.Clone ();
1526 Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
1527 GDIPlus.CheckStatus (status);
1531 public void RotateTransform (float angle)
1533 RotateTransform (angle, MatrixOrder.Prepend);
1536 public void RotateTransform (float angle, MatrixOrder order)
1539 Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
1540 GDIPlus.CheckStatus (status);
1543 public GraphicsState Save ()
1545 GraphicsState state = new GraphicsState ();
1546 state.matrix = Transform.Clone ();
1548 Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
1549 GDIPlus.CheckStatus (status);
1551 state.nativeState = saveState;
1555 public void ScaleTransform (float sx, float sy)
1557 ScaleTransform (sx, sy, MatrixOrder.Prepend);
1560 public void ScaleTransform (float sx, float sy, MatrixOrder order)
1562 Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
1563 GDIPlus.CheckStatus (status);
1567 public void SetClip (RectangleF rect)
1569 SetClip (rect, CombineMode.Replace);
1573 public void SetClip (GraphicsPath path)
1575 SetClip (path, CombineMode.Replace);
1579 public void SetClip (Rectangle rect)
1581 SetClip (rect, CombineMode.Replace);
1585 public void SetClip (Graphics g)
1587 SetClip (g, CombineMode.Replace);
1591 public void SetClip (Graphics g, CombineMode combineMode)
1593 Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
1594 GDIPlus.CheckStatus (status);
1598 public void SetClip (Rectangle rect, CombineMode combineMode)
1600 Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1601 GDIPlus.CheckStatus (status);
1605 public void SetClip (RectangleF rect, CombineMode combineMode)
1607 Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
1608 GDIPlus.CheckStatus (status);
1612 public void SetClip (Region region, CombineMode combineMode)
1614 Status status = GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode);
1615 GDIPlus.CheckStatus (status);
1619 public void SetClip (GraphicsPath path, CombineMode combineMode)
1621 Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
1622 GDIPlus.CheckStatus (status);
1626 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
1628 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
1630 Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
1631 GDIPlus.CheckStatus (status);
1633 GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
1637 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
1639 IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
1641 Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
1642 GDIPlus.CheckStatus (status);
1644 GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
1648 public void TranslateClip (int dx, int dy)
1650 Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
1651 GDIPlus.CheckStatus (status);
1655 public void TranslateClip (float dx, float dy)
1657 Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
1658 GDIPlus.CheckStatus (status);
1661 public void TranslateTransform (float dx, float dy)
1663 TranslateTransform (dx, dy, MatrixOrder.Prepend);
1667 public void TranslateTransform (float dx, float dy, MatrixOrder order)
1669 Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
1670 GDIPlus.CheckStatus (status);
1673 public Region Clip {
1675 Region reg = new Region();
1676 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
1677 GDIPlus.CheckStatus (status);
1681 SetClip (value, CombineMode.Replace);
1685 public RectangleF ClipBounds {
1687 RectangleF rect = new RectangleF ();
1688 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
1689 GDIPlus.CheckStatus (status);
1694 public CompositingMode CompositingMode {
1696 CompositingMode mode;
1697 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
1698 GDIPlus.CheckStatus (status);
1703 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
1704 GDIPlus.CheckStatus (status);
1709 public CompositingQuality CompositingQuality {
1711 CompositingQuality quality;
1713 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
1714 GDIPlus.CheckStatus (status);
1718 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
1719 GDIPlus.CheckStatus (status);
1727 Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
1728 GDIPlus.CheckStatus (status);
1737 Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
1738 GDIPlus.CheckStatus (status);
1743 public InterpolationMode InterpolationMode {
1745 InterpolationMode imode = InterpolationMode.Invalid;
1746 Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
1747 GDIPlus.CheckStatus (status);
1751 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
1752 GDIPlus.CheckStatus (status);
1756 public bool IsClipEmpty {
1758 bool isEmpty = false;
1760 Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
1761 GDIPlus.CheckStatus (status);
1766 public bool IsVisibleClipEmpty {
1768 bool isEmpty = false;
1770 Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
1771 GDIPlus.CheckStatus (status);
1776 public float PageScale {
1780 Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
1781 GDIPlus.CheckStatus (status);
1785 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
1786 GDIPlus.CheckStatus (status);
1790 public GraphicsUnit PageUnit {
1794 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
1795 GDIPlus.CheckStatus (status);
1799 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
1800 GDIPlus.CheckStatus (status);
1804 public PixelOffsetMode PixelOffsetMode {
1806 PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
1808 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
1809 GDIPlus.CheckStatus (status);
1813 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
1814 GDIPlus.CheckStatus (status);
1818 public Point RenderingOrigin {
1821 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
1822 GDIPlus.CheckStatus (status);
1823 return new Point (x, y);
1827 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
1828 GDIPlus.CheckStatus (status);
1832 public SmoothingMode SmoothingMode {
1834 SmoothingMode mode = SmoothingMode.Invalid;
1836 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
1837 GDIPlus.CheckStatus (status);
1842 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
1843 GDIPlus.CheckStatus (status);
1847 public int TextContrast {
1851 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
1852 GDIPlus.CheckStatus (status);
1857 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
1858 GDIPlus.CheckStatus (status);
1862 public TextRenderingHint TextRenderingHint {
1864 TextRenderingHint hint;
1866 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
1867 GDIPlus.CheckStatus (status);
1872 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
1873 GDIPlus.CheckStatus (status);
1877 public Matrix Transform {
1879 Matrix matrix = new Matrix ();
1880 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
1881 GDIPlus.CheckStatus (status);
1885 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
1886 GDIPlus.CheckStatus (status);
1890 public RectangleF VisibleClipBounds {
1894 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
1895 GDIPlus.CheckStatus (status);