Ejemplo n.º 1
0
        private Tuple <string, ICssValue> ParseValue(string name, string value, string priority, bool presentation)
        {
            var important = priority == "important";

            if (!presentation)
            {
                name = name.ToLower();
            }

            ICssValue parsedValue = null;

            switch (name)
            {
            case "fill":
            case "stroke":
                parsedValue = new SvgPaint(value);
                break;

            case "stroke-width":
                parsedValue = SvgLength.Parse(value, presentation);
                break;

            case "stop-color":
                parsedValue = new SvgColor(value);
                break;

            case "fill-opacity":
            case "stroke-opacity":
            case "stop-opacity":
            case "opacity":
                parsedValue = SvgNumber.Parse(value, 0.0F, 1.0F);
                break;

            case "clip-path":
                parsedValue = new SvgIri(value);
                break;

            case "fill-rule":
            case "clip-rule":
                parsedValue = new SvgFillRule(presentation ? value : value.ToLower());
                break;
            }

            if (!this._cache.ContainsKey(name))
            {
                var result = Tuple.Create(value, parsedValue);
                this._cache.Add(name, result);
                return(result);
            }
            else if (important)
            {
                var result = Tuple.Create(value, parsedValue);
                this._cache[name] = result;
                return(result);
            }

            return(null);
        }
Ejemplo n.º 2
0
        //==========================================================================
        public static new SvgCoordinate Parse(string value)
        {
            SvgLength length = SvgLength.Parse(value);

            return(new SvgCoordinate(length.Value, length.Unit));
        }
Ejemplo n.º 3
0
 public static SvgLength ParseLength(this XmlElement element, string attributeName)
 {
     return(SvgLength.Parse(element.GetAttribute(attributeName)));
 }