ToBrush() public abstract method

public abstract ToBrush ( SvgBaseElement element ) : System.Windows.Media.Brush
element SvgBaseElement
return System.Windows.Media.Brush
示例#1
0
        //==========================================================================
        public Pen GetPen()
        {
            if (Stroke == null)
            {
                return(null);
            }

            if (StrokeWidth.ToDouble() <= 0.0)
            {
                return(null);
            }

            Brush brush = Stroke.ToBrush(this);

            brush.Opacity = Opacity.ToDouble() * StrokeOpacity.ToDouble();

            Pen pen = new Pen(brush, StrokeWidth.ToDouble());

            pen.MiterLimit = this.StrokeMiterlimit;

            if (this.StrokeDasharray != null && this.StrokeDasharray.Length > 0)
            {
                var sda = new double[this.StrokeDasharray.Length];
                var i   = 0;
                foreach (var svgLength in this.StrokeDasharray)
                {
                    sda[i++] = svgLength.Value;
                }

                var sdo = this.StrokeDashoffset != null ? this.StrokeDashoffset.Value : 0.0;
                pen.DashStyle = new DashStyle(sda, sdo);
            }

            return(pen);
        }
示例#2
0
        //==========================================================================
        public Pen GetPen()
        {
            if (Stroke == null)
            {
                return(null);
            }

            if (StrokeWidth.ToDouble() <= 0.0)
            {
                return(null);
            }

            Brush brush = Stroke.ToBrush(this);

            brush.Opacity = Opacity.ToDouble() * StrokeOpacity.ToDouble();

            Pen pen = new Pen(brush, StrokeWidth.ToDouble());

            pen.MiterLimit = this.StrokeMiterlimit;

            if (this.StrokeDasharray != null && this.StrokeDasharray.Length > 0)
            {
                var sda = new double[this.StrokeDasharray.Length];
                var i   = 0;
                foreach (var svgLength in this.StrokeDasharray)
                {
                    sda[i++] = svgLength.Value;
                }

                var sdo = this.StrokeDashoffset != null ? this.StrokeDashoffset.Value : 0.0;
                pen.DashStyle = new DashStyle(sda, sdo);
                switch (StrokeLinecap)
                {
                case SvgStrokeLinecap.Round:
                    pen.DashCap = PenLineCap.Round;
                    break;

                case SvgStrokeLinecap.Square:
                    pen.DashCap = PenLineCap.Square;
                    break;

                case SvgStrokeLinecap.Butt:
                case SvgStrokeLinecap.Inherit:
                default:
                    pen.DashCap = PenLineCap.Flat;
                    break;
                }
            }

            return(pen);
        }
示例#3
0
        //==========================================================================
        public Brush GetBrush()
        {
            if (Fill == null)
            {
                return(null);
            }

            Brush brush = Fill.ToBrush(this);

            if (brush == null)
            {
                return(null);
            }

            brush.Opacity = Opacity.ToDouble() * FillOpacity.ToDouble();
            return(brush);
        }
示例#4
0
        //==========================================================================
        public Pen GetPen()
        {
            if (Stroke == null)
            {
                return(null);
            }

            if (StrokeWidth.ToDouble() <= 0.0)
            {
                return(null);
            }

            Brush brush = Stroke.ToBrush(this);

            brush.Opacity = Opacity.ToDouble() * StrokeOpacity.ToDouble();

            Pen pen = new Pen(brush, StrokeWidth.ToDouble());

            return(pen);
        }