public SVGPolygon(SVGNode svgNode, Color fill, List <Vector2D> vertices, bool debugOutput = false) : base(svgNode) { var doc = GetDocument(); xmlElement = doc.CreateElement("polygon"); parent.xmlElement.AppendChild(xmlElement); xmlElement.SetAttribute("fill", ColorToHex(fill)); if (debugOutput) { xmlElement.SetAttribute("stroke", "black"); xmlElement.SetAttribute("stroke-width", "1"); } //xmlElement.SetAttribute("stroke-linecap", "round"); StringWriter sw = new StringWriter(); bool first = true; foreach (var v in vertices) { if (first) { first = false; } else { sw.Write(" "); } sw.Write("{0},{1}", v.x.ToString("R"), v.y.ToString("R")); } xmlElement.SetAttribute("points", sw.ToString()); }
public IEnumerable <SVGNode> ParseAll(string svgContent) { var svgNodes = new List <SVGNode>(); try { XmlDocument svgXmlDocument = new XmlDocument(); svgXmlDocument.LoadXml(svgContent); XmlNamespaceManager nsmgr = new XmlNamespaceManager(svgXmlDocument.NameTable); nsmgr.AddNamespace("svg", "http://www.w3.org/2000/svg"); var xmlNodes = GetNodes(svgXmlDocument, nsmgr); foreach (XmlNode node in xmlNodes) { var properties = GetProperties(node, nsmgr); var svgNode = new SVGNode() { Properties = properties }; svgNodes.Add(svgNode); } } catch (Exception e) { throw; } return(svgNodes); }
public SVGGroup(SVGNode parent, string name) : base(parent) { var doc = GetDocument(); xmlElement = doc.CreateElement("g"); parent.xmlElement.AppendChild(xmlElement); xmlElement.SetAttribute("name", name); }
protected XmlDocument GetDocument() { SVGNode n = parent; while (n.parent != null) { n = n.parent; } SVGDocument doc = n as SVGDocument; return(doc.doc); }
public SVGNode(SVGNode parent) { this.parent = parent; }