Example #1
0
        /// <summary>
        /// Creates a new/empty SVG document that contains just the root element.
        /// </summary>
        /// <returns>
        /// The root element of the SVG document.
        /// </returns>
        public SvgRoot CreateNewDocument()
        {
            if (svgRoot != null)
            {
                svgRoot = null;
                svgDocumentNextInternalId = 1;
                svgDocumentElements.Clear();
            }

            svgRoot = new SvgRoot(this);
            svgRoot.SetInternalId(svgDocumentNextInternalId++);

            svgDocumentElements.Add(svgRoot.GetInternalId(), svgRoot);

            svgDocumentXmlDeclaration  = "<?xml version=\"1.0\"?>";
            svgDocumentXmlDocumentType = "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">";

            svgRoot.SetAttributeValue(SvgAttribute.SvgAttributes.AttrSvgXmlNs, "http://www.w3.org/2000/svg");
            svgRoot.SetAttributeValue(SvgAttribute.SvgAttributes.AttrSvgVersion, "1.1");

            return(svgRoot);
        }
Example #2
0
        /// <summary>
        /// Creates a new/empty SVG document that contains just the root element.
        /// </summary>
        /// <returns>
        /// The root element of the SVG document.
        /// </returns>
        public SvgRoot CreateNewDocument()
        {
            if ( svgRoot != null )
            {
                svgRoot = null;
                svgDocumentNextInternalId = 1;
                svgDocumentElements.Clear();
            }

            svgRoot = new SvgRoot(this);
            svgRoot.SetInternalId(svgDocumentNextInternalId++);

            svgDocumentElements.Add(svgRoot.GetInternalId(), svgRoot);

            svgDocumentXmlDeclaration = "<?xml version=\"1.0\"?>";
            svgDocumentXmlDocumentType = "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">";

            svgRoot.SetAttributeValue(SvgAttribute.SvgAttributes.AttrSvgXmlNs, "http://www.w3.org/2000/svg");
            svgRoot.SetAttributeValue(SvgAttribute.SvgAttributes.AttrSvgVersion, "1.1");

            return svgRoot;
        }
Example #3
0
        /// <summary>
        /// It creates a new element according to the element name provided
        /// and it adds the new element as the last children of the given parent element.
        /// </summary>
        /// <param name="parent">Parent element. If null the element is added under the root.</param>
        /// <param name="name">SVG element name.</param>
        /// <returns>The new created element.</returns>
        public SvgElement AddElement(SvgElement parent, string name)
        {
            SvgElement eleToReturn = null;

            if ( name == "svg" )
            {
                svgRoot = new SvgRoot(this);
                svgRoot.SetInternalId(svgDocumentNextInternalId++);

                svgDocumentElements.Add(svgRoot.GetInternalId(), svgRoot);
                eleToReturn = svgRoot;
            }
            else if ( name == "desc" )
            {
                eleToReturn = AddDesc(parent);
            }
            else if ( name == "text" )
            {
                eleToReturn = AddText(parent);
            }
            else if ( name == "g" )
            {
                eleToReturn = AddGroup(parent);
            }
            else if ( name == "rect" )
            {
                eleToReturn = AddRect(parent);
            }
            else if ( name == "circle" )
            {
                eleToReturn = AddCircle(parent);
            }
            else if ( name == "ellipse" )
            {
                eleToReturn = AddEllipse(parent);
            }
            else if ( name == "line" )
            {
                eleToReturn = AddLine(parent);
            }
            else if ( name == "path" )
            {
                eleToReturn = AddPath(parent);
            }
            else if ( name == "polygon" )
            {
                eleToReturn = AddPolygon(parent);
            }
            else if ( name == "image" )
            {
                eleToReturn = AddImage(parent);
            }
            else
            {
                if ( parent != null )
                {
                    eleToReturn = AddUnsupported(parent, name);
                }
            }

            return eleToReturn;
        }
Example #4
0
        /// <summary>
        /// It creates a new element according to the element name provided
        /// and it adds the new element as the last children of the given parent element.
        /// </summary>
        /// <param name="parent">Parent element. If null the element is added under the root.</param>
        /// <param name="name">SVG element name.</param>
        /// <returns>The new created element.</returns>
        public SvgElement AddElement(SvgElement parent, string name)
        {
            SvgElement eleToReturn = null;

            if (name == "svg")
            {
                svgRoot = new SvgRoot(this);
                svgRoot.SetInternalId(svgDocumentNextInternalId++);

                svgDocumentElements.Add(svgRoot.GetInternalId(), svgRoot);
                eleToReturn = svgRoot;
            }
            else if (name == "desc")
            {
                eleToReturn = AddDesc(parent);
            }
            else if (name == "text")
            {
                eleToReturn = AddText(parent);
            }
            else if (name == "g")
            {
                eleToReturn = AddGroup(parent);
            }
            else if (name == "rect")
            {
                eleToReturn = AddRect(parent);
            }
            else if (name == "circle")
            {
                eleToReturn = AddCircle(parent);
            }
            else if (name == "ellipse")
            {
                eleToReturn = AddEllipse(parent);
            }
            else if (name == "line")
            {
                eleToReturn = AddLine(parent);
            }
            else if (name == "path")
            {
                eleToReturn = AddPath(parent);
            }
            else if (name == "polygon")
            {
                eleToReturn = AddPolygon(parent);
            }
            else if (name == "image")
            {
                eleToReturn = AddImage(parent);
            }
            else
            {
                if (parent != null)
                {
                    eleToReturn = AddUnsupported(parent, name);
                }
            }

            return(eleToReturn);
        }