本文整理汇总了C#中PdfSharp.Drawing.XGraphics.ScaleTransform方法的典型用法代码示例。如果您正苦于以下问题:C# XGraphics.ScaleTransform方法的具体用法?C# XGraphics.ScaleTransform怎么用?C# XGraphics.ScaleTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfSharp.Drawing.XGraphics
的用法示例。
在下文中一共展示了XGraphics.ScaleTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: 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)));
}
示例3: 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)));
}
示例4: PrintLogo
private static void PrintLogo(XGraphics gfx)
{
try
{
XImage image = XImage.FromFile("Logo.jpg");
const double dx = 350, dy = 140;
//gfx.TranslateTransform(dx / 2, dy / 2);
gfx.ScaleTransform(0.5);
//gfx.TranslateTransform(-dx / 2, -dy / 2);
double width = image.PixelWidth * 72 / image.HorizontalResolution;
double height = image.PixelHeight * 72 / image.HorizontalResolution;
gfx.DrawImage(image, 5, 5, dx, dy);
}
catch (Exception ex)
{
Logger.LogException(ex);
}
}
示例5: RenderPage
/// <summary>
/// Demonstrates the use of XLinearGradientBrush.
/// </summary>
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
XRect rect;
XLinearGradientBrush brush;
Graphics grfx = gfx.Internals.Graphics;
XLinearGradientBrush brush2 =
new XLinearGradientBrush(
new XPoint(100, 100),
new XPoint(300, 300),
XColors.DarkRed, XColors.Yellow);
//gfx.FillRectangle(brush, 0, 0, 600, 600);
//gfx.TranslateTransform(35, 200);
//gfx.RotateTransform(17);
rect = new XRect(20, 50, 100, 200);
brush = new XLinearGradientBrush(rect,
XColors.DarkRed, XColors.Yellow, XLinearGradientMode.Horizontal);
gfx.DrawRectangle(XPens.Red, brush, rect);
rect = new XRect(140, 50, 100, 200);
brush = new XLinearGradientBrush(rect,
XColors.DarkRed, XColors.Yellow, XLinearGradientMode.Vertical);
gfx.DrawRectangle(XPens.Red, brush, rect);
rect = new XRect(260, 50, 100, 200);
brush = new XLinearGradientBrush(rect,
XColors.DarkRed, XColors.Yellow, XLinearGradientMode.ForwardDiagonal);
gfx.DrawRectangle(XPens.Red, brush, rect);
rect = new XRect(380, 50, 100, 200);
brush = new XLinearGradientBrush(rect,
XColors.DarkRed, XColors.Yellow, XLinearGradientMode.BackwardDiagonal);
gfx.DrawRectangle(XPens.Red, brush, rect);
gfx.TranslateTransform(80, 250);
gfx.ScaleTransform(1.1);
gfx.RotateTransform(20);
rect = new XRect(20, 50, 100, 200);
brush = new XLinearGradientBrush(rect,
XColors.Orange, XColors.DarkBlue, XLinearGradientMode.Horizontal);
gfx.DrawRectangle(XPens.Red, brush, rect);
rect = new XRect(140, 50, 100, 200);
brush = new XLinearGradientBrush(rect,
XColors.Orange, XColors.DarkBlue, XLinearGradientMode.Vertical);
gfx.DrawRectangle(XPens.Red, brush, rect);
rect = new XRect(260, 50, 100, 200);
brush = new XLinearGradientBrush(rect,
XColors.Orange, XColors.DarkBlue, XLinearGradientMode.ForwardDiagonal);
gfx.DrawRectangle(XPens.Red, brush, rect);
rect = new XRect(380, 50, 100, 200);
brush = new XLinearGradientBrush(rect,
XColors.Orange, XColors.DarkBlue, XLinearGradientMode.BackwardDiagonal);
gfx.DrawRectangle(XPens.Red, brush, rect);
}
示例6: RenderPage
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
PointF[] origins = new PointF[]
{
new PointF(100, 200), new PointF(300, 200),
new PointF(100, 400), new PointF(300, 400),
new PointF(100, 600), new PointF(350, 600),
};
PointF origin;
XGraphicsContainer container;
float length = 100;
// Not transformed
origin = origins[0];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, origin);
// Translation
container = gfx.BeginContainer(new RectangleF(10, 10, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
origin = origins[1];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(20, -30);
DrawAxes(gfx, XPens.DarkGray, origin, length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, origin);
gfx.EndContainer(container);
// Scaling
container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
origin = origins[2];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.ScaleTransform(1.3f, 1.5f);
DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0, 0);
gfx.EndContainer(container);
// Rotation
container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
origin = origins[3];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.RotateTransform(-45);
DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0 , 0);
gfx.EndContainer(container);
// Skewing (or shearing)
container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
origin = origins[4];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.MultiplyTransform(new Matrix(1, -0.3f, -0.4f, 1, 0, 0));
DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0 , 0);
gfx.EndContainer(container);
// Reflection
container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
origin = origins[5];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.MultiplyTransform(new Matrix(-1, 0, 0, -1, 0, 0));
DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0 , 0);
gfx.EndContainer(container);
}
示例7: Paint
public void Paint(XGraphics graphics, RectangleF rect, MapOptions options, Color dotColor, XBrush labelBrush, XFont labelFont)
{
if (graphics == null)
throw new ArgumentNullException("graphics");
Point pt = Astrometrics.LocationToCoordinates(Location);
using (RenderUtil.SaveState(graphics))
{
graphics.SmoothingMode = XSmoothingMode.HighSpeed;
graphics.TranslateTransform(pt.X, pt.Y);
graphics.ScaleTransform(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);
const float radius = 3;
XBrush brush = new XSolidBrush(dotColor);
XPen pen = new XPen(dotColor);
graphics.DrawEllipse(brush, -radius / 2, -radius / 2, radius, radius);
graphics.SmoothingMode = XSmoothingMode.HighQuality;
graphics.DrawEllipse(pen, -radius / 2, -radius / 2, radius, radius);
XStringFormat format = (LabelBiasX == -1) ? RenderUtil.StringFormatTopRight :
(LabelBiasX == 1) ? RenderUtil.StringFormatTopLeft : RenderUtil.StringFormatTopCenter;
XSize size = graphics.MeasureString(Name, labelFont);
XPoint pos = new XPoint(0, 0);
//pos.X += ( LabelBiasX * radius / 2 ) + ( -size.Width * ( 1 - LabelBiasX ) / 2.0f );
pos.Y += (LabelBiasY * radius / 2) + (-size.Height * (1 - LabelBiasY) / 2.0f);
pos.X += (LabelBiasX * radius / 2);
//pos.Y += ( LabelBiasY * radius / 2 );
graphics.DrawString(Name, labelFont, labelBrush, pos.X, pos.Y, format);
}
}
示例8: DrawLabel
public static void DrawLabel(XGraphics g, string text, PointF labelPos, XFont font, XBrush brush, LabelStyle labelStyle)
{
using (RenderUtil.SaveState(g))
{
if (labelStyle.Uppercase)
text = text.ToUpper();
if (labelStyle.Wrap)
text = text.Replace(' ', '\n');
g.TranslateTransform(labelPos.X, labelPos.Y);
g.ScaleTransform(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);
g.TranslateTransform(labelStyle.Translation.X, labelStyle.Translation.Y);
g.RotateTransform(labelStyle.Rotation);
g.ScaleTransform(labelStyle.Scale.Width, labelStyle.Scale.Height);
if (labelStyle.Rotation != 0)
g.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
XSize size = g.MeasureString(text, font);
size.Width *= 2; // prevent cut-off e.g. when rotated
XRect bounds = new XRect(-size.Width / 2, -size.Height / 2, size.Width, size.Height);
XTextFormatter tf = new XTextFormatter(g);
tf.Alignment = XParagraphAlignment.Center;
tf.DrawString(text, font, brush, bounds);
}
}
示例9: DrawImageRotated
/// <summary>
/// Draws an image transformed.
/// </summary>
void DrawImageRotated(XGraphics gfx, int number)
{
BeginBox(gfx, number, "DrawImage (rotated)");
XImage image = XImage.FromFile(jpegSamplePath);
const double dx = 250, dy = 140;
gfx.TranslateTransform(dx / 2, dy / 2);
gfx.ScaleTransform(0.7);
gfx.RotateTransform(-25);
gfx.TranslateTransform(-dx / 2, -dy / 2);
//XMatrix matrix = new XMatrix(); //XMatrix.Identity;
double width = image.PixelWidth * 72 / image.HorizontalResolution;
double height = image.PixelHeight * 72 / image.HorizontalResolution;
gfx.DrawImage(image, (dx - width) / 2, 0, width, height);
EndBox(gfx);
}
示例10: DrawFormXObject
/// <summary>
/// Draws a form XObject (a page from an external PDF file).
/// </summary>
void DrawFormXObject(XGraphics gfx, int number)
{
//this.backColor = XColors.LightSalmon;
BeginBox(gfx, number, "DrawImage (Form XObject)");
XImage image = XImage.FromFile(pdfSamplePath);
const double dx = 250, dy = 140;
gfx.TranslateTransform(dx / 2, dy / 2);
gfx.ScaleTransform(0.35);
gfx.TranslateTransform(-dx / 2, -dy / 2);
double width = image.PixelWidth * 72 / image.HorizontalResolution;
double height = image.PixelHeight * 72 / image.HorizontalResolution;
gfx.DrawImage(image, (dx - width) / 2, (dy - height) / 2, width, height);
EndBox(gfx);
}
示例11: DrawImageSheared
/// <summary>
/// Draws an image transformed.
/// </summary>
void DrawImageSheared(XGraphics gfx, int number)
{
BeginBox(gfx, number, "DrawImage (sheared)");
XImage image = XImage.FromFile(jpegSamplePath);
const double dx = 250, dy = 140;
//XMatrix matrix = gfx.Transform;
//matrix.TranslatePrepend(dx / 2, dy / 2);
//matrix.ScalePrepend(-0.7, 0.7);
//matrix.ShearPrepend(-0.4, -0.3);
//matrix.TranslatePrepend(-dx / 2, -dy / 2);
//gfx.Transform = matrix;
gfx.TranslateTransform(dx / 2, dy / 2);
gfx.ScaleTransform(-0.7, 0.7);
gfx.ShearTransform(-0.4, -0.3);
gfx.TranslateTransform(-dx / 2, -dy / 2);
double width = image.PixelWidth * 72 / image.HorizontalResolution;
double height = image.PixelHeight * 72 / image.HorizontalResolution;
gfx.DrawImage(image, (dx - width) / 2, 0, width, height);
EndBox(gfx);
}
示例12: DrawChevron
public static void DrawChevron(XGraphics graphics, PointF pos, float angle, float size, Brush fillBrush)
{
if (m_chevronPath == null)
{
var apex = new PointF(0.5f, 0);
var leftCorner = new PointF(-0.5f, 0.5f);
var rightCorner = new PointF(-0.5f, -0.5f);
m_chevronPath = new XGraphicsPath();
m_chevronPath.AddLine(apex, rightCorner);
m_chevronPath.AddLine(rightCorner, leftCorner);
m_chevronPath.AddLine(leftCorner, apex);
}
var state = graphics.Save();
graphics.TranslateTransform(pos.X, pos.Y);
graphics.RotateTransform(angle);
graphics.ScaleTransform(size, size);
graphics.DrawPath(fillBrush, m_chevronPath);
graphics.Restore(state);
}
示例13: DrawPngRotated
/// <summary>
/// Draws a PNG image with transparency.
/// </summary>
public void DrawPngRotated(XGraphics gfx, int number, XImage pngImage)
{
//BeginBox(gfx, number, "DrawImage (PNG)");
XImage image = pngImage;
//const double dx = 250, dy = 140;
//double width = image.PixelWidth * 72 / image.HorizontalResolution;
//double height = image.PixelHeight * 72 / image.HorizontalResolution;
//gfx.DrawImage(image, (dx - width) / 2, (dy - height) / 2, width, height);
const double dx = 250, dy = 140;
gfx.TranslateTransform(dx / 2, dy / 2);
gfx.ScaleTransform(0.7);
gfx.RotateTransform(-25);
gfx.TranslateTransform(-dx / 2, -dy / 2);
double width = image.PixelWidth * 72 / image.HorizontalResolution;
double height = image.PixelHeight * 72 / image.HorizontalResolution;
gfx.DrawImage(image, 0, 0, width, height);
//gfx.DrawImage(image, 0, 0, width, height);
//EndBox(gfx);
}
示例14: InitializeCoordinates
void InitializeCoordinates(XGraphics gfx)
{
double width = 600;
double height = 800;
gfx.TranslateTransform(width / 2, height / 2);
//float fInches = Math.Min(width / gfx.DpiX, height / gfx.DpiY);
double fInches = Math.Min(width, height);
gfx.ScaleTransform(fInches * 1 / 2000);
}
示例15: RenderPage
public override void RenderPage(XGraphics gfx)
{
//base.RenderPage(gfx);
XPoint[] origins = new XPoint[]
{
new XPoint(100, 200), new XPoint(300, 200),
new XPoint(100, 400), new XPoint(300, 400),
new XPoint(100, 600), new XPoint(350, 600),
};
XPoint origin;
XGraphicsState state;
float length = 100;
// Not transformed
origin = origins[0];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, origin);
// Translation
state = gfx.Save();
origin = origins[1];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(20, -30);
DrawAxes(gfx, XPens.DarkGray, origin, length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, origin);
gfx.Restore(state);
#if true
// Scaling
state = gfx.Save();
origin = origins[2];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.ScaleTransform(1.3, 1.5);
DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0, 0);
gfx.Restore(state);
// Rotation
state = gfx.Save();
origin = origins[3];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.RotateTransform(-45);
DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0, 0);
gfx.Restore(state);
// Skewing (or shearing)
state = gfx.Save();
origin = origins[4];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.MultiplyTransform(new Matrix(1, -0.3f, -0.4f, 1, 0, 0));
DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0, 0);
gfx.Restore(state);
// Reflection
state = gfx.Save();
origin = origins[5];
DrawAxes(gfx, XPens.Black, origin, length);
gfx.TranslateTransform(origin.X, origin.Y);
gfx.MultiplyTransform(new Matrix(-1, 0, 0, -1, 0, 0));
DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0, 0);
gfx.Restore(state);
#endif
}