本文整理匯總了C#中PdfSharp.Drawing.XBrush類的典型用法代碼示例。如果您正苦於以下問題:C# XBrush類的具體用法?C# XBrush怎麽用?C# XBrush使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
XBrush類屬於PdfSharp.Drawing命名空間,在下文中一共展示了XBrush類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: BarCodeRenderInfo
public BarCodeRenderInfo(XGraphics gfx, XBrush brush, XFont font, XPoint position)
{
Gfx = gfx;
Brush = brush;
Font = font;
Position = position;
}
示例2: DrawStringX
///<summary>The pdfSharp version of drawstring. g is used for measurement. scaleToPix scales xObjects to pixels.</summary>
public static void DrawStringX(XGraphics xg,Graphics g,double scaleToPix,string str,XFont xfont,XBrush xbrush,XRect xbounds, XStringAlignment sa) {
//There are two coordinate systems here: pixels (used by us) and points (used by PdfSharp).
//MeasureString and ALL related measurement functions must use pixels.
//DrawString is the ONLY function that uses points.
//pixels:
Rectangle bounds=new Rectangle((int)(scaleToPix*xbounds.Left),
(int)(scaleToPix*xbounds.Top),
(int)(scaleToPix*xbounds.Width),
(int)(scaleToPix*xbounds.Height));
FontStyle fontstyle=FontStyle.Regular;
if(xfont.Style==XFontStyle.Bold) {
fontstyle=FontStyle.Bold;
}
//pixels: (except Size is em-size)
Font font=new Font(xfont.Name,(float)xfont.Size,fontstyle);
//pixels:
SizeF fit=new SizeF((float)(bounds.Width-rightPad),(float)(font.Height));
StringFormat format=StringFormat.GenericTypographic;
//pixels:
float pixelsPerLine=LineSpacingForFont(font.Name) * (float)font.Height;
float lineIdx=0;
int chars;
int lines;
//points:
RectangleF layoutRectangle;
for(int ix=0;ix<str.Length;ix+=chars) {
if(bounds.Y+topPad+pixelsPerLine*lineIdx>bounds.Bottom) {
break;
}
//pixels:
g.MeasureString(str.Substring(ix),font,fit,format,out chars,out lines);
//PdfSharp isn't smart enough to cut off the lower half of a line.
//if(bounds.Y+topPad+pixelsPerLine*lineIdx+font.Height > bounds.Bottom) {
// layoutH=bounds.Bottom-(bounds.Y+topPad+pixelsPerLine*lineIdx);
//}
//else {
// layoutH=font.Height+2;
//}
//use points here:
float adjustTextDown=10f;//this value was arrived at by trial and error.
layoutRectangle=new RectangleF(
(float)xbounds.X,
//(float)(xbounds.Y+(float)topPad/scaleToPix+(pixelsPerLine/scaleToPix)*lineIdx),
(float)(xbounds.Y+adjustTextDown+(pixelsPerLine/scaleToPix)*lineIdx),
(float)xbounds.Width+50,//any amount of extra padding here will not cause malfunction
0);//layoutH);
XStringFormat sf=XStringFormats.Default;
sf.Alignment=sa;
//sf.LineAlignment= XLineAlignment.Near;
//xg.DrawString(str.Substring(ix,chars),xfont,xbrush,layoutRectangle,sf);
xg.DrawString(str.Substring(ix,chars),xfont,xbrush,(double)layoutRectangle.Left,(double)layoutRectangle.Top,sf);
lineIdx+=1;
}
}
示例3: Render
/// <summary>
/// Renders the OMR code.
/// </summary>
protected internal override void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position)
{
XGraphicsState state = gfx.Save();
switch (this.direction)
{
case CodeDirection.RightToLeft:
gfx.RotateAtTransform(180, position);
break;
case CodeDirection.TopToBottom:
gfx.RotateAtTransform(90, position);
break;
case CodeDirection.BottomToTop:
gfx.RotateAtTransform(-90, position);
break;
}
//XPoint pt = center - this.size / 2;
XPoint pt = position - CodeBase.CalcDistance(AnchorType.TopLeft, this.anchor, this.size);
uint value;
uint.TryParse(this.text, out value);
#if true
// HACK: Project Wallenwein: set LK
value |= 1;
this.synchronizeCode = true;
#endif
if (this.synchronizeCode)
{
XRect rect = new XRect(pt.x, pt.y, this.makerThickness, this.size.height);
gfx.DrawRectangle(brush, rect);
pt.x += 2 * this.makerDistance;
}
for (int idx = 0; idx < 32; idx++)
{
if ((value & 1) == 1)
{
XRect rect = new XRect(pt.x + idx * this.makerDistance, pt.y, this.makerThickness, this.size.height);
gfx.DrawRectangle(brush, rect);
}
value = value >> 1;
}
gfx.Restore(state);
}
示例4: ElliottsDiagramCalculation
void ElliottsDiagramCalculation()
{
//Decide Zone for both figures from this calculation
zone = "Non-Explosive Zone";
brush = XBrushes.Green;
}
示例5: DrawBarCode
/// <summary>
/// Draws the specified bar code.
/// </summary>
public void DrawBarCode(BarCodes.BarCode barcode, XBrush brush, XFont font, XPoint position)
{
barcode.Render(this, brush, font, position);
}
示例6: DrawString
/// <summary>
/// Draws the specified text string.
/// </summary>
public void DrawString(string s, XFont font, XBrush brush, RectangleF layoutRectangle, XStringFormat format)
{
DrawString(s, font, brush, new XRect(layoutRectangle), format);
}
示例7: DrawPath
// ----- fill -----
/// <summary>
/// Draws a graphical path.
/// </summary>
public void DrawPath(XBrush brush, XGraphicsPath path)
{
if (brush == null)
throw new ArgumentNullException("brush");
if (path == null)
throw new ArgumentNullException("path");
if (this.drawGraphics)
{
#if GDI
if (this.targetContext == XGraphicTargetContext.GDI)
this.gfx.FillPath(brush.RealizeGdiBrush(), path.gdipPath);
#endif
#if WPF
if (this.targetContext == XGraphicTargetContext.WPF)
this.dc.DrawGeometry(brush.RealizeWpfBrush(), null, path.pathGeometry);
#endif
}
if (this.renderer != null)
this.renderer.DrawPath(null, brush, path);
}
示例8: DrawClosedCurve
/// <summary>
/// Draws a closed cardinal spline defined by an array of points.
/// </summary>
public void DrawClosedCurve(XBrush brush, System.Windows.Point[] points)
{
DrawClosedCurve(null, brush, MakeXPointArray(points), XFillMode.Alternate, 0.5);
}
示例9: 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);
}
示例10: DrawMatrixCode
/// <summary>
/// Draws the specified data matrix code.
/// </summary>
public void DrawMatrixCode(BarCodes.MatrixCode matrixcode, XBrush brush, XPoint position)
{
matrixcode.Render(this, brush, position);
}
示例11: Render
/// <summary>
/// When defined in a derived class renders the code.
/// </summary>
protected internal abstract void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position);