本文整理汇总了C#中System.Windows.Media.Brush.?.GetBrush方法的典型用法代码示例。如果您正苦于以下问题:C# Brush.?.GetBrush方法的具体用法?C# Brush.?.GetBrush怎么用?C# Brush.?.GetBrush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Brush
的用法示例。
在下文中一共展示了Brush.?.GetBrush方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawText
public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
{
var formattedText = new FormattedText(text, CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, font.GetTypeface(), font.Size, null);
formattedText.SetForegroundBrush(brush?.GetBrush());
dc.DrawText(formattedText, frame.BottomLeft.GetPoint());
}
示例2: DrawPath
public void DrawPath(IEnumerable<PathOp> ops, Pen pen = null, Brush brush = null)
{
StreamGeometry streamGeometry = new StreamGeometry();
using (StreamGeometryContext geometryContext = streamGeometry.Open())
{
foreach (var op in ops)
{
var mt = op as MoveTo;
if (mt != null)
{
geometryContext.BeginFigure(mt.Point.GetPoint(), false, false);
continue;
}
var lt = op as LineTo;
if (lt != null)
{
geometryContext.LineTo(lt.Point.GetPoint(), true, false);
continue;
}
var at = op as ArcTo;
if (at != null)
{
/*
Point c1, c2;
at.GetCircles(pp, out c1, out c2);
var circleCenter = at.LargeArc ^ !at.SweepClockwise ? c2 : c1;
var rotationAngle = (float)Math.Atan2(at.Point.Y - circleCenter.Y, at.Point.X - circleCenter.X);
geometryContext.ArcTo(at.Point.GetPoint(), at.Radius.GetSize(), rotationAngle,
at.LargeArc, at.SweepClockwise ? SweepDirection.Clockwise : SweepDirection.Counterclockwise,
true, false
);*/
throw new NotImplementedException();
}
var ct = op as CurveTo;
if (ct != null)
{
geometryContext.BezierTo(ct.Control1.GetPoint(), ct.Control2.GetPoint(), ct.Point.GetPoint(), true, false);
}
throw new NotSupportedException();
}
}
dc.DrawGeometry(brush?.GetBrush(), pen?.GetPen(), streamGeometry);
}
示例3: DrawRectangle
public void DrawRectangle(Rect frame, Pen pen = null, Brush brush = null)
{
dc.DrawRectangle(brush?.GetBrush(), pen?.GetPen(), frame.GetRect());
}
示例4: DrawEllipse
public void DrawEllipse(Rect frame, Pen pen = null, Brush brush = null)
{
dc.DrawEllipse(brush?.GetBrush(), pen?.GetPen(), frame.Center.GetPoint(), frame.Width / 2, frame.Height / 2);
}