本文整理汇总了C#中PdfSharp.Drawing.XPen.RealizeWpfPen方法的典型用法代码示例。如果您正苦于以下问题:C# XPen.RealizeWpfPen方法的具体用法?C# XPen.RealizeWpfPen怎么用?C# XPen.RealizeWpfPen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfSharp.Drawing.XPen
的用法示例。
在下文中一共展示了XPen.RealizeWpfPen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawPolygon
/// <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);
}
示例2: DrawEllipse
/// <summary>
/// Draws an ellipse defined by a bounding rectangle.
/// </summary>
public void DrawEllipse(XPen pen, XBrush brush, double x, double y, double width, double height)
{
if (pen == null && brush == null)
throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
{
this.gfx.FillEllipse(brush.RealizeGdiBrush(), (float)x, (float)y, (float)width, (float)height);
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(brush.RealizeWpfBrush(), pen.RealizeWpfPen(), new System.Windows.Point(x + radiusX, y + radiusY), radiusX, radiusY);
}
#endif
}
if (this.renderer != null)
this.renderer.DrawEllipse(pen, brush, x, y, width, height);
}
示例3: 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)
{
#if GDI
this.gdipPath.Widen(pen.RealizeGdiPen());
#endif
#if WPF
this.pathGeometry = this.pathGeometry.GetWidenedPathGeometry(pen.RealizeWpfPen());
#endif
}
示例4: DrawPath
// ----- DrawPath -----------------------------------------------------------------------------
// ----- stroke -----
/// <summary>
/// Draws a graphical path.
/// </summary>
public void DrawPath(XPen pen, XGraphicsPath path)
{
if (pen == null)
throw new ArgumentNullException("pen");
if (path == null)
throw new ArgumentNullException("path");
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
this.gfx.DrawPath(pen.RealizeGdiPen(), path.gdipPath);
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
this.dc.DrawGeometry(null, pen.RealizeWpfPen(), path.pathGeometry);
#endif
}
if (this.renderer != null)
this.renderer.DrawPath(pen, null, path);
}
示例5: DrawLine
/// <summary>
/// Draws a line connecting the two points specified by coordinate pairs.
/// </summary>
public void DrawLine(XPen pen, double x1, double y1, double x2, double y2)
{
if (pen == null)
throw new ArgumentNullException("pen");
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
this.gfx.DrawLine(pen.RealizeGdiPen(), (float)x1, (float)y1, (float)x2, (float)y2);
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
this.dc.DrawLine(pen.RealizeWpfPen(), new System.Windows.Point(x1, y1), new System.Windows.Point(x2, y2));
#endif
}
if (this.renderer != null)
this.renderer.DrawLines(pen, new XPoint[2] { new XPoint(x1, y1), new XPoint(x2, y2) });
}
示例6: 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)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
this.gfx.DrawArc(pen.RealizeGdiPen(), (float)x, (float)y, (float)width, (float)height, (float)startAngle, (float)sweepAngle);
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
{
System.Windows.Point startPoint;
ArcSegment seg = GeometryHelper.CreateArcSegment(x, y, width, height, startAngle, sweepAngle, out startPoint);
PathFigure figure = new PathFigure();
figure.StartPoint = startPoint;
figure.Segments.Add(seg);
PathGeometry geo = new PathGeometry();
geo.Figures.Add(figure);
this.dc.DrawGeometry(null, pen.RealizeWpfPen(), geo);
}
#endif
}
if (this.renderer != null)
this.renderer.DrawArc(pen, x, y, width, height, startAngle, sweepAngle);
}
}
示例7: 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)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
this.gfx.DrawRectangle(pen.RealizeGdiPen(), (float)x, (float)y, (float)width, (float)height);
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
{
this.dc.DrawRectangle(null, pen.RealizeWpfPen(), new Rect(x, y, width, height));
}
#endif
}
if (this.renderer != null)
this.renderer.DrawRectangle(pen, null, x, y, width, height);
}
示例8: 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)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
this.gfx.DrawBeziers(pen.RealizeGdiPen(), MakePointFArray(points));
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
{
#if !SILVERLIGHT
PathFigure figure = new PathFigure();
figure.StartPoint = new System.Windows.Point(points[0].x, points[0].y);
for (int idx = 1; idx < count; idx += 3)
{
BezierSegment seg = new BezierSegment(
new System.Windows.Point(points[idx].x, points[idx].y),
new System.Windows.Point(points[idx + 1].x, points[idx + 1].y),
new System.Windows.Point(points[idx + 2].x, points[idx + 2].y), true);
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, points);
}
示例9: 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");
int count = points.Length;
if (count < 2)
throw new ArgumentException("DrawCurve requires two or more points.", "points");
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
this.gfx.DrawCurve(pen.RealizeGdiPen(), MakePointFArray(points), (float)tension);
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
{
tension /= 3;
PathFigure figure = new PathFigure();
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[0], 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[count - 1], tension));
}
PathGeometry geo = new PathGeometry();
geo.Figures.Add(figure);
this.dc.DrawGeometry(null, pen.RealizeWpfPen(), geo);
}
#endif
}
if (this.renderer != null)
this.renderer.DrawCurve(pen, points, tension);
}
示例10: 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)});
}
示例11: 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
}
示例12: DrawPie
/// <summary>
/// Draws a pie defined by an ellipse.
/// </summary>
public void DrawPie(XPen pen, XBrush brush, double x, double y, double width, double height, double startAngle, double sweepAngle)
{
if (pen == null && brush == null)
throw new ArgumentNullException("pen", PSSR.NeedPenOrBrush);
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
{
this.gfx.FillPie(brush.RealizeGdiBrush(), (float)x, (float)y, (float)width, (float)height, (float)startAngle, (float)sweepAngle);
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)
{
#if !SILVERLIGHT
System.Windows.Media.Brush wpfBrush = brush != null ? brush.RealizeWpfBrush() : null;
System.Windows.Media.Pen wpfPen = pen != null ? pen.RealizeWpfPen() : null;
System.Windows.Point center = new System.Windows.Point(x + width / 2, y + height / 2);
System.Windows.Point startArc;
ArcSegment arc = GeometryHelper.CreateArcSegment(x, y, width, height, startAngle, sweepAngle, out startArc);
PathFigure figure = new PathFigure();
figure.StartPoint = center;
figure.Segments.Add(new LineSegment(startArc, true));
figure.Segments.Add(arc);
figure.IsClosed = true;
PathGeometry geo = new PathGeometry();
geo.Figures.Add(figure);
this.dc.DrawGeometry(wpfBrush, wpfPen, geo);
#else
// AGHACK
#endif
}
#endif
}
if (this.renderer != null)
this.renderer.DrawPie(pen, brush, x, y, width, height, startAngle, sweepAngle);
}
示例13: 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);
}
示例14: DrawRectangles
/// <summary>
/// Draws a series of rectangles.
/// </summary>
public void DrawRectangles(XPen pen, XBrush brush, XRect[] rectangles)
{
if (pen == null && brush == null)
throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);
if (rectangles == null)
throw new ArgumentNullException("rectangles");
int count = rectangles.Length;
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
{
RectangleF[] rects = new RectangleF[count];
for (int idx = 0; idx < count; idx++)
{
XRect rect = rectangles[idx];
rects[idx] = new RectangleF((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height);
}
if (brush != null)
this.gfx.FillRectangles(brush.RealizeGdiBrush(), rects);
if (pen != null)
this.gfx.DrawRectangles(pen.RealizeGdiPen(), rects);
}
#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;
for (int idx = 0; idx < count; idx++)
{
XRect rect = rectangles[idx];
this.dc.DrawRectangle(wpfBrush, wpfPen, new System.Windows.Rect(new System.Windows.Point(rect.x, rect.y), new System.Windows.Size(rect.width, rect.height)));
}
}
#endif
}
if (this.renderer != null)
{
for (int idx = 0; idx < count; idx++)
{
XRect rect = rectangles[idx];
this.renderer.DrawRectangle(pen, brush, rect.X, rect.Y, rect.Width, rect.Height);
}
}
}
示例15: DrawRoundedRectangle
/// <summary>
/// Draws a rectangles with round corners.
/// </summary>
public void DrawRoundedRectangle(XPen pen, XBrush brush, double x, double y, double width, double height,
double ellipseWidth, double ellipseHeight)
{
if (pen == null && brush == null)
throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
{
XGraphicsPath path = new XGraphicsPath();
path.AddRoundedRectangle(x, y, width, height, ellipseWidth, ellipseHeight);
DrawPath(pen, brush, path);
}
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
{
this.dc.DrawRoundedRectangle(
brush != null ? brush.RealizeWpfBrush() : null,
pen != null ? pen.RealizeWpfPen() : null,
new Rect(x, y, width, height), ellipseWidth / 2, ellipseHeight / 2);
}
#endif
}
if (this.renderer != null)
this.renderer.DrawRoundedRectangle(pen, brush, x, y, width, height, ellipseWidth, ellipseHeight);
}