public PolylineShape(SVG svg, XmlNode node) : base(svg, node) { string points = XmlUtil.AttrValue(node, SVGTags.sPoints, string.Empty); ShapeUtil.StringSplitter split = new ShapeUtil.StringSplitter(points); List <Point> list = new List <Point>(); while (split.More) { list.Add(split.ReadNextPoint()); } this.Points = list.ToArray(); }
public PolygonShape(SVG svg, XmlNode node) : base(svg, node) { if (DefaultFill == null) { DefaultFill = new Fill(svg); DefaultFill.Color = svg.PaintServers.Parse("black"); } string points = XmlUtil.AttrValue(node, SVGTags.sPoints, string.Empty); ShapeUtil.StringSplitter split = new ShapeUtil.StringSplitter(points); List<Point> list = new List<Point>(); while (split.More) { list.Add(split.ReadNextPoint()); } this.Points = list.ToArray(); }
public PolygonShape(SVG svg, XmlNode node) : base(svg, node) { if (DefaultFill == null) { DefaultFill = new Fill(svg); DefaultFill.PaintServerKey = svg.PaintServers.Parse("black"); } string points = XmlUtil.AttrValue(node, SVGTags.sPoints, string.Empty); ShapeUtil.StringSplitter split = new ShapeUtil.StringSplitter(points); List <Point> list = new List <Point>(); while (split.More) { list.Add(split.ReadNextPoint()); } this.Points = list.ToArray(); }
protected virtual void Parse(SVG svg, string name, string value) { if (name == SVGTags.sTransform) { this.Transform = ShapeUtil.ParseTransform(value.ToLower()); return; } if (name == SVGTags.sStroke) { this.GetStroke(svg).Color = svg.PaintServers.Parse(value); return; } if (name == SVGTags.sStrokeWidth) { this.GetStroke(svg).Width = XmlUtil.ParseDouble(svg, value); return; } if (name == SVGTags.sStrokeOpacity) { this.GetStroke(svg).Opacity = XmlUtil.ParseDouble(svg, value) * 100; return; } if (name == SVGTags.sStrokeDashArray) { if (value == "none") { this.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()); } this.GetStroke(svg).StrokeArray = a.ToArray(); return; } if (name == SVGTags.sStrokeLinecap) { this.GetStroke(svg).LineCap = (Stroke.eLineCap)Enum.Parse(typeof(Stroke.eLineCap), value); return; } if (name == SVGTags.sStrokeLinejoin) { this.GetStroke(svg).LineJoin = (Stroke.eLineJoin)Enum.Parse(typeof(Stroke.eLineJoin), value); return; } if (name == SVGTags.sClipPath) { if (value.StartsWith("url")) { Shape result; string id = ShapeUtil.ExtractBetween(value, '(', ')'); if (id.Length > 0 && id[0] == '#') id = id.Substring(1); svg.m_shapes.TryGetValue(id, out result); this.m_clip = result as Clip; return; } return; } if (name == SVGTags.sFill) { this.GetFill(svg).Color = svg.PaintServers.Parse(value); return; } if (name == SVGTags.sFillOpacity) { this.GetFill(svg).Opacity = XmlUtil.ParseDouble(svg, value) * 100; return; } if (name == SVGTags.sFillRule) { this.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)) this.Parse(svg, item); } //********************** text ******************* if (name == SVGTags.sFontFamily) { this.GetTextStyle(svg).FontFamily = value; return; } if (name == SVGTags.sFontSize) { this.GetTextStyle(svg).FontSize = XmlUtil.AttrValue(new ShapeUtil.Attribute(name, value)); return; } if (name == SVGTags.sFontWeight) { this.GetTextStyle(svg).Fontweight = (FontWeight)new FontWeightConverter().ConvertFromString(value); return; } if (name == SVGTags.sFontStyle) { this.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); this.GetTextStyle(svg).TextDecoration = tt; return; } if (name == SVGTags.sTextAnchor) { if (value == "start") this.GetTextStyle(svg).TextAlignment = TextAlignment.Left; if (value == "middle") this.GetTextStyle(svg).TextAlignment = TextAlignment.Center; if (value == "end") this.GetTextStyle(svg).TextAlignment = TextAlignment.Right; return; } if (name == "word-spacing") { this.GetTextStyle(svg).WordSpacing = XmlUtil.AttrValue(new ShapeUtil.Attribute(name, value)); return; } if (name == "letter-spacing") { this.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)); this.GetTextStyle(svg).BaseLineShift = value; return; } }
protected virtual void Parse(SVG svg, string name, string value) { if (name == SVGTags.sTransform) { this.Transform = ShapeUtil.ParseTransform(value.ToLower()); return; } if (name == SVGTags.sStroke) { this.GetStroke(svg).Color = svg.PaintServers.Parse(value); return; } if (name == SVGTags.sStrokeWidth) { this.GetStroke(svg).Width = XmlUtil.ParseDouble(svg, value); return; } if (name == SVGTags.sStrokeOpacity) { this.GetStroke(svg).Opacity = XmlUtil.ParseDouble(svg, value) * 100; return; } if (name == SVGTags.sStrokeDashArray) { if (value == "none") { this.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()); } this.GetStroke(svg).StrokeArray = a.ToArray(); return; } if (name == SVGTags.sStrokeLinecap) { this.GetStroke(svg).LineCap = (Stroke.eLineCap)Enum.Parse(typeof(Stroke.eLineCap), value); return; } if (name == SVGTags.sStrokeLinejoin) { this.GetStroke(svg).LineJoin = (Stroke.eLineJoin)Enum.Parse(typeof(Stroke.eLineJoin), value); return; } if (name == SVGTags.sClipPath) { if (value.StartsWith("url")) { Shape result; string id = ShapeUtil.ExtractBetween(value, '(', ')'); if (id.Length > 0 && id[0] == '#') { id = id.Substring(1); } svg.m_shapes.TryGetValue(id, out result); this.m_clip = result as Clip; return; } return; } if (name == SVGTags.sFill) { this.GetFill(svg).Color = svg.PaintServers.Parse(value); return; } if (name == SVGTags.sFillOpacity) { this.GetFill(svg).Opacity = XmlUtil.ParseDouble(svg, value) * 100; return; } if (name == SVGTags.sFillRule) { this.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)) { this.Parse(svg, item); } } //********************** text ******************* if (name == SVGTags.sFontFamily) { this.GetTextStyle(svg).FontFamily = value; return; } if (name == SVGTags.sFontSize) { this.GetTextStyle(svg).FontSize = XmlUtil.AttrValue(new ShapeUtil.Attribute(name, value)); return; } if (name == SVGTags.sFontWeight) { this.GetTextStyle(svg).Fontweight = (FontWeight) new FontWeightConverter().ConvertFromString(value); return; } if (name == SVGTags.sFontStyle) { this.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); this.GetTextStyle(svg).TextDecoration = tt; return; } if (name == SVGTags.sTextAnchor) { if (value == "start") { this.GetTextStyle(svg).TextAlignment = TextAlignment.Left; } if (value == "middle") { this.GetTextStyle(svg).TextAlignment = TextAlignment.Center; } if (value == "end") { this.GetTextStyle(svg).TextAlignment = TextAlignment.Right; } return; } if (name == "word-spacing") { this.GetTextStyle(svg).WordSpacing = XmlUtil.AttrValue(new ShapeUtil.Attribute(name, value)); return; } if (name == "letter-spacing") { this.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)); this.GetTextStyle(svg).BaseLineShift = value; return; } }