Esempio n. 1
0
        private WpfSvgPaint GetDeferredFill()
        {
            var nodeList = _element.OwnerDocument.SelectNodes("//*[@fill='currentColor']");

            if (nodeList == null || nodeList.Count == 0)
            {
                return(null);
            }
            // Try a shortcut...
            SvgStyleableElement svgElement = _element.ParentNode as SvgStyleableElement;

            if (svgElement != null && svgElement.HasAttribute("fill") &&
                string.Equals("currentColor", svgElement.GetAttribute("fill")))
            {
                string color = svgElement.GetAttribute("color");
                if (!string.IsNullOrWhiteSpace(color))
                {
                    return(new WpfSvgPaint(_context, svgElement, "color"));
                }
            }

            foreach (XmlNode nodeItem in nodeList)
            {
                svgElement = nodeItem as SvgStyleableElement;
                if (svgElement == null)
                {
                    continue;
                }

                var childNodeList = svgElement.GetElementsByTagName(_element.LocalName);
                if (childNodeList != null && childNodeList.Count != 0)
                {
                    foreach (var childNode in childNodeList)
                    {
                        if (childNode == _element)
                        {
                            string color = svgElement.GetAttribute("color");
                            if (!string.IsNullOrWhiteSpace(color))
                            {
                                return(new WpfSvgPaint(_context, svgElement, "color"));
                            }
                        }
                    }
                }
            }
            return(null);
        }