Exemple #1
0
            public LineTo(char command, ShapeUtil.StringSplitter value) : base(command)
            {
                if (char.ToLower(command) == 'h')
                {
                    PositionType = eType.Horizontal;
                    double v = value.ReadNextValue();
                    Points = new Point[] { new Point(v, 0) };
                    return;
                }
                if (char.ToLower(command) == 'v')
                {
                    PositionType = eType.Vertical;
                    double v = value.ReadNextValue();
                    Points = new Point[] { new Point(0, v) };
                    return;
                }

                PositionType = eType.Point;
                List <Point> list = new List <Point>();

                while (value.More)
                {
                    Point p = value.ReadNextPoint();
                    list.Add(p);
                }
                Points = list.ToArray();
            }
Exemple #2
0
        public static Transform ParseTransform(string value)
        {
            string type = ExtractUntil(value, '(');
            string v1   = ExtractBetween(value, '(', ')');

            ShapeUtil.StringSplitter split  = new ShapeUtil.StringSplitter(v1);
            List <double>            values = new List <double>();

            while (split.More)
            {
                values.Add(split.ReadNextValue());
            }
            if (type == SVGTags.sTranslate)
            {
                return(new TranslateTransform(values[0], values[1]));
            }
            if (type == SVGTags.sMatrix)
            {
                return(Transform.Parse(v1));
            }
            if (type == SVGTags.sScale)
            {
                return(new ScaleTransform(values[0], values[1]));
            }
            if (type == SVGTags.sRotate)
            {
                return(new RotateTransform(values[0], values[1], values[2]));
            }

            return(null);
        }
Exemple #3
0
            public EllipticalArcTo(char command, ShapeUtil.StringSplitter value) : base(command)
            {
                RX           = value.ReadNextValue();
                RY           = value.ReadNextValue();
                AxisRotation = value.ReadNextValue();
                double arcflag = value.ReadNextValue();

                LargeArc = (arcflag > 0);
                double sweepflag = value.ReadNextValue();

                Clockwise = (sweepflag > 0);
                X         = value.ReadNextValue();
                Y         = value.ReadNextValue();
            }
Exemple #4
0
 protected virtual void Parse(SVG svg, string name, string value)
 {
     if (name == SVGTags.sTransform)
     {
         Transform = ShapeUtil.ParseTransform(value.ToLower());
         return;
     }
     if (name == SVGTags.sStroke)
     {
         GetStroke(svg).Color = svg.PaintServers.Parse(value);
         return;
     }
     if (name == SVGTags.sStrokeWidth)
     {
         GetStroke(svg).Width = XmlUtil.ParseDouble(svg, value);
         return;
     }
     if (name == SVGTags.sStrokeOpacity)
     {
         GetStroke(svg).Opacity = XmlUtil.ParseDouble(svg, value) * 100;
         return;
     }
     if (name == SVGTags.sStrokeDashArray)
     {
         if (value == "none")
         {
             GetStroke(svg).StrokeArray = null;
             return;
         }
         ShapeUtil.StringSplitter sp = new ShapeUtil.StringSplitter(value);
         List <double>            a  = new List <double>();
         while (sp.More)
         {
             a.Add(sp.ReadNextValue());
         }
         GetStroke(svg).StrokeArray = a.ToArray();
         return;
     }
     if (name == SVGTags.sStrokeLinecap)
     {
         GetStroke(svg).LineCap = (ClipArtViewer.Stroke.eLineCap)Enum.Parse(typeof(ClipArtViewer.Stroke.eLineCap), value);
         return;
     }
     if (name == SVGTags.sStrokeLinejoin)
     {
         GetStroke(svg).LineJoin = (ClipArtViewer.Stroke.eLineJoin)Enum.Parse(typeof(ClipArtViewer.Stroke.eLineJoin), value);
         return;
     }
     if (name == SVGTags.sFill)
     {
         GetFill(svg).Color = svg.PaintServers.Parse(value);
         return;
     }
     if (name == SVGTags.sFillOpacity)
     {
         GetFill(svg).Opacity = XmlUtil.ParseDouble(svg, value) * 100;
         return;
     }
     if (name == SVGTags.sFillRule)
     {
         GetFill(svg).FillRule = (Fill.eFillRule)Enum.Parse(typeof(Fill.eFillRule), value);
         return;
     }
     if (name == SVGTags.sStyle)
     {
         foreach (ShapeUtil.Attribute item in XmlUtil.SplitStyle(svg, value))
         {
             Parse(svg, item);
         }
     }
     //********************** text *******************
     if (name == SVGTags.sFontFamily)
     {
         GetTextStyle(svg).FontFamily = value;
         return;
     }
     if (name == SVGTags.sFontSize)
     {
         GetTextStyle(svg).FontSize = XmlUtil.AttrValue(new ShapeUtil.Attribute(name, value));
         return;
     }
     if (name == SVGTags.sFontWeight)
     {
         GetTextStyle(svg).Fontweight = (FontWeight) new FontWeightConverter().ConvertFromString(value);
         return;
     }
     if (name == SVGTags.sFontStyle)
     {
         GetTextStyle(svg).Fontstyle = (FontStyle) new FontStyleConverter().ConvertFromString(value);
         return;
     }
     if (name == SVGTags.sTextDecoration)
     {
         TextDecoration t = new TextDecoration();
         if (value == "none")
         {
             return;
         }
         if (value == "underline")
         {
             t.Location = TextDecorationLocation.Underline;
         }
         if (value == "overline")
         {
             t.Location = TextDecorationLocation.OverLine;
         }
         if (value == "line-through")
         {
             t.Location = TextDecorationLocation.Strikethrough;
         }
         TextDecorationCollection tt = new TextDecorationCollection();
         tt.Add(t);
         GetTextStyle(svg).TextDecoration = tt;
         return;
     }
     if (name == SVGTags.sTextAnchor)
     {
         if (value == "start")
         {
             GetTextStyle(svg).TextAlignment = TextAlignment.Left;
         }
         if (value == "middle")
         {
             GetTextStyle(svg).TextAlignment = TextAlignment.Center;
         }
         if (value == "end")
         {
             GetTextStyle(svg).TextAlignment = TextAlignment.Right;
         }
         return;
     }
     if (name == "word-spacing")
     {
         GetTextStyle(svg).WordSpacing = XmlUtil.AttrValue(new ShapeUtil.Attribute(name, value));
         return;
     }
     if (name == "letter-spacing")
     {
         GetTextStyle(svg).LetterSpacing = XmlUtil.AttrValue(new ShapeUtil.Attribute(name, value));
         return;
     }
     if (name == "baseline-shift")
     {
         //GetTextStyle(svg).BaseLineShift = XmlUtil.AttrValue(new ShapeUtil.Attribute(name, value));
         GetTextStyle(svg).BaseLineShift = value;
         return;
     }
 }