本文整理汇总了C#中MatterHackers.Agg.Graphics2D.PopTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics2D.PopTransform方法的具体用法?C# Graphics2D.PopTransform怎么用?C# Graphics2D.PopTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatterHackers.Agg.Graphics2D
的用法示例。
在下文中一共展示了Graphics2D.PopTransform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDraw
public override void OnDraw(Graphics2D graphics2D)
{
graphics2D.PushTransform();
int numLines = Text.Split('\n').Length - 1;
if(Text.Contains("\r"))
{
throw new Exception("These should have be converted to \n.");
}
double yOffsetForText = Printer.TypeFaceStyle.EmSizeInPixels * numLines;
double xOffsetForText = 0;
switch (printer.Justification)
{
case Justification.Left:
break;
case Justification.Center:
xOffsetForText = (Width - Printer.LocalBounds.Width) / 2;
break;
case Justification.Right:
xOffsetForText = Width - Printer.LocalBounds.Width;
break;
default:
throw new NotImplementedException();
}
graphics2D.SetTransform(graphics2D.GetTransform() * Affine.NewTranslation(xOffsetForText, yOffsetForText));
RGBA_Bytes currentColor = this.textColor;
if (EllipsisIfClipped && Printer.LocalBounds.Width > LocalBounds.Width) // only do this if it's static text
{
TypeFacePrinter shortTextPrinter = Printer;
while (shortTextPrinter.LocalBounds.Width > LocalBounds.Width && shortTextPrinter.Text.Length > 4)
{
shortTextPrinter = new TypeFacePrinter(shortTextPrinter.Text.Substring(0, shortTextPrinter.Text.Length - 4).TrimEnd(spaceTrim) + "...", Printer);
}
shortTextPrinter.Render(graphics2D, currentColor);
}
else
{
// it all fits or it's editable (if editable it will need to be offset/scrolled sometimes).
Printer.Render(graphics2D, currentColor);
}
if (debugIt)
{
graphics2D.Line(-5, 0, 5, 0, RGBA_Bytes.Blue);
graphics2D.Line(0, -5, 0, 5, RGBA_Bytes.Blue);
}
graphics2D.PopTransform();
if (debugIt)
{
graphics2D.Line(-5, 0, 5, 0, RGBA_Bytes.Red);
graphics2D.Line(0, -5, 0, 5, RGBA_Bytes.Red);
}
base.OnDraw(graphics2D);
}