| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- //
- // System.Drawing.Drawing2D.GraphicsPath.cs
- //
- // Authors:
- //
- // Miguel de Icaza ([email protected])
- // Duncan Mak ([email protected])
- //
- // (C) 2004 Novell, Inc
- //
- using System;
- using System.Drawing;
- using System.Runtime.InteropServices;
- namespace System.Drawing.Drawing2D
- {
- public sealed class GraphicsPath : MarshalByRefObject, ICloneable, IDisposable {
- internal IntPtr nativePath;
- GraphicsPath (IntPtr ptr)
- {
- nativePath = ptr;
- }
-
- public GraphicsPath ()
- {
- GDIPlus.GdipCreatePath (FillMode.Alternate, out nativePath);
- }
-
- public object Clone ()
- {
- IntPtr clone;
- GDIPlus.GdipClonePath (nativePath, out clone);
- return new GraphicsPath (clone);
- }
- public void Dispose ()
- {
- Dispose (true);
- System.GC.SuppressFinalize (this);
- }
- ~GraphicsPath ()
- {
- Dispose (false);
- }
-
- void Dispose (bool disposing)
- {
-
- }
- public FillMode FillMode {
- get {
- FillMode mode;
- GDIPlus.GdipGetPathFillMode (nativePath, out mode);
- return mode;
- }
- set {
- GDIPlus.GdipSetPathFillMode (nativePath, value);
- }
- }
- public PathData PathData {
- get {
- IntPtr tmp;
- GDIPlus.GdipGetPathData (nativePath, out tmp);
- throw new Exception ();
- }
- }
- public PointF [] PathPoints {
- get {
- int count;
-
- GDIPlus.GdipGetPointCount (nativePath, out count);
- PointF [] points = new PointF [count];
- GDIPlus.GdipGetPathPoints (nativePath, points, count);
- return points;
- }
- }
- public byte [] PathTypes {
- get {
- int count;
- GDIPlus.GdipGetPointCount (nativePath, out count);
- byte [] types = new byte [count];
- GDIPlus.GdipGetPathTypes (nativePath, types, count);
- return types;
- }
- }
- public int PointCount {
- get {
- int count;
- GDIPlus.GdipGetPointCount (nativePath, out count);
- return count;
- }
- }
-
- internal IntPtr NativeObject{
-
- get{
- return nativePath;
- }
- set {
- nativePath = value;
- }
- }
-
- //
- // AddArc
- //
- public void AddArc (Rectangle rect, float start_angle, float sweep_angle)
- {
- GDIPlus.GdipAddPathArcI (nativePath, rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);
- }
- public void AddArc (RectangleF rect, float start_angle, float sweep_angle)
- {
- GDIPlus.GdipAddPathArc (nativePath, rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);
- }
- public void AddArc (int x, int y, int width, int height, float start_angle, float sweep_angle)
- {
- GDIPlus.GdipAddPathArcI (nativePath, x, y, width, height, start_angle, sweep_angle);
- }
- public void AddArc (float x, float y, float width, float height, float start_angle, float sweep_angle)
- {
- GDIPlus.GdipAddPathArc (nativePath, x, y, width, height, start_angle, sweep_angle);
- }
- //
- // AddBezier
- //
- public void AddBezier (Point pt1, Point pt2, Point pt3, Point pt4)
- {
- GDIPlus.GdipAddPathBezierI (nativePath, pt1.X, pt1.Y,
- pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
- }
- public void AddBezier (PointF pt1, PointF pt2, PointF pt3, PointF pt4)
- {
- GDIPlus.GdipAddPathBezier (nativePath, pt1.X, pt1.Y,
- pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
- }
- public void AddBezier (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
- {
- GDIPlus.GdipAddPathBezierI (nativePath, x1, y1, x2, y2, x3, y3, x4, y4);
- }
- public void AddBezier (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
- {
- GDIPlus.GdipAddPathBezier (nativePath, x1, y1, x2, y2, x3, y3, x4, y4);
- }
- //
- // AddBeziers
- //
- public void AddBeziers (Point [] pts)
- {
- GDIPlus.GdipAddPathBeziersI (nativePath, pts, pts.Length);
- }
- public void AddBeziers (PointF [] pts)
- {
- GDIPlus.GdipAddPathBeziers (nativePath, pts, pts.Length);
- }
- //
- // AddEllipse
- //
- public void AddEllipse (RectangleF r)
- {
- GDIPlus.GdipAddPathEllipse (nativePath, r.X, r.Y, r.Width, r.Height);
- }
-
- public void AddEllipse (float x, float y, float width, float height)
- {
- GDIPlus.GdipAddPathEllipse (nativePath, x, y, width, height);
- }
- public void AddEllipse (Rectangle r)
- {
- GDIPlus.GdipAddPathEllipseI (nativePath, r.X, r.Y, r.Width, r.Height);
- }
-
- public void AddEllipse (int x, int y, int width, int height)
- {
- GDIPlus.GdipAddPathEllipseI (nativePath, x, y, width, height);
- }
-
- //
- // AddLine
- //
- public void AddLine (Point a, Point b)
- {
- GDIPlus.GdipAddPathLineI (nativePath, a.X, a.Y, b.X, b.Y);
- }
- public void AddLine (PointF a, PointF b)
- {
- GDIPlus.GdipAddPathLine (nativePath, a.X, a.Y, b.X,
- b.Y);
- }
- public void AddLine (int x1, int y1, int x2, int y2)
- {
- GDIPlus.GdipAddPathLineI (nativePath, x1, y1, x2, y2);
- }
- public void AddLine (float x1, float y1, float x2, float y2)
- {
- GDIPlus.GdipAddPathLine (nativePath, x1, y1, x2,
- y2);
- }
- //
- // AddLines
- //
- public void AddLines (Point [] points)
- {
- int length = points.Length;
- for (int i = 0; i < length - 2; i += 2) {
- int j = i + 1;
- GDIPlus.GdipAddPathLineI (nativePath, points [i].X, points [i].Y, points [j].X, points [j].Y);
- }
- }
- public void AddLines (PointF [] points)
- {
- int length = points.Length;
- for (int i = 0; i < length - 2; i += 2) {
- int j = i + 1;
- GDIPlus.GdipAddPathLine (nativePath, points [i].X, points [i].Y, points [j].X, points [j].Y);
- }
- }
-
- //
- // AddPie
- //
- public void AddPie (Rectangle rect, float startAngle, float sweepAngle)
- {
- GDIPlus.GdipAddPathPie (nativePath, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
- }
- public void AddPie (int x, int y, int width, int height, float startAngle, float sweepAngle)
- {
- GDIPlus.GdipAddPathPie (nativePath, x, y, width, height, startAngle, sweepAngle);
- }
- public void AddPie (float x, float y, float width, float height, float startAngle, float sweepAngle)
- {
- GDIPlus.GdipAddPathPie (nativePath, x, y, width, height, startAngle, sweepAngle);
- }
- //
- // AddPolygon
- //
- public void AddPolygon (Point [] points)
- {
- GDIPlus.GdipAddPathPolygonI (nativePath, points, points.Length);
- }
- public void AddPolygon (PointF [] points)
- {
- GDIPlus.GdipAddPathPolygon (nativePath, points, points.Length);
- }
- //
- // AddRectangle
- //
- public void AddRectangle (Rectangle rect)
- {
- GDIPlus.GdipAddPathRectangleI (nativePath, rect.X, rect.Y, rect.Width, rect.Height);
- }
- public void AddRectangle (RectangleF rect)
- {
- GDIPlus.GdipAddPathRectangle (nativePath, rect.X, rect.Y, rect.Width, rect.Height);
- }
- //
- // AddRectangles
- //
- public void AddRectangles (Rectangle [] rects)
- {
- GDIPlus.GdipAddPathRectanglesI (nativePath, rects, rects.Length);
- }
- public void AddRectangles (RectangleF [] rects)
- {
- GDIPlus.GdipAddPathRectangles (nativePath, rects, rects.Length);
- }
- //
- // AddPath
- //
- public void AddPath (GraphicsPath addingPath, bool connect)
- {
- GDIPlus.GdipAddPathPath (nativePath, addingPath.nativePath, connect);
- }
- public PointF GetLastPoint ()
- {
- PointF pt;
- GDIPlus.GdipGetPathLastPoint (nativePath, out pt);
- return pt;
- }
- public void Reset ()
- {
- GDIPlus.GdipResetPath (nativePath);
- }
- public void Reverse ()
- {
- GDIPlus.GdipReversePath (nativePath);
- }
- public void Transform (Matrix matrix)
- {
- GDIPlus.GdipTransformPath (nativePath, matrix.nativeMatrix);
- }
- }
- }
|