Пример #1
0
        /// <summary>
        /// Generates a new <see cref="WpfRendering">RenderingNode</see> that
        /// corresponds to the given Uri.
        /// </summary>
        /// <param name="baseUri">
        /// The base Uri.
        /// </param>
        /// <param name="url">
        /// The url.
        /// </param>
        /// <returns>
        /// The generated <see cref="WpfRendering">RenderingNode</see> that
        /// corresponds to the given Uri.
        /// </returns>
        public static WpfRendering CreateByUri(SvgDocument document, string baseUri, string url)
        {
            url = url.Trim().Trim(new char[] { '\"', '\'' });
            if (url.StartsWith("#", StringComparison.OrdinalIgnoreCase))
            {
                // do nothing
            }
            else if (baseUri != "")
            {
                Uri absoluteUri = new Uri(new Uri(baseUri), url);
                url = absoluteUri.AbsoluteUri;
            }
            else
            {
                // TODO: Handle xml:base here?
                // Right now just skip this... it can't be resolved, must assume it is absolute
            }
            ISvgElement elm = document.GetNodeByUri(url) as ISvgElement;

            if (elm != null)
            {
                return(WpfRendering.Create(elm));
            }
            return(null);
        }
Пример #2
0
        private void RenderElementAs(SvgElement svgElement)
        {
            WpfRenderingBase renderingNode = WpfRendering.Create(svgElement);

            if (renderingNode == null)
            {
                return;
            }

            if (!renderingNode.NeedRender(_renderer))
            {
                //renderingNode.Dispose();
                //renderingNode = null;
                return;
            }

            _rendererMap[svgElement.UniqueId] = renderingNode;
            renderingNode.BeforeRender(_renderer);

            renderingNode.Render(_renderer);

            if (!renderingNode.IsRecursive && svgElement.HasChildNodes)
            {
                RenderChildren(svgElement);
            }

            renderingNode = _rendererMap[svgElement.UniqueId];
            renderingNode.AfterRender(_renderer);

            _rendererMap.Remove(svgElement.UniqueId);

            //renderingNode.Dispose();
            //renderingNode = null;
        }
Пример #3
0
        private void RenderElement(ISvgElement svgElement)
        {
            bool isNotRenderable = !svgElement.IsRenderable;

            if (string.Equals(svgElement.LocalName, "a"))
            {
            }
            if (isNotRenderable)
            {
                return;
            }

            WpfRenderingBase renderingNode = WpfRendering.Create(svgElement);

            if (renderingNode == null)
            {
                return;
            }

            if (!renderingNode.NeedRender(_renderer))
            {
                //renderingNode.Dispose();
                //renderingNode = null;
                return;
            }

            SvgElement currentElement = (SvgElement)svgElement;

            if (_rendererMap.ContainsKey(currentElement.UniqueId))
            {
                // Might be circular rendering...
//                System.Diagnostics.Debug.WriteLine("Circular Object: " + currentElement.LocalName);
                return;
            }

            _rendererMap[currentElement.UniqueId] = renderingNode;
            renderingNode.BeforeRender(_renderer);

            renderingNode.Render(_renderer);

            if (!renderingNode.IsRecursive && svgElement.HasChildNodes)
            {
                RenderChildren(svgElement);
            }

            renderingNode = _rendererMap[currentElement.UniqueId];
            renderingNode.AfterRender(_renderer);

            _rendererMap.Remove(currentElement.UniqueId);

            //renderingNode.Dispose();
            //renderingNode = null;
        }
Пример #4
0
        private void RenderElement(ISvgElement svgElement)
        {
            bool isNotRenderable = !svgElement.IsRenderable;

            //bool isNotRenderable = !svgElement.IsRenderable || string.Equals(svgElement.LocalName, "a");

            if (string.Equals(svgElement.LocalName, "a"))
            {
            }
            if (isNotRenderable)
            {
                return;
            }

            WpfRenderingBase renderingNode = WpfRendering.Create(svgElement);

            if (renderingNode == null)
            {
                return;
            }

            if (!renderingNode.NeedRender(_renderer))
            {
                renderingNode.Dispose();
                renderingNode = null;
                return;
            }

            _rendererMap[svgElement] = renderingNode;
            renderingNode.BeforeRender(_renderer);

            renderingNode.Render(_renderer);

            if (!renderingNode.IsRecursive && svgElement.HasChildNodes)
            {
                RenderChildren(svgElement);
            }

            renderingNode = _rendererMap[svgElement];
            renderingNode.AfterRender(_renderer);

            _rendererMap.Remove(svgElement);

            renderingNode.Dispose();
            renderingNode = null;
        }