示例#1
0
            public void Apply(AbstractPen pen)
            {
                if (pen == null)
                {
                    Set("stroke", Color.Empty);
                }
                else
                {
                    Set("stroke", pen.Color);
                    Set("stroke-width", pen.Width);

                    switch (pen.DashStyle)
                    {
                    case DashStyle.Solid:
                        // "solid" is SVG default
                        break;

                    case DashStyle.Dot:
                        Set("stroke-dasharray", $"{pen.Width:G2} {pen.Width:G2}");
                        break;

                    case DashStyle.Dash:
                        Set("stroke-dasharray", $"{pen.Width * 2:G2} {pen.Width:G2}");
                        break;

                    case DashStyle.DashDot:
                        Set("stroke-dasharray", $"{pen.Width * 2:G2} {pen.Width:G2} {pen.Width:G2} {pen.Width:G2}");
                        break;

                    case DashStyle.DashDotDot:
                        Set("stroke-dasharray", $"{pen.Width * 2:G2} {pen.Width:G2} {pen.Width:G2} {pen.Width:G2} {pen.Width:G2} {pen.Width:G2}");
                        break;

                    case DashStyle.Custom:
                        if (pen.CustomDashPattern == null)
                        {
                            throw new ApplicationException("Custom dash style specified but no pattern set");
                        }
                        Set("stroke-dasharray",
                            string.Join(" ", pen.CustomDashPattern.Select(w => F(w * pen.Width))));
                        break;
                    }
                }
            }
示例#2
0
 private void Apply(AbstractPen pen)
 {
     this.pen.Color     = pen.Color;
     this.pen.Width     = pen.Width;
     this.pen.DashStyle = pen.DashStyle switch
     {
         DashStyle.Solid => System.Drawing.Drawing2D.DashStyle.Solid,
         DashStyle.Dot => System.Drawing.Drawing2D.DashStyle.Dot,
         DashStyle.Dash => System.Drawing.Drawing2D.DashStyle.Dash,
         DashStyle.DashDot => System.Drawing.Drawing2D.DashStyle.DashDot,
         DashStyle.DashDotDot => System.Drawing.Drawing2D.DashStyle.DashDotDot,
         DashStyle.Custom => System.Drawing.Drawing2D.DashStyle.Custom,
         _ => System.Drawing.Drawing2D.DashStyle.Solid,
     };
     if (pen.CustomDashPattern != null)
     {
         this.pen.DashPattern = pen.CustomDashPattern;
     }
 }
示例#3
0
        private void Apply(AbstractPen pen)
        {
            this.pen.Color = pen.Color;
            this.pen.Width = pen.Width;
            switch (pen.DashStyle)
            {
            case DashStyle.Solid: this.pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; break;

            case DashStyle.Dot: this.pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; break;

            case DashStyle.Dash: this.pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; break;

            case DashStyle.DashDot: this.pen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; break;

            case DashStyle.DashDotDot: this.pen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; break;

            case DashStyle.Custom: this.pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; break;
            }
            if (pen.CustomDashPattern != null)
            {
                this.pen.DashPattern = pen.CustomDashPattern;
            }
        }
        private void Apply(AbstractPen pen)
        {
            this.pen.Color = pen.Color;
            this.pen.Width = pen.Width;
            switch (pen.DashStyle)
            {
            case DashStyle.Solid: this.pen.DashStyle = XDashStyle.Solid; break;

            case DashStyle.Dot: this.pen.DashStyle = XDashStyle.Dot; break;

            case DashStyle.Dash: this.pen.DashStyle = XDashStyle.Dash; break;

            case DashStyle.DashDot: this.pen.DashStyle = XDashStyle.DashDot; break;

            case DashStyle.DashDotDot: this.pen.DashStyle = XDashStyle.DashDotDot; break;

            case DashStyle.Custom: this.pen.DashStyle = XDashStyle.Custom; break;
            }
            if (pen.CustomDashPattern != null)
            {
                this.pen.DashPattern = pen.CustomDashPattern.Select(f => (double)f).ToArray();
            }
        }
示例#5
0
 public void Apply(AbstractPen pen, AbstractBrush brush)
 {
     Apply(pen);
     Apply(brush);
 }
示例#6
0
 private void Apply(AbstractPen pen, AbstractBrush brush)
 {
     Apply(pen); Apply(brush);
 }