예제 #1
0
        private WpfFill GetPaintFill(string uri)
        {
            string absoluteUri = _element.ResolveUri(uri);

            if (absoluteUri.StartsWith("#", StringComparison.OrdinalIgnoreCase))
            {
                var elementId = absoluteUri.Substring(1);
                if (_context.ContainsUrl(elementId))
                {
                    return(null);
                }
            }

            if (_element.Imported && _element.ImportDocument != null && _element.ImportNode != null)
            {
                // We need to determine whether the provided URI refers to element in the
                // original document or in the current document...
                SvgStyleableElement styleElm = _element.ImportNode as SvgStyleableElement;
                if (styleElm != null)
                {
                    var cssDeclaration = styleElm.GetComputedStyle(string.Empty);

                    string propertyValue = cssDeclaration.GetPropertyValue(_propertyName);

                    if (!string.IsNullOrWhiteSpace(propertyValue))
                    {
                        WpfSvgPaint importFill = new WpfSvgPaint(_context, styleElm, _propertyName);
                        if (string.Equals(uri, importFill.Uri, StringComparison.OrdinalIgnoreCase))
                        {
                            WpfFill fill = WpfFill.CreateFill(_element.ImportDocument, absoluteUri);
                            if (fill != null)
                            {
                                return(fill);
                            }
                        }
                    }
                }
            }

            return(WpfFill.CreateFill(_element.OwnerDocument, absoluteUri));
        }