/// <summary> /// Initializes a new instance of the <see cref="XGraphicsPath"/> class. /// </summary> public XGraphicsPath(PointF[] points, byte[] types, XFillMode fillMode) { #if GDI this.gdipPath = new GraphicsPath(points, types, (FillMode)fillMode); #endif #if WPF this.pathGeometry = new PathGeometry(); this.pathGeometry.FillRule = FillRule.EvenOdd; #endif }
/// <summary> /// Creates a path geometry from a polygon. /// </summary> public static PolyLineSegment CreatePolyLineSegment(SysPoint[] points, XFillMode fillMode, bool closed) { PolyLineSegment seg = new PolyLineSegment(); int count = points.Length; // For correct drawing the start point of the segment must not be the same as the first point. for (int idx = 1; idx < count; idx++) { seg.Points.Add(new SysPoint(points[idx].X, points[idx].Y)); } #if !SILVERLIGHT && !NETFX_CORE seg.IsStroked = true; #endif return(seg); }
/// <summary> /// Initializes a new instance of the <see cref="XGraphicsPath"/> class. /// </summary> public XGraphicsPath(PointF[] points, byte[] types, XFillMode fillMode) { #if GDI try { Lock.EnterGdiPlus(); _gdipPath = new GraphicsPath(points, types, (FillMode)fillMode); } finally { Lock.ExitGdiPlus(); } #endif #if WPF // Is true only in Hybrid build. _pathGeometry = new PathGeometry(); _pathGeometry.FillRule = FillRule.EvenOdd; #endif }
/// <summary> /// Creates a path geometry form a polygon. /// </summary> public static PathGeometry CreatePolygonGeometry(System.Windows.Point[] points, XFillMode fillMode, bool closed) { PolyLineSegment seg = new PolyLineSegment(); int count = points.Length; // For correct drawing the start point of the segment must not be the same as the first point for (int idx = 1; idx < count; idx++) seg.Points.Add(new System.Windows.Point(points[idx].X, points[idx].Y)); seg.IsStroked = true; PathFigure fig = new PathFigure(); fig.StartPoint = new System.Windows.Point(points[0].X, points[0].Y); fig.Segments.Add(seg); fig.IsClosed = closed; PathGeometry geo = new PathGeometry(); geo.FillRule = fillMode == XFillMode.Winding ? FillRule.Nonzero : FillRule.EvenOdd; geo.Figures.Add(fig); return geo; }
/// <summary> /// Creates a path geometry from a polygon. /// </summary> public static PathGeometry CreatePolygonGeometry(SysPoint[] points, XFillMode fillMode, bool closed) { PolyLineSegment seg = new PolyLineSegment(); int count = points.Length; // For correct drawing the start point of the segment must not be the same as the first point. for (int idx = 1; idx < count; idx++) { seg.Points.Add(new SysPoint(points[idx].X, points[idx].Y)); } #if !SILVERLIGHT && !NETFX_CORE seg.IsStroked = true; #endif PathFigure fig = new PathFigure(); fig.StartPoint = new SysPoint(points[0].X, points[0].Y); fig.Segments.Add(seg); fig.IsClosed = closed; PathGeometry geo = new PathGeometry(); geo.FillRule = fillMode == XFillMode.Winding ? FillRule.Nonzero : FillRule.EvenOdd; geo.Figures.Add(fig); return(geo); }
// ----- fill ----- #if GDI /// <summary> /// Draws a polygon defined by an array of points. /// </summary> public void DrawPolygon(XBrush brush, System.Drawing.Point[] points, XFillMode fillmode) { DrawPolygon(brush, MakeXPointArray(points), fillmode); }
/// <summary> /// Draws a polygon defined by an array of points. /// </summary> public void DrawPolygon(XBrush brush, XPoint[] points, XFillMode fillmode) { if (brush == null) throw new ArgumentNullException("brush"); if (points == null) throw new ArgumentNullException("points"); if (points.Length < 2) throw new ArgumentException("points", PSSR.PointArrayAtLeast(2)); if (this.drawGraphics) { #if GDI if (this.targetContext == XGraphicTargetContext.GDI) this.gfx.FillPolygon(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode); #endif #if WPF if (this.targetContext == XGraphicTargetContext.WPF) { this.dc.DrawGeometry(brush.RealizeWpfBrush(), null, GeometryHelper.CreatePolygonGeometry(MakePointArray(points), fillmode, true)); } #endif } if (this.renderer != null) this.renderer.DrawPolygon(null, brush, points, fillmode); }
// ----- fill ----- /// <summary> /// Draws a polygon defined by an array of points. /// </summary> public void DrawPolygon(XBrush brush, Point[] points, XFillMode fillmode) { DrawPolygon(brush, MakePointFArray(points), fillmode); }
public void DrawPolygon(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode) { }
/// <summary> /// Draws a closed cardinal spline defined by an array of points. /// </summary> public void DrawClosedCurve(XPen pen, XBrush brush, System.Windows.Point[] points, XFillMode fillmode) { DrawClosedCurve(pen, brush, MakeXPointArray(points), fillmode, 0.5); }
/// <summary> /// Draws a closed cardinal spline defined by an array of points. /// </summary> public void DrawClosedCurve(XPen pen, XBrush brush, PointF[] points, XFillMode fillmode, double tension) { DrawClosedCurve(pen, brush, MakeXPointArray(points), fillmode, tension); }
/// <summary> /// Draws a polygon defined by an array of points. /// </summary> public void DrawPolygon(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode) { if (pen == null && brush == null) throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush); if (points == null) throw new ArgumentNullException("points"); if (points.Length < 2) throw new ArgumentException("points", PSSR.PointArrayAtLeast(2)); if (this.drawGraphics) { #if GDI if (this.targetContext == XGraphicTargetContext.GDI) { PointF[] pts = MakePointFArray(points); this.gfx.FillPolygon(brush.RealizeGdiBrush(), pts, (FillMode)fillmode); this.gfx.DrawPolygon(pen.RealizeGdiPen(), pts); } #endif #if WPF if (this.targetContext == XGraphicTargetContext.WPF) { System.Windows.Media.Brush wpfBrush = brush != null ? brush.RealizeWpfBrush() : null; System.Windows.Media.Pen wpfPen = brush != null ? pen.RealizeWpfPen() : null; this.dc.DrawGeometry(wpfBrush, wpfPen, GeometryHelper.CreatePolygonGeometry(MakePointArray(points), fillmode, true)); } #endif } if (this.renderer != null) this.renderer.DrawPolygon(pen, brush, points, fillmode); }
/// <summary> /// Draws a closed cardinal spline defined by an array of points. /// </summary> public void DrawClosedCurve(XBrush brush, System.Windows.Point[] points, XFillMode fillmode, double tension) { DrawClosedCurve(null, brush, MakeXPointArray(points), fillmode, tension); }
/// <summary> /// Draws a polygon defined by an array of points. /// </summary> public void DrawPolygon(XPen pen, XBrush brush, System.Windows.Point[] points, XFillMode fillmode) { DrawPolygon(pen, brush, MakeXPointArray(points), fillmode); }
/// <summary> /// Draws a closed cardinal spline defined by an array of points. /// </summary> public void DrawClosedCurve(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode, double tension) { if (pen == null && brush == null) throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush); if (this.drawGraphics) { this.gfx.FillClosedCurve(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode, (float)tension); // The fillmode is not used by DrawClosedCurve this.gfx.DrawClosedCurve(pen.RealizeGdiPen(), MakePointFArray(points), (float)tension, (FillMode)fillmode); } if (this.renderer != null) this.renderer.DrawClosedCurve(pen, brush, points, tension, fillmode); }
/// <summary> /// Draws a closed cardinal spline defined by an array of points. /// </summary> public void DrawClosedCurve(XBrush brush, XPoint[] points, XFillMode fillmode, double tension) { if (brush == null) throw new ArgumentNullException("brush"); if (this.drawGraphics) this.gfx.FillClosedCurve(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode, (float)tension); if (this.renderer != null) this.renderer.DrawClosedCurve(null, brush, points, tension, fillmode); }
/// <summary> /// Draws a polygon defined by an array of points. /// </summary> public void DrawPolygon(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode) { if (pen == null && brush == null) throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush); if (points == null) throw new ArgumentNullException("points"); if (points.Length < 2) throw new ArgumentException("points", PSSR.PointArrayAtLeast(2)); if (this.drawGraphics) { PointF[] pts = MakePointFArray(points); this.gfx.FillPolygon(brush.RealizeGdiBrush(), pts, (FillMode)fillmode); this.gfx.DrawPolygon(pen.RealizeGdiPen(), pts); } if (this.renderer != null) this.renderer.DrawPolygon(pen, brush, points, fillmode); }
/// <summary> /// Draws a polygon defined by an array of points. /// </summary> public void DrawPolygon(XBrush brush, XPoint[] points, XFillMode fillmode) { if (brush == null) throw new ArgumentNullException("brush"); if (points == null) throw new ArgumentNullException("points"); if (points.Length < 2) throw new ArgumentException("points", PSSR.PointArrayAtLeast(2)); if (this.drawGraphics) this.gfx.FillPolygon(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode); if (this.renderer != null) this.renderer.DrawPolygon(null, brush, points, fillmode); }
/// <summary> /// Draws a polygon defined by an array of points. /// </summary> public void DrawPolygon(XPen pen, XBrush brush, PointF[] points, XFillMode fillmode) { DrawPolygon(pen, brush, MakeXPointArray(points), fillmode); }
/// <summary> /// Initializes a new instance of the <see cref="XGraphicsPath"/> class. /// </summary> public XGraphicsPath(PointF[] points, byte[] types, XFillMode fillMode) { this.gdipPath = new GraphicsPath(points, types, (FillMode)fillMode); }
/// <summary> /// Draws a closed cardinal spline defined by an array of points. /// </summary> public void DrawClosedCurve(XBrush brush, PointF[] points, XFillMode fillmode) { DrawClosedCurve(null, brush, MakeXPointArray(points), fillmode, 0.5); }
// ----- DrawPolygon -------------------------------------------------------------------------- public void DrawPolygon(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode) { Realize(pen, brush); int count = points.Length; if (points.Length < 2) throw new ArgumentException("points", PSSR.PointArrayAtLeast(2)); const string format = Config.SignificantFigures4; AppendFormatPoint("{0:" + format + "} {1:" + format + "} m\n", points[0].X, points[0].Y); for (int idx = 1; idx < count; idx++) AppendFormatPoint("{0:" + format + "} {1:" + format + "} l\n", points[idx].X, points[idx].Y); AppendStrokeFill(pen, brush, fillmode, true); }
/// <summary> /// Draws a closed cardinal spline defined by an array of points. /// </summary> public void DrawClosedCurve(XBrush brush, XPoint[] points, XFillMode fillmode, double tension) { DrawClosedCurve(null, brush, points, fillmode, tension); // if (brush == null) // throw new ArgumentNullException("brush"); // if (this.drawGraphics) // { //#if GDI // if (this.targetContext == XGraphicTargetContext.GDI) // this.gfx.FillClosedCurve(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode, (float)tension); //#endif //#if WPF // if (this.targetContext == XGraphicTargetContext.WPF) // { // // throw new NotImplementedException("TODO"); // } //#endif // } // if (this.renderer != null) // this.renderer.DrawClosedCurve(null, brush, points, tension, fillmode); }
void AppendStrokeFill(XPen pen, XBrush brush, XFillMode fillMode, bool closePath) { if (closePath) this.content.Append("h "); if (fillMode == XFillMode.Winding) { if (pen != null && brush != null) this.content.Append("B\n"); else if (pen != null) this.content.Append("S\n"); else this.content.Append("f\n"); } else { if (pen != null && brush != null) this.content.Append("B*\n"); else if (pen != null) this.content.Append("S\n"); else this.content.Append("f*\n"); } }
/// <summary> /// Draws a closed cardinal spline defined by an array of points. /// </summary> public void DrawClosedCurve(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode) { DrawClosedCurve(pen, brush, points, fillmode, 0.5); }
// ----- DrawPolygon -------------------------------------------------------------------------- public void DrawPolygon(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode) { Realize(pen, brush); int count = points.Length; if (points.Length < 2) throw new ArgumentException("points", PSSR.PointArrayAtLeast(2)); AppendFormat("{0:0.####} {1:0.####} m\n", points[0].X, points[0].Y); for (int idx = 1; idx < count; idx++) AppendFormat("{0:0.####} {1:0.####} l\n", points[idx].X, points[idx].Y); AppendStrokeFill(pen, brush, fillmode, true); }
/// <summary> /// Draws a closed cardinal spline defined by an array of points. /// </summary> public void DrawClosedCurve(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode, double tension) { if (pen == null && brush == null) throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush); int count = points.Length; if (count == 0) return; if (count < 2) throw new ArgumentException("Not enough points.", "points"); if (this.drawGraphics) { #if GDI if (this.targetContext == XGraphicTargetContext.GDI) { if (brush != null) this.gfx.FillClosedCurve(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode, (float)tension); if (pen != null) { // The fillmode is not used by DrawClosedCurve this.gfx.DrawClosedCurve(pen.RealizeGdiPen(), MakePointFArray(points), (float)tension, (FillMode)fillmode); } } #endif #if WPF if (this.targetContext == XGraphicTargetContext.WPF) { #if !SILVERLIGHT tension /= 3; // Simply tried out. Not proofed why it is correct. PathFigure figure = new PathFigure(); figure.IsClosed = true; figure.StartPoint = new System.Windows.Point(points[0].x, points[0].y); if (count == 2) { figure.Segments.Add(GeometryHelper.CreateCurveSegment(points[0], points[0], points[1], points[1], tension)); } else { figure.Segments.Add(GeometryHelper.CreateCurveSegment(points[count - 1], points[0], points[1], points[2], tension)); for (int idx = 1; idx < count - 2; idx++) figure.Segments.Add(GeometryHelper.CreateCurveSegment(points[idx - 1], points[idx], points[idx + 1], points[idx + 2], tension)); figure.Segments.Add(GeometryHelper.CreateCurveSegment(points[count - 3], points[count - 2], points[count - 1], points[0], tension)); figure.Segments.Add(GeometryHelper.CreateCurveSegment(points[count - 2], points[count - 1], points[0], points[1], tension)); } PathGeometry geo = new PathGeometry(); geo.FillRule = fillmode == XFillMode.Alternate ? FillRule.EvenOdd : FillRule.Nonzero; geo.Figures.Add(figure); System.Windows.Media.Brush wpfBrush = brush != null ? brush.RealizeWpfBrush() : null; System.Windows.Media.Pen wpfPen = pen != null ? pen.RealizeWpfPen() : null; this.dc.DrawGeometry(wpfBrush, wpfPen, geo); #else // AGHACK #endif } #endif } if (this.renderer != null) this.renderer.DrawClosedCurve(pen, brush, points, tension, fillmode); }
// ----- DrawClosedCurve ---------------------------------------------------------------------- public void DrawClosedCurve(XPen pen, XBrush brush, XPoint[] points, double tension, XFillMode fillmode) { int count = points.Length; if (count == 0) return; if (count < 2) throw new ArgumentException("Not enough points", "points"); // Simply tried out. Not proofed why it is correct. tension /= 3; Realize(pen, brush); AppendFormat("{0:0.####} {1:0.####} m\n", points[0].X, points[0].Y); if (count == 2) { // Just draws a line... AppendCurveSegment(points[0], points[0], points[1], points[1], tension); } else { AppendCurveSegment(points[count - 1], points[0], points[1], points[2], tension); for (int idx = 1; idx < count - 2; idx++) AppendCurveSegment(points[idx - 1], points[idx], points[idx + 1], points[idx + 2], tension); AppendCurveSegment(points[count - 3], points[count - 2], points[count - 1], points[0], tension); AppendCurveSegment(points[count - 2], points[count - 1], points[0], points[1], tension); } AppendStrokeFill(pen, brush, fillmode, true); }
/// <summary> /// Creates a path geometry from a polygon. /// </summary> public static PolyLineSegment CreatePolyLineSegment(SysPoint[] points, XFillMode fillMode, bool closed) { PolyLineSegment seg = new PolyLineSegment(); int count = points.Length; // For correct drawing the start point of the segment must not be the same as the first point. for (int idx = 1; idx < count; idx++) seg.Points.Add(new SysPoint(points[idx].X, points[idx].Y)); #if !SILVERLIGHT && !NETFX_CORE seg.IsStroked = true; #endif return seg; }
public void DrawClosedCurve(XPen pen, XBrush brush, XPoint[] points, double tension, XFillMode fillmode) { }