DekGenius.com
[ Team LiB ] Previous Section Next Section

GraphicsPathmarshal by reference, disposable

System.Drawing.Drawing2D (system.drawing.dll)sealed class

This class implements a complex graphics path that can be used to encapsulate a number of different drawing elements in a single container. It can be used in conjunction with the System.Drawing.Graphics.DrawPath() and System.Drawing.Graphics.FillPath() members to render outlines or filled shapes. The FillMode specifies the winding mode for filled shapes. If the path is an open shape, the system automatically adds a straight line to close the path if it is to be filled; this does not affect outline drawing.

The path can also be used for hit-testing. The IsOutlineVisible() method will widen the path with the specified pen, and then return a value indicating whether a particular point is to be found under that path. Note that this is non-destructive, whereas the Widen() method followed by IsVisible(), while logically similar, will irreversibly flatten the path first. (See below for information on flattened paths.) In a similar vein, GetBounds() will give you the minimum containing rectangle for the path.

A path consists of one or more figures. A figure is a connected set of drawing objects. A figure is automatically started when the path is created, and you can then use the various AddXXX() methods to insert shapes into the path. Those shapes are not actually inserted as-is, but approximated with a set of straight line or Bezier spline segments.

You then call CloseFigure() if you wish to create a closed shape and start a new figure, or alternatively call StartFigure() to leave the previous figure open, and start a new one. CloseAllFigures() can subsequently be used to close any remaining open figures, if required.

To modify the path, you can apply a Transform(), or alternatively, you can Warp() the actual path, as defined by a rectangle and a parallelogram. This method actually flattens the path into a series of straight line segments and moves those points. As a result, you cannot undo this operation. (See below for information on flattening paths).

You can retrieve the underlying PathData, which consists of a set of Point and PathPointType objects. Alternatively, you can retrieve the PathPoints and PathTypes independently. You can also retrieve the PointCount, the number of elements in those arrays.

One feature that can be particularly useful if you need an efficient means of approximating your complex path for geometric purposes (such as length or area calculations) is the Flatten() method. This returns a set of points representing the straight line segments approximating the line. You can specify how accurate this approximation should be, and the default of 0.25 is sufficient to give you an approximation that is visually difficult to distinguish from the "real thing." Note that you can apply a transform as part of the flattening process so that the approximation can be made in page or device coordinates for best accuracy.

public sealed class GraphicsPath : MarshalByRefObject : ICloneable, IDisposable {
// Public Constructors
   public GraphicsPath();
   public GraphicsPath(FillMode fillMode);
   public GraphicsPath(System.Drawing.Point[  ] pts, byte[ ] types);
   public GraphicsPath(System.Drawing.Point[  ] pts, byte[ ] types, FillMode fillMode);
   public GraphicsPath(System.Drawing.PointF[  ] pts, byte[ ] types);
   public GraphicsPath(System.Drawing.PointF[  ] pts, byte[ ] types, FillMode fillMode);
// Public Instance Properties
   public FillMode FillMode{set; get; }
   public PathData PathData{get; }
   public PointF[ ] PathPoints{get; }
   public byte[ ] PathTypes{get; }
   public int PointCount{get; }
// Public Instance Methods
   public void AddArc(int x, int y, int width, int height, float startAngle, float sweepAngle);
   public void AddArc(System.Drawing.RectangleF rect,
        float startAngle, float sweepAngle);
   public void AddArc(System.Drawing.Rectangle rect,
        float startAngle, float sweepAngle);
   public void AddArc(float x, float y, float width,
        float height, float startAngle, float sweepAngle);
   public void AddBezier(int x1, int y1, int x2, int y2,
        int x3, int y3, int x4, int y4);
   public void AddBezier(System.Drawing.PointF pt1,
        System.Drawing.PointF pt2,
        System.Drawing.PointF pt3,
        System.Drawing.PointF pt4);
   public void AddBezier(System.Drawing.Point pt1,
        System.Drawing.Point pt2, System.Drawing.Point pt3,
        System.Drawing.Point pt4);
   public void AddBezier(float x1, float y1, float x2,
        float y2, float x3, float y3, float x4, float y4);
   public void AddBeziers(System.Drawing.Point[ ] points);
   public void AddBeziers(System.Drawing.PointF[ ] points);
   public void AddClosedCurve(System.Drawing.Point[ ] points);
   public void AddClosedCurve(System.Drawing.Point[ ] points, float tension);
   public void AddClosedCurve(System.Drawing.PointF[ ] points);
   public void AddClosedCurve(System.Drawing.PointF[ ] points, float tension);
   public void AddCurve(System.Drawing.Point[ ] points);
   public void AddCurve(System.Drawing.Point[ ] points, int offset, int numberOfSegments, float tension);
   public void AddCurve(System.Drawing.Point[ ] points, float tension);
   public void AddCurve(System.Drawing.PointF[ ] points);
   public void AddCurve(System.Drawing.PointF[ ] points, int offset, int numberOfSegments, float tension);
   public void AddCurve(System.Drawing.PointF[ ] points, float tension);
   public void AddEllipse(int x, int y, int width, int height);
   public void AddEllipse(System.Drawing.Rectangle rect);
   public void AddEllipse(System.Drawing.RectangleF rect);
   public void AddEllipse(float x, float y, float width, float height);
   public void AddLine(int x1, int y1, int x2, int y2);
   public void AddLine(System.Drawing.PointF pt1, System.Drawing.PointF pt2);
   public void AddLine(System.Drawing.Point pt1, System.Drawing.Point pt2);
   public void AddLine(float x1, float y1, float x2, float y2);
   public void AddLines(System.Drawing.Point[ ] points);
   public void AddLines(System.Drawing.PointF[ ] points);
   public void AddPath(GraphicsPath addingPath, bool connect);
   public void AddPie(int x, int y, int width, int height, float startAngle, float sweepAngle);
   public void AddPie(System.Drawing.Rectangle rect, float startAngle, float sweepAngle);
   public void AddPie(float x, float y, float width, float height, float startAngle, float sweepAngle);
   public void AddPolygon(System.Drawing.Point[ ] points);
   public void AddPolygon(System.Drawing.PointF[ ] points);
   public void AddRectangle(System.Drawing.Rectangle rect);
   public void AddRectangle(System.Drawing.RectangleF rect);
   public void AddRectangles(System.Drawing.Rectangle[ ] rects);
   public void AddRectangles(System.Drawing.RectangleF[ ] rects);
   public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, 
        System.Drawing.PointF origin, System.Drawing.StringFormat format);
   public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, 
        System.Drawing.Point origin, System.Drawing.StringFormat format);
   public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, 
        System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat format);
   public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, 
        System.Drawing.Rectangle layoutRect, System.Drawing.StringFormat format);
   public void ClearMarkers();
   public object Clone();  // implements ICloneable
   public void CloseAllFigures();
   public void CloseFigure();
   public void Dispose();  // implements IDisposable
   public void Flatten();
   public void Flatten(Matrix matrix);
   public void Flatten(Matrix matrix, float flatness);
   public RectangleF GetBounds();
   public RectangleF GetBounds(Matrix matrix);
   public RectangleF GetBounds(Matrix matrix, System.Drawing.Pen pen);
   public PointF GetLastPoint();
   public bool IsOutlineVisible(int x, int y, System.Drawing.Pen pen);
   public bool IsOutlineVisible(int x, int y, System.Drawing.Pen pen, System.Drawing.Graphics graphics);
   public bool IsOutlineVisible(System.Drawing.PointF point, System.Drawing.Pen pen);
   public bool IsOutlineVisible(System.Drawing.PointF pt, System.Drawing.Pen pen, System.Drawing.Graphics graphics);
   public bool IsOutlineVisible(System.Drawing.Point point, System.Drawing.Pen pen);
   public bool IsOutlineVisible(System.Drawing.Point pt, System.Drawing.Pen pen, System.Drawing.Graphics graphics);
   public bool IsOutlineVisible(float x, float y, System.Drawing.Pen pen);
   public bool IsOutlineVisible(float x, float y, System.Drawing.Pen pen, System.Drawing.Graphics graphics);
   public bool IsVisible(int x, int y);
   public bool IsVisible(int x, int y, System.Drawing.Graphics graphics);
   public bool IsVisible(System.Drawing.Point point);
   public bool IsVisible(System.Drawing.PointF point);
   public bool IsVisible(System.Drawing.PointF pt, System.Drawing.Graphics graphics);
   public bool IsVisible(System.Drawing.Point pt, System.Drawing.Graphics graphics);
   public bool IsVisible(float x, float y);
   public bool IsVisible(float x, float y, System.Drawing.Graphics graphics);
   public void Reset();
   public void Reverse();
   public void SetMarkers();
   public void StartFigure();
   public void Transform(Matrix matrix);
   public void Warp(System.Drawing.PointF[ ] destPoints, System.Drawing.RectangleF srcRect);
   public void Warp(System.Drawing.PointF[ ] destPoints, System.Drawing.RectangleF srcRect, Matrix matrix);
   public void Warp(System.Drawing.PointF[ ] destPoints, System.Drawing.RectangleF srcRect, Matrix matrix,
        WarpMode warpMode);
   public void Warp(System.Drawing.PointF[ ] destPoints, System.Drawing.RectangleF srcRect, Matrix matrix,
        WarpMode warpMode, float flatness);
   public void Widen(System.Drawing.Pen pen);
   public void Widen(System.Drawing.Pen pen, Matrix matrix);
   public void Widen(System.Drawing.Pen pen, Matrix matrix, float flatness);
// Protected Instance Methods
   protected override void Finalize();  // overrides object
}

Hierarchy

System.Object System.MarshalByRefObject GraphicsPath(System.ICloneabl, System.IDisposable)

Passed To

Multiple types

    [ Team LiB ] Previous Section Next Section