本文整理汇总了C#中PdfSharp.Drawing.XGraphics类的典型用法代码示例。如果您正苦于以下问题:C# XGraphics类的具体用法?C# XGraphics怎么用?C# XGraphics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XGraphics类属于PdfSharp.Drawing命名空间,在下文中一共展示了XGraphics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderLines
/// <summary>
/// Draws simple lines.
/// </summary>
void RenderLines(XGraphics gfx)
{
gfx.TranslateTransform(15, 20);
gfx.DrawLine(XPens.Red, new XPoint(10, 10), new XPoint(300, 300));
gfx.DrawLine(XPens.DarkGreen, 0, 0, 250, 0);
gfx.DrawLine(XPens.Gold, 15, 7, 230, 15);
XPen pen = new XPen(XColors.Navy, 4);
gfx.DrawLine(pen, 0, 20, 250, 20);
pen = new XPen(XColors.Firebrick, 6);
pen.DashStyle = XDashStyle.Dash;
gfx.DrawLine(pen, 0, 40, 250, 40);
pen.Width = 7.3;
pen.DashStyle = XDashStyle.DashDotDot;
gfx.DrawLine(pen, 0, 60, 250, 60);
pen = new XPen(XColors.Goldenrod, 10);
pen.LineCap = XLineCap.Flat;
gfx.DrawLine(pen, 10, 90, 240, 90);
gfx.DrawLine(XPens.Black, 10, 90, 240, 90);
pen = new XPen(XColors.Goldenrod, 10);
pen.LineCap = XLineCap.Square;
gfx.DrawLine(pen, 10, 110, 240, 110);
gfx.DrawLine(XPens.Black, 10, 110, 240, 110);
pen = new XPen(XColors.Goldenrod, 10);
pen.LineCap = XLineCap.Round;
gfx.DrawLine(pen, 10, 130, 240, 130);
gfx.DrawLine(XPens.Black, 10, 130, 240, 130);
}
示例2: RenderClock
/// <summary>
/// Draws a clock on a square page.
/// Inspired by Charles Petzold's AnalogClock sample in
/// 'Programming Microsoft Windows with C#'.
/// </summary>
void RenderClock(XGraphics gfx)
{
// Clocks should always look happy on hardcopies...
//this.time = new DateTime(2005, 1, 1, 11, 6, 22, 500);
XColor strokeColor = XColors.DarkBlue;
XColor fillColor = XColors.DarkOrange;
XPen pen = new XPen(strokeColor, 5);
XBrush brush = new XSolidBrush(fillColor);
strokeColor.A = 0.8;
fillColor.A = 0.8;
XPen handPen = new XPen(strokeColor, 5);
XBrush handBrush = new XSolidBrush(fillColor);
DrawText(gfx, pen, brush);
double width = gfx.PageSize.Width;
double height = gfx.PageSize.Height;
gfx.TranslateTransform(width / 2, height / 2);
double scale = Math.Min(width, height);
gfx.ScaleTransform(scale / 2000);
DrawFace(gfx, pen, brush);
DrawHourHand(gfx, handPen, handBrush);
DrawMinuteHand(gfx, handPen, handBrush);
DrawSecondHand(gfx, new XPen(XColors.Red, 7));
}
示例3: DrawLine
/// <summary>
/// Draws simple lines.
/// </summary>
void DrawLine(XGraphics gfx, int number)
{
BeginBox(gfx, number, "DrawLine");
gfx.DrawLine(XPens.DarkGreen, 0, 0, 250, 0);
gfx.DrawLine(XPens.Gold, 15, 7, 230, 15);
XPen pen = new XPen(XColors.Navy, 4);
gfx.DrawLine(pen, 0, 20, 250, 20);
pen = new XPen(XColors.Firebrick, 6);
pen.DashStyle = XDashStyle.Dash;
gfx.DrawLine(pen, 0, 40, 250, 40);
pen.Width = 7.3;
pen.DashStyle = XDashStyle.DashDotDot;
gfx.DrawLine(pen, 0, 60, 250, 60);
pen = new XPen(XColors.Goldenrod, 10);
pen.LineCap = XLineCap.Flat;
gfx.DrawLine(pen, 10, 90, 240, 90);
gfx.DrawLine(XPens.Black, 10, 90, 240, 90);
pen = new XPen(XColors.Goldenrod, 10);
pen.LineCap = XLineCap.Square;
gfx.DrawLine(pen, 10, 110, 240, 110);
gfx.DrawLine(XPens.Black, 10, 110, 240, 110);
pen = new XPen(XColors.Goldenrod, 10);
pen.LineCap = XLineCap.Round;
gfx.DrawLine(pen, 10, 130, 240, 130);
gfx.DrawLine(XPens.Black, 10, 130, 240, 130);
EndBox(gfx);
}
示例4: Genereer
public static bool Genereer(Deelnemer deelnemer, DeelnemerVerhuisd deelnemerVerhuisd)
{
_deelnemer = deelnemer;
_event = deelnemerVerhuisd;
// start pdf document
_document = new PdfDocument();
_document.Info.Title = "Verhuisbrief " + _deelnemer.Naam;
_document.Info.Author = "Verhuisbrief Generator";
// voeg pagina toe
_page = _document.AddPage();
_gfx = XGraphics.FromPdfPage(_page);
// vul pagina
PlaatsLogo();
PlaatsTitel();
PlaatsNAWGegevens();
PlaatsInhoud();
// sla document op
SlaPdfOp();
return true;
}
示例5: Arc
public void Arc(XGraphics gfx, RectangleF rect, float startAngle, float sweepAngle)
{
RectangleF rect2 = RectangleF.Inflate(rect, rect.Width, 0);
Box2(gfx, rect2, startAngle, sweepAngle);
Box1(gfx, rect, startAngle, sweepAngle);
//Box(gfx, rect, startAngle, sweepAngle);
gfx.DrawArc(properties.Pen2.Pen, rect, startAngle, sweepAngle);
gfx.DrawArc(properties.Pen3.Pen, rect2, 0, 90);
gfx.DrawArc(properties.Pen2.Pen, rect2, startAngle, sweepAngle);
float delta = (float)(Math.PI / 360);
float rx = rect2.Width / 2;
float ry = rect2.Height / 2;
float dx = rect2.X + rx;
float dy = rect2.Y + ry;
for (float rad = 0; rad < Math.PI * 2; rad += delta)
{
gfx.DrawLine(XPens.LawnGreen, (float)(dx + rx * Math.Cos(rad)), (float)(dy + ry * Math.Sin(rad)),
(float)(dx + rx * Math.Cos(rad + delta)), (float)(dy + ry * Math.Sin(rad + delta)));
}
double gamma1 = (ry * Math.Cos(20 * 0.0174532925199433)) / (rx * Math.Sin(20 * 0.0174532925199433));
gamma1 = Math.Atan(gamma1);
gamma1 = 90 - gamma1 / 0.0174532925199433;
double gamma2 = (ry * Math.Cos(70 * 0.0174532925199433)) / (rx * Math.Sin(70 * 0.0174532925199433));
gamma2 = Math.Atan(gamma2);
gamma2 = 90 - gamma2 / 0.0174532925199433 - gamma1;
gfx.DrawArc(XPens.Black, rect2, (float)gamma1, (float)gamma2);
}
示例6: RenderPage
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
DrawGridlines(gfx);
// Create a new graphical path
XGraphicsPath path = new XGraphicsPath();
XSize size = new XSize(90, 140);
double rotationAngle = 130;
path.AddArc(new XPoint(100, 100), new XPoint(200, 200), size, rotationAngle, false, System.Windows.Media.SweepDirection.Clockwise);
path.StartFigure();
path.AddArc(new XPoint(400, 100), new XPoint(500, 200), size, rotationAngle, false, System.Windows.Media.SweepDirection.Counterclockwise);
path.StartFigure();
path.AddArc(new XPoint(100, 300), new XPoint(200, 400), size, rotationAngle, true, System.Windows.Media.SweepDirection.Clockwise);
path.StartFigure();
path.AddArc(new XPoint(400, 300), new XPoint(500, 400), size, rotationAngle, true, System.Windows.Media.SweepDirection.Counterclockwise);
path.StartFigure();
#if DEBUG_
gfx.WriteComment("PathArcSegment");
#endif
gfx.DrawPath(XPens.Red, path);
}
示例7: Draw
/// <summary>
/// Draws the Table Control. Will not draw, if height lower than table head height
/// </summary>
/// <param name="gfx">The GFX.</param>
/// <param name="startY">The start Y. Relative to table</param>
/// <param name="height">The height. Relative to table</param>
public void Draw(XGraphics gfx, double startY, double height)
{
if (startY < 0 || height < 0)
{
throw new ArgumentException("Wrong Y range spefified");
}
List<IContainerControl> rows = Rows.Where(r => (r.Rect.Y + r.Rect.Height) <= startY + height).ToList();
//Cannot draw lower table than header or Nothing to draw
if (height < _headHight || !rows.Any())
{
Rect = new XRect(Rect.X, Rect.Y, Rect.Width, 0);
return;
}
rows.InsertRange(0, HeadRows.Clone());
double curentHeight = rows.Select(x => x.Rect.Height).Sum();
Rect = new XRect(Rect.X, Rect.Y, Rect.Width, curentHeight + MarginTop + 1);
_backgroundControl.Brush = XBrushes.LightGray;
_backgroundControl.Pen = XPens.Black;
_backgroundControl.Draw(gfx);
double y = 0;
foreach (IContainerControl row in rows)
{
row.Rect = new XRect(Rect.X + 1, Rect.Y + MarginTop + y, row.Rect.Width - 2,
row.Rect.Height);
y += row.Rect.Height;
row.Draw(gfx);
}
}
示例8: Renderer
internal Renderer(XGraphics gfx, RenderInfo renderInfo, FieldInfos fieldInfos)
{
_documentObject = renderInfo.DocumentObject;
_gfx = gfx;
_renderInfo = renderInfo;
_fieldInfos = fieldInfos;
}
示例9: Renderer
internal Renderer(XGraphics gfx, RenderInfo renderInfo, FieldInfos fieldInfos)
{
this.documentObject = renderInfo.DocumentObject;
this.gfx = gfx;
this.renderInfo = renderInfo;
this.fieldInfos = fieldInfos;
}
示例10: Format
internal void Format(XGraphics gfx)
{
_gfx = gfx;
_isFirstArea = true;
_formatter = new TopDownFormatter(this, _documentRenderer, TextArea.Elements);
_formatter.FormatOnAreas(gfx, false);
}
示例11: RenderPage
/// <summary>
/// Demonstrates the use of XGraphics.DrawRoundedRectangle.
/// </summary>
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
// Stroke ellipse
gfx.DrawEllipse(properties.Pen1.Pen, 50, 100, 450, 150);
// Fill ellipse
gfx.DrawEllipse(properties.Brush2.Brush, new Rectangle(50, 300, 450, 150));
// Stroke and fill ellipse
gfx.DrawEllipse(properties.Pen2.Pen, properties.Brush2.Brush, new RectangleF(50, 500, 450, 150));
// Stroke circle
gfx.DrawEllipse(properties.Pen2.Pen, new XRect(100, 200, 400, 400));
#if DEBUG
int count = 360;
XPoint[] circle = new XPoint[count];
for (int idx = 0; idx < count; idx++)
{
double rad = idx * 2 * Math.PI / count;
circle[idx].X = Math.Cos(rad) * 200 + 300;
circle[idx].Y = Math.Sin(rad) * 200 + 400;
}
gfx.DrawPolygon(properties.Pen3.Pen, circle);
#endif
}
示例12: ShapeRenderer
internal ShapeRenderer(XGraphics gfx, Shape shape, FieldInfos fieldInfos)
: base(gfx, shape, fieldInfos)
{
this.shape = shape;
LineFormat lf = (LineFormat)this.shape.GetValue("LineFormat", GV.ReadOnly);
this.lineFormatRenderer = new LineFormatRenderer(lf, gfx);
}
示例13: RenderPage
/// <summary>
/// Demonstrates serveral bar code types.
/// </summary>
public override void RenderPage(XGraphics gfx)
{
XRect rc;
base.RenderPage(gfx);
Graphics grfx = gfx.Internals.Graphics;
Code2of5Interleaved bc25 = new Code2of5Interleaved();
bc25.Text = "123456";
bc25.Size = new XSize(90, 30);
//bc25.Direction = BarCodeDirection.RightToLeft;
bc25.TextLocation = TextLocation.Above;
gfx.DrawBarCode(bc25, XBrushes.DarkBlue, new XPoint(100, 100));
CodeDataMatrix dm = new CodeDataMatrix("test", 26);
dm.Size = new XSize(XUnit.FromMillimeter(15), XUnit.FromMillimeter(15));
gfx.DrawMatrixCode(dm, XBrushes.DarkBlue, new XPoint(300, 100));
rc = new XRect(30, 200, XUnit.FromCentimeter(9.3) + XUnit.FromMillimeter(0.5), XUnit.FromMillimeter(6));
gfx.DrawRectangle(new XSolidBrush(XColor.FromArgb(128, XColors.LightSeaGreen)), rc);
CodeOmr omr = new CodeOmr(0xF8F5FF3F.ToString(), rc.Size, CodeDirection.LeftToRight);
omr.MakerDistance = XUnit.FromMillimeter(3);
omr.MakerThickness = XUnit.FromMillimeter(0.5);
gfx.DrawBarCode(omr, XBrushes.Black, rc.Center);
omr.Direction = CodeDirection.RightToLeft;
gfx.DrawBarCode(omr, XBrushes.Black, rc.Center + new XSize(0, 50));
omr.Direction = CodeDirection.RightToLeft;
gfx.DrawBarCode(omr, XBrushes.Black, rc.Center + new XSize(0, 50));
omr.Direction = CodeDirection.TopToBottom;
gfx.DrawBarCode(omr, XBrushes.Black, rc.Center + new XSize(300, 25));
}
示例14: RenderPage
public override void RenderPage(XGraphics gfx)
{
//base.RenderPage(gfx);
XTextFormatter tf = new XTextFormatter(gfx);
XRect rect;
string text = this.properties.Font1.Text;
//text = "First\nSecond Line\nlaksdjf 234 234";
rect = new XRect(40, 100, 250, 200);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
//tf.Alignment = ParagraphAlignment.Left;
tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
rect, XStringFormats.TopLeft);
rect = new XRect(310, 100, 250, 200);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.Alignment = XParagraphAlignment.Right;
tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
rect, XStringFormats.TopLeft);
rect = new XRect(40, 400, 250, 200);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.Alignment = XParagraphAlignment.Center;
tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
rect, XStringFormats.TopLeft);
rect = new XRect(310, 400, 250, 200);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.Alignment = XParagraphAlignment.Justify;
tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
rect, XStringFormats.TopLeft);
}
示例15: Box2
void Box2(XGraphics gfx, RectangleF rect, float startAngle, float sweepAngle)
{
float xc = rect.X + rect.Width / 2;
float yc = rect.Y + rect.Height / 2;
double a = startAngle * 0.0174532925199433;
double b = (startAngle + sweepAngle) * 0.0174532925199433;
gfx.DrawRectangle(XPens.Black, rect);
for (float deg = 0; deg < 360; deg += 10)
gfx.DrawLine(XPens.Yellow, xc, yc,
(float)(xc + rect.Width * Math.Cos(deg * 0.0174532925199433)),
(float)(yc + rect.Height * Math.Sin(deg * 0.0174532925199433)));
//if (rect.Width == rect.Height)
//{
// float f = Math.Max(rect.Width / 2, rect.Height / 2);
// for (float deg = 0; deg < 360; deg += 10)
// gfx.DrawLine(XPens.Goldenrod, xc, yc,
// (float)(xc + f * Math.Cos(deg * 0.0174532925199433)),
// (float)(yc + f * Math.Sin(deg * 0.0174532925199433)));
//}
//gfx.DrawLine(XPens.PaleGreen, xc, rect.Y, xc, rect.Y + rect.Height);
//gfx.DrawLine(XPens.PaleGreen, rect.X, yc, rect.X + rect.Width, yc);
gfx.DrawLine(XPens.DarkGray, xc, yc, (float)(xc + rect.Width / 2 * Math.Cos(a)), (float)(yc + rect.Height / 2 * Math.Sin(a)));
gfx.DrawLine(XPens.DarkGray, xc, yc, (float)(xc + rect.Width / 2 * Math.Cos(b)), (float)(yc + rect.Height / 2 * Math.Sin(b)));
}