本文整理汇总了C#中PdfSharp.Drawing.XPen.RealizeGdiPen方法的典型用法代码示例。如果您正苦于以下问题:C# XPen.RealizeGdiPen方法的具体用法?C# XPen.RealizeGdiPen怎么用?C# XPen.RealizeGdiPen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfSharp.Drawing.XPen
的用法示例。
在下文中一共展示了XPen.RealizeGdiPen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBezier
/// <summary>
/// Draws a Bézier spline defined by four points.
/// </summary>
public void DrawBezier(XPen pen, double x1, double y1, double x2, double y2,
double x3, double y3, double x4, double y4)
{
if (pen == null)
throw new ArgumentNullException("pen");
if (this.drawGraphics)
this.gfx.DrawBezier(pen.RealizeGdiPen(), (float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4);
if (this.renderer != null)
this.renderer.DrawBeziers(pen, new XPoint[4]{new XPoint(x1, y1), new XPoint(x2, y2),
new XPoint(x3, y3), new XPoint(x4, y4)});
}
示例2: DrawPath
// ----- stroke and fill -----
/// <summary>
/// Draws a graphical path.
/// </summary>
public void DrawPath(XPen pen, XBrush brush, XGraphicsPath path)
{
if (pen == null && brush == null)
throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);
if (path == null)
throw new ArgumentNullException("path");
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
{
if (brush != null)
this.gfx.FillPath(brush.RealizeGdiBrush(), path.gdipPath);
if (pen != null)
this.gfx.DrawPath(pen.RealizeGdiPen(), path.gdipPath);
}
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
{
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, path.pathGeometry);
}
#endif
}
if (this.renderer != null)
this.renderer.DrawPath(pen, brush, path);
}
示例3: DrawLines
/// <summary>
/// Draws a series of line segments that connect an array of points.
/// </summary>
public void DrawLines(XPen pen, PointF[] points)
{
if (pen == null)
throw new ArgumentNullException("pen");
if (points == null)
throw new ArgumentNullException("points");
if (points.Length < 2)
throw new ArgumentException("points", PSSR.PointArrayAtLeast(2));
if (this.drawGraphics)
this.gfx.DrawLines(pen.RealizeGdiPen(), points);
if (this.renderer != null)
this.renderer.DrawLines(pen, MakeXPointArray(points));
}
示例4: DrawPie
/// <summary>
/// Draws a pie defined by an ellipse.
/// </summary>
public void DrawPie(XPen pen, double x, double y, double width, double height, double startAngle, double sweepAngle)
{
if (pen == null)
throw new ArgumentNullException("pen", PSSR.NeedPenOrBrush);
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
this.gfx.DrawPie(pen.RealizeGdiPen(), (float)x, (float)y, (float)width, (float)height, (float)startAngle, (float)sweepAngle);
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
DrawPie(pen, null, x, y, width, height, startAngle, sweepAngle);
#endif
}
if (this.renderer != null)
this.renderer.DrawPie(pen, null, x, y, width, height, startAngle, sweepAngle);
}
示例5: DrawClosedCurve
/// <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);
}
示例6: DrawEllipse
/// <summary>
/// Draws an ellipse defined by a bounding rectangle.
/// </summary>
public void DrawEllipse(XPen pen, double x, double y, double width, double height)
{
if (pen == null)
throw new ArgumentNullException("pen");
// No DrawArc defined?
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
this.gfx.DrawArc(pen.RealizeGdiPen(), (float)x, (float)y, (float)width, (float)height, 0, 360);
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
{
double radiusX = width / 2;
double radiusY = height / 2;
this.dc.DrawEllipse(null, pen.RealizeWpfPen(), new System.Windows.Point(x + radiusX, y + radiusY), radiusX, radiusY);
}
#endif
}
if (this.renderer != null)
this.renderer.DrawEllipse(pen, null, x, y, width, height);
}
示例7: DrawPolygon
/// <summary>
/// Draws a polygon defined by an array of points.
/// </summary>
public void DrawPolygon(XPen pen, XPoint[] points)
{
if (pen == null)
throw new ArgumentNullException("pen");
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.DrawPolygon(pen.RealizeGdiPen(), MakePointFArray(points));
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
{
this.dc.DrawGeometry(null, pen.RealizeWpfPen(), GeometryHelper.CreatePolygonGeometry(MakePointArray(points), XFillMode.Alternate, true));
}
#endif
}
if (this.renderer != null)
this.renderer.DrawPolygon(pen, null, points, XFillMode.Alternate); // XFillMode is ignored
}
示例8: Widen
// --------------------------------------------------------------------------------------------
/// <summary>
/// Replaces this path with curves that enclose the area that is filled when this path is drawn
/// by the specified pen.
/// </summary>
public void Widen(XPen pen)
{
this.gdipPath.Widen(pen.RealizeGdiPen());
}
示例9: DrawRectangle
/// <summary>
/// Draws a rectangle.
/// </summary>
public void DrawRectangle(XPen pen, double x, double y, double width, double height)
{
if (pen == null)
throw new ArgumentNullException("pen");
if (this.drawGraphics)
this.gfx.DrawRectangle(pen.RealizeGdiPen(), (float)x, (float)y, (float)width, (float)height);
if (this.renderer != null)
this.renderer.DrawRectangle(pen, null, x, y, width, height);
}
示例10: Widen
/// <summary>
/// Replaces this path with curves that enclose the area that is filled when this path is drawn
/// by the specified pen.
/// </summary>
public void Widen(XPen pen, XMatrix matrix, double flatness)
{
#if CORE
// Just do nothing.
#endif
#if CORE__
throw new NotImplementedException("XGraphicsPath.Widen");
#endif
#if GDI
try
{
Lock.EnterGdiPlus();
_gdipPath.Widen(pen.RealizeGdiPen(), matrix.ToGdiMatrix(), (float)flatness);
}
finally { Lock.ExitGdiPlus(); }
#endif
#if WPF || NETFX_CORE
#if !SILVERLIGHT && !NETFX_CORE
_pathGeometry = _pathGeometry.GetWidenedPathGeometry(pen.RealizeWpfPen());
#else
// AG-HACK
throw new InvalidOperationException("Silverlight/WinRT cannot widen a geometry.");
// TODO: no, yagni
#endif
#endif
}
示例11: DrawArc
/// <summary>
/// Draws an arc representing a portion of an ellipse.
/// </summary>
public void DrawArc(XPen pen, double x, double y, double width, double height, double startAngle, double sweepAngle)
{
if (pen == null)
throw new ArgumentNullException("pen");
if (Math.Abs(sweepAngle) >= 360)
{
DrawEllipse(pen, x, y, width, height);
}
else
{
if (this.drawGraphics)
this.gfx.DrawArc(pen.RealizeGdiPen(), (float)x, (float)y, (float)width, (float)height, (float)startAngle, (float)sweepAngle);
if (this.renderer != null)
this.renderer.DrawArc(pen, x, y, width, height, startAngle, sweepAngle);
}
}
示例12: DrawCurve
/// <summary>
/// Draws a cardinal spline through a specified array of points using a specified tension.
/// </summary>
public void DrawCurve(XPen pen, XPoint[] points, double tension)
{
if (pen == null)
throw new ArgumentNullException("pen");
if (points == null)
throw new ArgumentNullException("points");
if (points.Length < 2)
throw new ArgumentException("DrawCurve requires two or more points.", "points");
if (this.drawGraphics)
this.gfx.DrawCurve(pen.RealizeGdiPen(), MakePointFArray(points), (float)tension);
if (this.renderer != null)
this.renderer.DrawCurve(pen, points, tension);
}
示例13: DrawBeziers
/// <summary>
/// Draws a series of Bézier splines from an array of points.
/// </summary>
public void DrawBeziers(XPen pen, XPoint[] points)
{
if (pen == null)
throw new ArgumentNullException("pen");
int count = points.Length;
if (count == 0)
return;
if ((count - 1) % 3 != 0)
throw new ArgumentException("Invalid number of points for bezier curves. Number must fulfil 4+3n.", "points");
if (this.drawGraphics)
this.gfx.DrawBeziers(pen.RealizeGdiPen(), MakePointFArray(points));
if (this.renderer != null)
this.renderer.DrawBeziers(pen, points);
}
示例14: DrawRectangles
/// <summary>
/// Draws a series of rectangles.
/// </summary>
public void DrawRectangles(XPen pen, XBrush brush, RectangleF[] rectangles)
{
if (pen == null && brush == null)
throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);
if (rectangles == null)
throw new ArgumentNullException("rectangles");
if (this.drawGraphics)
{
this.gfx.FillRectangles(brush.RealizeGdiBrush(), rectangles);
this.gfx.DrawRectangles(pen.RealizeGdiPen(), rectangles);
}
if (this.renderer != null)
{
int count = rectangles.Length;
for (int idx = 0; idx < count; idx++)
{
RectangleF rect = rectangles[idx];
this.renderer.DrawRectangle(pen, brush, rect.X, rect.Y, rect.Width, rect.Height);
}
}
}
示例15: DrawBezier
/// <summary>
/// Draws a Bézier spline defined by four points.
/// </summary>
public void DrawBezier(XPen pen, double x1, double y1, double x2, double y2,
double x3, double y3, double x4, double y4)
{
if (pen == null)
throw new ArgumentNullException("pen");
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
this.gfx.DrawBezier(pen.RealizeGdiPen(), (float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4);
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
{
#if !SILVERLIGHT
BezierSegment seg = new BezierSegment(new System.Windows.Point(x2, y2), new System.Windows.Point(x3, y3), new System.Windows.Point(x4, y4), true);
PathFigure figure = new PathFigure();
figure.StartPoint = new System.Windows.Point(x1, y1);
figure.Segments.Add(seg);
PathGeometry geo = new PathGeometry();
geo.Figures.Add(figure);
this.dc.DrawGeometry(null, pen.RealizeWpfPen(), geo);
#else
// AGHACK
#endif
}
#endif
}
if (this.renderer != null)
this.renderer.DrawBeziers(pen,
new XPoint[4]{new XPoint(x1, y1), new XPoint(x2, y2),
new XPoint(x3, y3), new XPoint(x4, y4)});
}