private static XAttribute GetStyleAttribute(SVGStroke stroke, SVGFill fill) { // Returns the "style" attribute which can be added to most elements string str; if (fill == null) { str = "fill:none; "; } else { str = fill.GetStyle() + " "; } if (stroke != null) { str += stroke.GetStyle(); } return(new XAttribute("style", str)); }
protected SVGElement(Dictionary <string, string> _attrList) { attrList = _attrList; stroke = null; fillColor = null; strokeColor = null; fillOpacity = 1.0f; strokeOpacity = 1.0f; strokeWidth = 0; hasFill = true; hasStroke = false; visible = true; element_number = SVGGenerals.getElementId(); if (attrList.ContainsKey("id")) { name = attrList["id"]; } else { name = this.ToString() + "-" + element_number; } foreach (KeyValuePair <string, string> attr in attrList) { switch (attr.Key) { case "transform": transformlist = new SVGTransformList(); transformlist.ParseAttributes(attr.Value); break; case "fill": if (String.Compare(attr.Value, "none") == 0) { hasFill = false; } else if (String.Compare(attr.Value, "transparent") == 0) { hasFill = false; } else { hasFill = true; fillColor = new SVGColor(attr.Value); } break; case "opacity": fillOpacity = StringParser.StringAttrFloat(attr.Value); strokeOpacity = fillOpacity; break; case "fill-opacity": fillOpacity = StringParser.StringAttrFloat(attr.Value); break; case "stroke": if (String.Compare(attr.Value, "none") == 0) { hasStroke = false; } else { hasStroke = true; strokeColor = new SVGColor(attr.Value); } break; case "stroke-width": strokeWidth = StringParser.StringAttrFloat(attr.Value); break; case "stroke-opacity": strokeOpacity = StringParser.StringAttrFloat(attr.Value); break; case "display": if (String.Compare(attr.Value, "none") == 0) { visible = false; } else { visible = true; } break; case "style": //ParseStyle(value); Debug.Log("Attributo style no implementado aun:" + attr.Value); break; default: //Debug.Log("Attributo no implementado: " + attr.Key); break; } } if (hasStroke) { stroke = new SVGStroke(strokeColor, strokeWidth, strokeOpacity); } }