Exemplo n.º 1
0
        private Pen GetPen(LineStyle lineStyle)
        {
            if (lineStyle == null || lineStyle.Type == LineType.None || lineStyle.Width == 0)
            {
                return(null);
            }
            if (lineStyle.Type == LineType.Solid)
            {
                return(new Pen(new SolidColorBrush(lineStyle.Color.Argb), lineStyle.Width));
            }
            IDashStyle dashStyle = null;

            switch (lineStyle.Type)
            {
            case LineType.DashDot:
                dashStyle = DashStyle.DashDot;
                break;

            case LineType.DashDotDot:
                dashStyle = DashStyle.DashDotDot;
                break;

            case LineType.Dot:
                dashStyle = DashStyle.Dot;
                break;

            default:
                dashStyle = DashStyle.Dash;
                break;
            }
            return(new Pen(new SolidColorBrush(lineStyle.Color.Argb), lineStyle.Width, dashStyle));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pen"/> class.
 /// </summary>
 /// <param name="color">The stroke color.</param>
 /// <param name="thickness">The stroke thickness.</param>
 /// <param name="dashStyle">The dash style.</param>
 /// <param name="lineCap">Specifies the type of graphic shape to use on both ends of a line.</param>
 /// <param name="lineJoin">The line join.</param>
 /// <param name="miterLimit">The miter limit.</param>
 public Pen(
     uint color,
     double thickness     = 1.0,
     IDashStyle dashStyle = null,
     PenLineCap lineCap   = PenLineCap.Flat,
     PenLineJoin lineJoin = PenLineJoin.Miter,
     double miterLimit    = 10.0) : this(new SolidColorBrush(color), thickness, dashStyle, lineCap, lineJoin, miterLimit)
 {
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pen"/> class.
 /// </summary>
 /// <param name="brush">The brush used to draw.</param>
 /// <param name="thickness">The stroke thickness.</param>
 /// <param name="dashStyle">The dash style.</param>
 /// <param name="lineCap">The line cap.</param>
 /// <param name="lineJoin">The line join.</param>
 /// <param name="miterLimit">The miter limit.</param>
 public Pen(
     IBrush brush,
     double thickness     = 1.0,
     IDashStyle dashStyle = null,
     PenLineCap lineCap   = PenLineCap.Flat,
     PenLineJoin lineJoin = PenLineJoin.Miter,
     double miterLimit    = 10.0)
 {
     Brush      = brush;
     Thickness  = thickness;
     LineCap    = lineCap;
     LineJoin   = lineJoin;
     MiterLimit = miterLimit;
     DashStyle  = dashStyle;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Converts a dash style to an immutable dash style.
        /// </summary>
        /// <param name="style">The dash style.</param>
        /// <returns>
        /// The result of calling <see cref="DashStyle.ToImmutable"/> if the style is mutable,
        /// otherwise <paramref name="style"/>.
        /// </returns>
        public static ImmutableDashStyle ToImmutable(this IDashStyle style)
        {
            _ = style ?? throw new ArgumentNullException(nameof(style));

            return(style as ImmutableDashStyle ?? ((DashStyle)style).ToImmutable());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Converts a dash style to an immutable dash style.
        /// </summary>
        /// <param name="style">The dash style.</param>
        /// <returns>
        /// The result of calling <see cref="DashStyle.ToImmutable"/> if the style is mutable,
        /// otherwise <paramref name="style"/>.
        /// </returns>
        public static ImmutableDashStyle ToImmutable(this IDashStyle style)
        {
            Contract.Requires <ArgumentNullException>(style != null);

            return(style as ImmutableDashStyle ?? ((DashStyle)style).ToImmutable());
        }