本文整理汇总了C#中PdfSharp.Drawing.XGraphics.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# XGraphics.DrawLine方法的具体用法?C# XGraphics.DrawLine怎么用?C# XGraphics.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfSharp.Drawing.XGraphics
的用法示例。
在下文中一共展示了XGraphics.DrawLine方法的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: RenderPage
/// <summary>
/// Demonstrates the use of XGraphics.DrawBeziers.
/// </summary>
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
int n = 2;
int count = 1 + 3 * n;
XPoint[] points = new XPoint[count];
Random rnd = new Random(42);
for (int idx = 0; idx < count; idx++)
{
points[idx].X = 20 + rnd.Next(600);
points[idx].Y = 50 + rnd.Next(800);
}
// Draw the points
XPen pen = new XPen(XColors.Red, 0.5);
pen.DashStyle = XDashStyle.Dash;
for (int idx = 0; idx + 3 < count; idx += 3)
{
gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx]));
gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 1]));
gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 2]));
gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 3]));
gfx.DrawLine(pen, points[idx], points[idx + 1]);
gfx.DrawLine(pen, points[idx + 2], points[idx + 3]);
}
// Draw the curve
gfx.DrawBeziers(properties.Pen2.Pen, points);
}
示例3: DrawDebuggingCrosshair
private void DrawDebuggingCrosshair(XGraphics context)
{
var pen = new XPen(XColors.Red);
var w = form.Size.Width;
var h = form.Size.Height;
context.DrawLine(pen, 0, 0, w, h);
context.DrawLine(pen, w, 0, 0, h);
}
示例4: 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);
}
示例5: RenderTextAlignment
void RenderTextAlignment(XGraphics gfx)
{
gfx.TranslateTransform(15, 20);
XRect rect = new XRect(0, 0, 250, 140);
XFont font = new XFont("Verdana", 10);
XBrush brush = XBrushes.Purple;
XStringFormat format = new XStringFormat();
gfx.DrawRectangle(XPens.YellowGreen, rect);
gfx.DrawLine(XPens.YellowGreen, rect.Width / 2, 0, rect.Width / 2, rect.Height);
gfx.DrawLine(XPens.YellowGreen, 0, rect.Height / 2, rect.Width, rect.Height / 2);
#if true
gfx.DrawString("TopLeft", font, brush, rect, format);
format.Alignment = XStringAlignment.Center;
gfx.DrawString("TopCenter", font, brush, rect, format);
format.Alignment = XStringAlignment.Far;
gfx.DrawString("TopRight", font, brush, rect, format);
format.LineAlignment = XLineAlignment.Center;
format.Alignment = XStringAlignment.Near;
gfx.DrawString("CenterLeft", font, brush, rect, format);
format.Alignment = XStringAlignment.Center;
gfx.DrawString("Center", font, brush, rect, format);
format.Alignment = XStringAlignment.Far;
gfx.DrawString("CenterRight", font, brush, rect, format);
format.LineAlignment = XLineAlignment.Far;
format.Alignment = XStringAlignment.Near;
gfx.DrawString("BottomLeft", font, brush, rect, format);
format.Alignment = XStringAlignment.Center;
gfx.DrawString("BottomCenter", font, brush, rect, format);
format.Alignment = XStringAlignment.Far;
gfx.DrawString("BottomRight", font, brush, rect, format);
#else
format.Alignment = XStringAlignment.Far;
gfx.DrawString("TopRight", font, brush, rect, format);
#endif
}
示例6: RenderPage
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
#if true__
XPen pen = new XPen(XColors.DarkGreen, 20);
gfx.DrawLine(pen, 0, 0, 1000, 1000);
#endif
XGraphicsPath path = new XGraphicsPath();
path.AddString("@", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 500, new XPoint(90, 60), XStringFormats.Default);
gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path);
}
示例7: Box1
void Box1(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)));
float f = Math.Max(rect.Width, rect.Height) * 3 / 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)));
}
示例8: Box
void Box(XGraphics gfx, XRect rect, double startAngle, double sweepAngle)
{
double xc = rect.X + rect.Width / 2;
double yc = rect.Y + rect.Height / 2;
double a = startAngle * 0.0174532925199433;
double b = (startAngle + sweepAngle) * 0.0174532925199433;
XGraphicsState state = gfx.Save();
gfx.IntersectClip(rect);
#if true
#if true_
for (double deg = 0; deg < 360; deg += 10)
gfx.DrawLine(XPens.Yellow, xc, yc,
(xc + rect.Width / 2 * Math.Cos(deg * 0.0174532925199433)),
(yc + rect.Height / 2 * Math.Sin(deg * 0.0174532925199433)));
#endif
double f = Math.Max(rect.Width / 2, rect.Height / 2);
for (double deg = 0; deg < 360; deg += 10)
gfx.DrawLine(XPens.Goldenrod, xc, yc,
(xc + f * Math.Cos(deg * 0.0174532925199433)),
(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, (xc + rect.Width / 2 * Math.Cos(a)), (yc + rect.Height / 2 * Math.Sin(a)));
//gfx.DrawLine(XPens.DarkGray, xc, yc, (xc + rect.Width / 2 * Math.Cos(b)), (yc + rect.Height / 2 * Math.Sin(b)));
#endif
gfx.Restore(state);
gfx.DrawRectangle(properties.Pen1.Pen, rect);
}
示例9: RenderPage
/// <summary>
/// Demonstrates the use of XGraphics.Transform.
/// </summary>
public override void RenderPage(XGraphics gfx)
{
//gfx.Clear(this.properties.General.BackColor.Color);
base.RenderPage(gfx);
gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));
Matrix matrix = new Matrix();
//matrix.Scale(2f, 1.5f);
//matrix.Translate(-200, -400);
//matrix.Rotate(45);
//matrix.Translate(200, 400);
//gfx.Transform = matrix;
//gfx.TranslateTransform(50, 30);
#if true
gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
bool id = matrix.IsIdentity;
matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
//matrix.Translate(30, -50);
matrix.Rotate(15, MatrixOrder.Prepend);
//Matrix mtx = gfx.Transform.ToGdiMatrix();
//gfx.Transform = matrix;
gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));
}
示例10: Draw
public void Draw(XGraphics gfx)
{
string s = "Testtext";
//gfx.DrawLine(XPens.GreenYellow, 5, 100, 30, 50);
//gfx.DrawEllipse(XBrushes.DarkBlue, new XRect(30, 40, 250, 235));
XFont font = new XFont("Arial", 40, XFontStyle.Italic);
gfx.DrawString(s, font, XBrushes.Firebrick, 40, 60);
XSize size = gfx.MeasureString(s, font);
gfx.DrawLine(XPens.DarkBlue, 40, 60, 40 + size.Width, 60);
gfx.DrawLine(XPens.DarkBlue, 40, 60, 40, 60 + size.Height);
}
示例11: RenderPage
/// <summary>
/// Demonstrates the use of XGraphics.Transform.
/// </summary>
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
//XGraphicsState state = gfx.Save();
gfx.Save();
gfx.IntersectClip(new XRect(20, 20, 300, 500));
gfx.DrawRectangle(XBrushes.Yellow, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);
gfx.Restore();
gfx.Save();
gfx.IntersectClip(new XRect(100, 200, 300, 500));
gfx.DrawRectangle(XBrushes.LightBlue, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);
gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));
Matrix matrix = new Matrix();
//matrix.Scale(2f, 1.5f);
//matrix.Translate(-200, -400);
//matrix.Rotate(45);
//matrix.Translate(200, 400);
//gfx.Transform = matrix;
//gfx.TranslateTransform(50, 30);
#if true
gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
bool id = matrix.IsIdentity;
matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
//matrix.Translate(30, -50);
matrix.Rotate(15, MatrixOrder.Prepend);
//Matrix mtx = gfx.Transform.ToGdiMatrix();
//gfx.Transform = matrix;
gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));
gfx.Restore();
gfx.DrawLine(XPens.Red, 0, 0, 1000, 1000);
gfx.DrawPolygon(XPens.SandyBrown, GetPentagram(75, new PointF(150, 200)));
}
示例12: RenderPage
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
string facename = "Times";
XFont fontR = new XFont(facename, 40);
XFont fontB = new XFont(facename, 40, XFontStyle.Bold);
XFont fontI = new XFont(facename, 40, XFontStyle.Italic);
XFont fontBI = new XFont(facename, 40, XFontStyle.Bold | XFontStyle.Italic);
//gfx.DrawString("Hello", this.properties.Font1.Font, this.properties.Font1.Brush, 200, 200);
double x = 80;
XPen pen = XPens.SlateBlue;
gfx.DrawLine(pen, x, 100, x, 600);
gfx.DrawLine(pen, x - 50, 200, 400, 200);
gfx.DrawLine(pen, x - 50, 300, 400, 300);
gfx.DrawLine(pen, x - 50, 400, 400, 400);
gfx.DrawLine(pen, x - 50, 500, 400, 500);
double lineSpace = fontR.GetHeight(gfx);
int cellSpace = fontR.FontFamily.GetLineSpacing(fontR.Style);
int cellAscent = fontR.FontFamily.GetCellAscent(fontR.Style);
int cellDescent = fontR.FontFamily.GetCellDescent(fontR.Style);
double cyAscent = lineSpace * cellAscent / cellSpace;
XFontMetrics metrics = fontR.Metrics;
XSize size;
gfx.DrawString("Times 40", fontR, this.properties.Font1.Brush, x, 200);
size = gfx.MeasureString("Times 40", fontR);
//gfx.DrawLine(this.properties.Pen3.Pen, x, 200, x + size.Width, 200);
gfx.DrawString("Times bold 40", fontB, this.properties.Font1.Brush, x, 300);
size = gfx.MeasureString("Times bold 40", fontB);
//gfx.DrawLine(this.properties.Pen3.Pen, x, 300, x + size.Width, 300);
gfx.DrawString("Times italic 40", fontI, this.properties.Font1.Brush, x, 400);
size = gfx.MeasureString("Times italic 40", fontI);
//gfx.DrawLine(this.properties.Pen3.Pen, x, 400, x + size.Width, 400);
gfx.DrawString("Times bold italic 40", fontBI, this.properties.Font1.Brush, x, 500);
size = gfx.MeasureString("Times bold italic 40", fontBI);
//gfx.DrawLine(this.properties.Pen3.Pen, x, 500, x + size.Width, 500);
#if true
// Check Malayalam
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
XFont Kartika = new XFont("Kartika", 20, XFontStyle.Regular, options);
XFont AnjaliOldLipi = new XFont("AnjaliOldLipi", 20, XFontStyle.Regular, options);
gfx.DrawString("മകനെ ഇത് ഇന്ത്യയുടെ ഭൂപടം", Kartika, this.properties.Font1.Brush, x, 600);
gfx.DrawString("മകനെ ഇത് ഇന്ത്യയുടെ ഭൂപടം", AnjaliOldLipi, this.properties.Font1.Brush, x, 650);
#endif
}
示例13: DrawEdge
private static void DrawEdge(XGraphics g, Edge e, LayoutProvider layout, NetworkColorizer colorizer)
{
Vector3 p1 = layout.GetPositionOfNode(e.Source);
Vector3 p2 = layout.GetPositionOfNode(e.Target);
g.DrawLine(new Pen(colorizer[e], 0.05f), p1.X, p1.Y, p2.X, p2.Y);
}
示例14: RenderPage
public override void RenderPage(XGraphics gfx)
{
//base.RenderPage(gfx);
XFont font1 = new XFont("Arial", 9);
XFont font2 = new XFont("Arial", 9, XFontStyle.Italic);
XFont font3 = new XFont("Arial", 9, XFontStyle.Bold);
XSolidBrush brush = new XSolidBrush(XColors.Black);
gfx.DrawString("Page 5", font1, brush, 100, 100);
gfx.DrawString("Water Sports You've Done continued", font2, brush, 100, 200);
gfx.DrawString("Rowing", font1, brush, 100, 250);
gfx.DrawString("Snorkeling", font1, brush, 100, 300);
gfx.DrawString("WINTER SPORTS, SKIING, SKIING IN THE US", font3, XBrushes.Red, 100, 320);
gfx.DrawLine(XPens.Red, 100, 100, 200, 200);
gfx.DrawString("Resorts You've Skied in Vermont", font3, brush, 100, 400);
gfx.DrawString("Haystack", font1, brush, 100, 420);
// string text = "TgfÄÖÜWi9";
// if (this.properties.Font1.Text != "")
// text = this.properties.Font1.Text;
// float x = 100, y = 300;
// string familyName = properties.Font1.FamilyName;
// XFontStyle style = this.properties.Font1.Style;
// float emSize = this.properties.Font1.Size;
// XFont font = CreateFont(familyName, emSize, style);
// font = this.properties.Font1.Font;
// XSize size = gfx.MeasureString(text, font);
// double lineSpace = font.GetHeight(gfx);
// int cellSpace = font.FontFamily.GetLineSpacing(style);
// int cellAscent = font.FontFamily.GetCellAscent(style);
// int cellDescent = font.FontFamily.GetCellDescent(style);
// int cellLeading = cellSpace - cellAscent - cellDescent;
// double ascent = lineSpace * cellAscent / cellSpace;
// gfx.DrawRectangle(XBrushes.Bisque, x, y - ascent, size.Width, ascent);
// double descent = lineSpace * cellDescent / cellSpace;
// gfx.DrawRectangle(XBrushes.LightGreen, x, y, size.Width, descent);
// double leading = lineSpace * cellLeading / cellSpace;
// gfx.DrawRectangle(XBrushes.Yellow, x, y + descent, size.Width, leading);
// //gfx.DrawRectangle(this.properties.Brush1.Brush, x, y - size.Height, size.Width, size.Height);
// //gfx.DrawLine(this.properties.Pen2.Pen, x, y, x + size.Width, y);
// //gfx.DrawString("Hello", this.properties.Font1.Font, this.properties.Font1.Brush, 200, 200);
//#if true_
// XPdfFontOptions pdfOptions = new XPdfFontOptions(false, true);
// font = new XFont("Tahoma", 8, XFontStyle.Regular, pdfOptions);
// text = "Hallo";
// text = chinese;
//#endif
// gfx.DrawString(text, font, this.properties.Font1.Brush, x, y);
// gfx.DrawLine(XPens.Red, 0, 0, 100, 100);
// gfx.DrawString(text, font, this.properties.Font1.Brush, x, y + 20);
}
示例15: 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);
}