本文整理汇总了C#中DrawingContext.DrawString方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.DrawString方法的具体用法?C# DrawingContext.DrawString怎么用?C# DrawingContext.DrawString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawingContext
的用法示例。
在下文中一共展示了DrawingContext.DrawString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawOverride
/// <inheritdoc/>
protected override void DrawOverride(UltravioletTime time, DrawingContext dc)
{
var font = Font;
if (font.IsLoaded)
{
View.Resources.StringFormatter.Reset();
View.Resources.StringFormatter.AddArgument(Value);
View.Resources.StringFormatter.Format(Format ?? "{0}", View.Resources.StringBuffer);
var face = font.Resource.Value.GetFace(FontStyle);
var position = Display.DipsToPixels(UntransformedAbsolutePosition);
var positionRounded = dc.IsTransformed ? (Vector2)position : (Vector2)(Point2)position;
dc.DrawString(face, View.Resources.StringBuffer, positionRounded, Foreground);
}
base.DrawOverride(time, dc);
}
示例2: DrawOverride
/// <inheritdoc/>
protected override void DrawOverride(UltravioletTime time, DrawingContext dc)
{
var font = Font;
if (font.IsLoaded)
{
View.Resources.StringFormatter.Reset();
View.Resources.StringFormatter.AddArgument(Value);
View.Resources.StringFormatter.Format(Format ?? "{0}", View.Resources.StringBuffer);
var face = font.Resource.Value.GetFace(FontStyle);
var positionRaw = Display.DipsToPixels(UntransformedAbsolutePosition);
var positionX = dc.IsTransformed ? positionRaw.X : Math.Round(positionRaw.X, MidpointRounding.AwayFromZero);
var positionY = dc.IsTransformed ? positionRaw.Y : Math.Round(positionRaw.Y, MidpointRounding.AwayFromZero);
var position = new Vector2((Single)positionX, (Single)positionY);
dc.DrawString(face, View.Resources.StringBuffer, position, Foreground);
}
base.DrawOverride(time, dc);
}