本文整理汇总了C#中Pen.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# Pen.Freeze方法的具体用法?C# Pen.Freeze怎么用?C# Pen.Freeze使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pen
的用法示例。
在下文中一共展示了Pen.Freeze方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPen
static Pen GetPen(object lockObj, Dictionary<double, Pen> penDictionary, double thickness, PenLineJoin lineJoin, Brush brush=null)
{
lock (lockObj)
{
thickness = Math.Round(thickness, 1);
if (!penDictionary.ContainsKey(thickness))
{
Pen pen = new Pen(brush ?? Brushes.Black, thickness);
pen.LineJoin = lineJoin;
pen.Freeze();
penDictionary.Add(thickness, pen);
}
return penDictionary[thickness];
}
}
示例2: CreateSolidPen
// Create a solid pen
public static Pen CreateSolidPen(Color color, float thickness, LineStyle style)
{
#if false
Pen pen = new Pen(new SolidColorBrush(color), thickness);
if (style == LineStyle.Rounded) {
pen.StartLineCap = pen.EndLineCap = PenLineCap.Round;
pen.LineJoin = PenLineJoin.Round;
}
else if (style == LineStyle.Beveled) {
pen.StartLineCap = pen.EndLineCap = PenLineCap.Flat;
pen.LineJoin = PenLineJoin.Bevel;
}
else if (style == LineStyle.Mitered) {
pen.StartLineCap = pen.EndLineCap = PenLineCap.Flat;
pen.LineJoin = PenLineJoin.Miter;
pen.MiterLimit = MITER_LIMIT;
}
else if (style == LineStyle.FlatRounded) {
pen.StartLineCap = pen.EndLineCap = PenLineCap.Flat;
pen.LineJoin = PenLineJoin.Round;
}
pen.Freeze();
return pen;
#else
Pen pen = new Pen(color, thickness);
if (style == LineStyle.Rounded) {
pen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Flat);
pen.LineJoin = LineJoin.Round;
}
else if (style == LineStyle.Beveled) {
pen.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
pen.LineJoin = LineJoin.Bevel;
}
else if (style == LineStyle.Mitered) {
pen.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
pen.LineJoin = LineJoin.Miter;
pen.MiterLimit = MITER_LIMIT;
}
else if (style == LineStyle.FlatRounded) {
pen.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
pen.LineJoin = LineJoin.Round;
}
return pen;
#endif
}