Defines a set of options to customize rendering repspectively reading of SVG documents.
Esempio n. 1
0
 //==========================================================================
 /// <summary>
 ///   Loads an SVG document and renders it into a
 ///   <see cref="DrawingImage"/>.
 /// </summary>
 /// <param name="stream">
 ///   A <see cref="Stream"/> to read the XML structure of the SVG
 ///   document.
 /// </param>
 /// <param name="options">
 ///   <see cref="SvgReaderOptions"/> to use for parsing respectively
 ///   rendering the SVG document.
 /// </param>
 /// <returns>
 ///   A <see cref="DrawingImage"/> containing the rendered SVG document.
 /// </returns>
 public static DrawingImage Load(Stream stream, SvgReaderOptions options)
 {
     using (XmlReader reader = XmlReader.Create(stream, new XmlReaderSettings {
         DtdProcessing = DtdProcessing.Ignore
     }))
         return(Load(reader, options));
 }
Esempio n. 2
0
 //==========================================================================
 /// <summary>
 ///   Loads an SVG document and renders it into a
 ///   <see cref="DrawingImage"/>.
 /// </summary>
 /// <param name="stream">
 ///   A <see cref="Stream"/> to read the XML structure of the SVG
 ///   document.
 /// </param>
 /// <param name="options">
 ///   <see cref="SvgReaderOptions"/> to use for parsing respectively
 ///   rendering the SVG document.
 /// </param>
 /// <returns>
 ///   A <see cref="DrawingImage"/> containing the rendered SVG document.
 /// </returns>
 public static DrawingImage Load(Stream stream, SvgReaderOptions options)
 {
     using (XmlReader reader = XmlReader.Create(stream, new XmlReaderSettings {
         ProhibitDtd = false
     }))
         return(Load(reader, options));
 }
Esempio n. 3
0
        //==========================================================================
        /// <summary>
        ///   Loads an SVG document and renders it into a 
        ///   <see cref="DrawingImage"/>.
        /// </summary>
        /// <param name="reader">
        ///   A <see cref="XmlReader"/> to read the XML structure of the SVG 
        ///   document.
        /// </param>
        /// <param name="options">
        ///   <see cref="SvgReaderOptions"/> to use for parsing respectively 
        ///   rendering the SVG document.
        /// </param>
        /// <returns>
        ///   A <see cref="DrawingImage"/> containing the rendered SVG document.
        /// </returns>
        public static DrawingImage Load(XmlReader reader, SvgReaderOptions options)
        {
            if(options == null)
            options = new SvgReaderOptions();

              XDocument document = XDocument.Load(reader);
              if(document.Root.Name.NamespaceName != "http://www.w3.org/2000/svg")
            throw new XmlException("Root element is not in namespace 'http://www.w3.org/2000/svg'.");
              if(document.Root.Name.LocalName != "svg")
            throw new XmlException("Root element is not an <svg> element.");

              return new SvgDocument(document.Root, options).Draw();
        }
Esempio n. 4
0
        //==========================================================================
        /// <summary>
        ///   Loads an SVG document and renders it into a
        ///   <see cref="DrawingImage"/>.
        /// </summary>
        /// <param name="reader">
        ///   A <see cref="XmlReader"/> to read the XML structure of the SVG
        ///   document.
        /// </param>
        /// <param name="options">
        ///   <see cref="SvgReaderOptions"/> to use for parsing respectively
        ///   rendering the SVG document.
        /// </param>
        /// <returns>
        ///   A <see cref="DrawingImage"/> containing the rendered SVG document.
        /// </returns>
        public static DrawingImage Load(XmlReader reader, SvgReaderOptions options)
        {
            if (options == null)
            {
                options = new SvgReaderOptions();
            }

            XDocument document = XDocument.Load(reader);

            if (document.Root.Name.NamespaceName != "http://www.w3.org/2000/svg")
            {
                throw new XmlException("Root element is not in namespace 'http://www.w3.org/2000/svg'.");
            }
            if (document.Root.Name.LocalName != "svg")
            {
                throw new XmlException("Root element is not an <svg> element.");
            }

            return(new SvgDocument(document.Root, options).Draw());
        }
Esempio n. 5
0
 /// <summary>
 ///   Loads an SVG document and renders it into a 
 ///   <see cref="DrawingImage"/>.
 /// </summary>
 /// <param name="stream">
 ///   A <see cref="Stream"/> to read the XML structure of the SVG 
 ///   document.
 /// </param>
 /// <param name="options">
 ///   <see cref="SvgReaderOptions"/> to use for parsing respectively 
 ///   rendering the SVG document.
 /// </param>
 /// <returns>
 ///   A <see cref="DrawingImage"/> containing the rendered SVG document.
 /// </returns>
 public static DrawingImage Load(Stream stream, SvgReaderOptions options)
 {
     using (XmlReader reader = XmlReader.Create(stream, new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore }))
     {
         return Load(reader, options);
     }
 }
Esempio n. 6
0
 //==========================================================================
 public SvgDocument(XElement root, SvgReaderOptions options)
 {
     Root    = new SvgSVGElement(this, null, root);
       Options = options;
 }
Esempio n. 7
0
 //==========================================================================
 public SvgDocument(XElement root, SvgReaderOptions options)
 {
     Root    = new SvgSVGElement(this, null, root);
     Options = options;
 }
Esempio n. 8
0
 //==========================================================================
 public SvgDocument(XElement root, SvgReaderOptions options)
 {
     StyleDictionary = new Dictionary <string, IDictionary <string, string> >();
     Root            = new SvgSVGElement(this, null, root);
     Options         = options;
 }