本文整理汇总了C#中PdfSharp.Drawing.XGraphics.DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# XGraphics.DrawRectangle方法的具体用法?C# XGraphics.DrawRectangle怎么用?C# XGraphics.DrawRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfSharp.Drawing.XGraphics
的用法示例。
在下文中一共展示了XGraphics.DrawRectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderEllipses
void RenderEllipses(XGraphics gfx)
{
gfx.TranslateTransform(15, 20);
XPen pen = new XPen(XColors.Navy, Math.PI);
gfx.DrawRectangle(pen, 10, 0, 100, 60);
gfx.DrawRectangle(XBrushes.DarkOrange, 130, 0, 100, 60);
gfx.DrawRectangle(pen, XBrushes.DarkOrange, 10, 80, 100, 60);
gfx.DrawRectangle(pen, XBrushes.DarkOrange, 150, 80, 60, 60);
}
示例2: DrawRectangle
/// <summary>
/// Draws rectangles.
/// </summary>
void DrawRectangle(XGraphics gfx, int number)
{
BeginBox(gfx, number, "DrawRectangle");
XPen pen = new XPen(XColors.Navy, Math.PI);
gfx.DrawRectangle(pen, 10, 0, 100, 60);
gfx.DrawRectangle(XBrushes.DarkOrange, 130, 0, 100, 60);
gfx.DrawRectangle(pen, XBrushes.DarkOrange, 10, 80, 100, 60);
gfx.DrawRectangle(pen, XBrushes.DarkOrange, 150, 80, 60, 60);
EndBox(gfx);
}
示例3: BeginBox
/// <summary>
/// Draws a sample box.
/// </summary>
public void BeginBox(XGraphics gfx, int number)
{
//obracene XY
gfx.RotateAtTransform(90.0, new XPoint(height / 4, width / 4));
gfx.TranslateTransform(+62, +63);
//const int dEllipse = 15;
XRect rect = new XRect(0, 0, height /2 -2, width/2 -2);
if (number % 2 == 0)
rect.X += height/2 +2;
rect.Y = ((number - 1) / 2) * (-width/2 - 3);
//rect.Inflate(-10, -10);
//XRect rect2 = rect;
XPen pen = new XPen(XColors.Black, 1);
gfx.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
//rect2.Offset(this.borderWidth, this.borderWidth);
//gfx.DrawRoundedRectangle(new XSolidBrush(this.shadowColor), rect2, new XSize(dEllipse + 8, dEllipse + 8));
//XLinearGradientBrush brush = new XLinearGradientBrush(rect, this.backColor, this.backColor2, XLinearGradientMode.Vertical);
//gfx.DrawRoundedRectangle(this.borderPen, brush, rect, new XSize(dEllipse, dEllipse));
//rect.Inflate(-5, -5);
//rect.Inflate(-10, -5);
//rect.Y += 20;
//rect.Height -= 20;
////gfx.DrawRectangle(XPens.Red, rect);
// gfx.TranslateTransform(rect.X, rect.Y);
this.state = gfx.Save();
}
示例4: 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
}
示例5: 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);
}
示例6: RenderMeasureText
void RenderMeasureText(XGraphics gfx)
{
gfx.TranslateTransform(15, 20);
XFontStyle style = XFontStyle.Regular;
XFont font = new XFont("Times New Roman", 95, style);
string text = "Hello";
double x = 20, y = 100;
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;
// Get effective ascent
double ascent = lineSpace * cellAscent / cellSpace;
gfx.DrawRectangle(XBrushes.Bisque, x, y - ascent, size.Width, ascent);
// Get effective descent
double descent = lineSpace * cellDescent / cellSpace;
gfx.DrawRectangle(XBrushes.LightGreen, x, y, size.Width, descent);
// Get effective leading
double leading = lineSpace * cellLeading / cellSpace;
gfx.DrawRectangle(XBrushes.Yellow, x, y + descent, size.Width, leading);
// Draw text half transparent
XColor color = XColors.DarkSlateBlue;
color.A = 0.6;
gfx.DrawString(text, font, new XSolidBrush(color), x, y);
}
示例7: RenderPage
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
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;
//familyName = "Verdana";
//style = XFontStyle.Regular;
//emSize = 20;
//text = "X";
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);
#if true
XFont font2 = CreateFont(familyName, emSize, XFontStyle.Italic);
gfx.DrawString(text, font2, this.properties.Font1.Brush, x, y+50);
#endif
//gfx.DrawLine(XPens.Red, x, y + 10, x + 13.7, y + 10);
//gfx.DrawString(text, font, this.properties.Font1.Brush, x, y + 20);
}
示例8: 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)));
}
示例9: RenderPage
/// <summary>
/// Demonstrates the use of XGraphics.DrawRectangle.
/// </summary>
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
// Stroke rectangle
gfx.DrawRectangle(properties.Pen1.Pen, 50, 100, 450, 150);
// Fill rectangle
gfx.DrawRectangle(properties.Brush2.Brush, new Rectangle(50, 300, 450, 150));
// Stroke and fill rectangle
gfx.DrawRectangle(properties.Pen1.Pen, properties.Brush2.Brush, new RectangleF(50, 500, 450, 150));
}
示例10: 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));
}
示例11: Draw
public void Draw(XGraphics gfx)
{
gfx.DrawRectangle(Pen, Brush, Rect);
double yOffset = 5;
//Print InputBox Title, Left Top corner
if (!string.IsNullOrEmpty(Title))
{
var titleLabel = new Label(Rect.X + 5, Rect.Y, Title)
{
Brush = XBrushes.Black,
Font = new XFont(Font.FontFamily.Name, 8, XFontStyle.Bold, Font.PdfOptions),
Pen = XPens.Black
};
titleLabel.Draw(gfx);
yOffset = 15;
}
//Print InputBox Value
if (!string.IsNullOrEmpty(Value))
{
var valLabel = new Label(new XRect(Rect.X + 10, Rect.Y + yOffset, Rect.Width, Rect.Height), Value)
{
Alignment = XParagraphAlignment.Left,
Brush = XBrushes.Black,
Font = new XFont(Font.FontFamily.Name, 12, XFontStyle.Regular, Font.PdfOptions),
Pen = XPens.Black,
};
valLabel.Draw(gfx);
yOffset += valLabel.Rect.Height;
}
}
示例12: 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)));
}
示例13: DrawCodePage
void DrawCodePage(XGraphics gfx, XPoint origin)
{
const double dx = 25;
const double dy = 25;
XFont labelFont = new XFont("Verdana", 10, XFontStyle.Bold);
//XFont font = new XFont("Bauhaus", 16);
XFont font = this.properties.Font1.Font;
//XFont labelFont = font;
//font = new XFont("Symbol", 16);
Encoding encoding = Encoding.GetEncoding(1252);
double asdf = XColors.LightGray.GS;
//XBrush lighter = new XSolidBrush(XColor.FromGrayScale(XColor.LightGray.GS * 1.1));
XBrush lighter = new XSolidBrush(XColor.FromGrayScale(0.9));
XFontStyle style = font.Style;
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;
double descent = lineSpace * cellDescent / cellSpace;
double leading = lineSpace * cellLeading / cellSpace;
double x = origin.X + dx;
double y = origin.Y;
//for (int idx = 0; idx < 16; idx++)
// gfx.DrawString("x" + idx.ToString("X"), labelFont, XBrushes.DarkGray, x + idx * dx, y);
for (int row = 0; row < 16; row++)
{
x = origin.X;
y += dy;
//gfx.DrawString(row.ToString("X") + "x", labelFont, XBrushes.DarkGray, x, y);
for (int clm = 0; clm < 16; clm++)
{
x += dx;
string glyph = encoding.GetString(new byte[1]{Convert.ToByte(row * 16 + clm)});
glyph += "!";
XSize size = gfx.MeasureString(glyph, font);
gfx.DrawRectangle(XBrushes.LightGray, x, y - size.Height + descent, size.Width, size.Height);
gfx.DrawRectangle(lighter, x, y - size.Height + descent, size.Width, leading);
gfx.DrawRectangle(lighter, x, y, size.Width, descent);
gfx.DrawString(glyph, font, XBrushes.Black, x, y);
}
}
}
示例14: Render
public void Render(XGraphics gfx, FixedElement element)
{
var spec = (Backgrounded) element.Specification;
if (spec.BackgroundColor != Colors.Transparent)
{
var backgroundBrush = new XSolidBrush(XColor.FromArgb(spec.BackgroundColor));
gfx.DrawRectangle(backgroundBrush,
element.InnerBox.Left.Points,
element.InnerBox.Top.Points,
element.InnerBox.Width.Points,
element.InnerBox.Height.Points);
}
}
示例15: RenderClipPath
void RenderClipPath(XGraphics gfx)
{
gfx.TranslateTransform(15, 20);
XGraphicsPath path = new XGraphicsPath();
path.AddString("Clip!", new XFontFamily("Verdana"), XFontStyle.Bold, 90, new XRect(0, 0, 250, 140),
XStringFormats.Center);
gfx.IntersectClip(path);
gfx.DrawRectangle(XBrushes.LightSalmon, new XRect(0, 0, 10000, 10000));
// Draw a beam of dotted lines
XPen pen = XPens.DarkRed.Clone();
pen.DashStyle = XDashStyle.Dot;
for (double r = 0; r <= 90; r += 0.5)
gfx.DrawLine(pen, 0, 0, 1000 * Math.Cos(r / 90 * Math.PI), 1000 * Math.Sin(r / 90 * Math.PI));
}