• davescriven's avatar
    - Fixed #6324: SvgElement.PushTransforms and ViewBox - not necessarily related... · 7a704170
    davescriven authored
    - Fixed #6324: SvgElement.PushTransforms and ViewBox - not necessarily related to ViewBox but every   element was 'resetting' the current graphics transform if the element contained it's own transform. This 
      was a very small fix for a large problem (SvgElement.PushTransforms Matrix transformMatrix = new   Matrix(); changed to Matrix transformMatrix = renderer.Transform; in order to inherit the current   transform.)
    - Fixed #6344: Parsing document incorrectly parents elements when it encounters empty nodes which are   in a different namespace. Empty nodes are now ignored and current nodes are closed as required. We'll 
      see how this fix goes.
    - Fixed #6381: Units in inches are incorrectly parsed as millimeters - problem was caused by some   copy/paste work.
    - Graphics has been replaced by SvgRenderer. This is essentially a wrapper around graphics but will allow
      custom svg related properties in the future when needed.
    - Removed ISvgRenderer: A concrete implementation is suitable.
    - SvgElement.ElementName has been changed to non-virtual and is set by the parser instead of the   developer having to specify it when developing the class.
    - Added more XML API documentation.
    7a704170
SvgPath.cs 2.70 KiB
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using System.Xml;
using System.Diagnostics;
using Svg.Pathing;
namespace Svg
    /// <summary>
    /// Represents an SVG path element.
    /// </summary>
    public class SvgPath : SvgGraphicsElement
        private SvgPathSegmentList _pathData;
        private GraphicsPath _path;
        private int _pathLength;
        /// <summary>
        /// Gets or sets a <see cref="SvgPathSegmentList"/> of path data.
        /// </summary>
        [SvgAttribute("d")]
        public SvgPathSegmentList PathData
            get { return this._pathData; }
            set
                this._pathData = value;
                this._pathData._owner = this;
                this.IsPathDirty = true;
        /// <summary>
        /// Gets or sets the length of the path.
        /// </summary>
        [SvgAttribute("pathLength")]
        public int PathLength
            get { return this._pathLength; }
            set { this._pathLength = value; }
        /// <summary>
        /// Gets the <see cref="GraphicsPath"/> for this element.
        /// </summary>
        public override GraphicsPath Path
            get
                if (this._path == null || this.IsPathDirty)
                    _path = new GraphicsPath();
                    foreach (SvgPathSegment segment in this.PathData)
                        segment.AddToPath(_path);
                    this.IsPathDirty = false;
                return _path;
        internal void OnPathUpdated()
this.IsPathDirty = true; } /// <summary> /// Gets or sets a value to determine if anti-aliasing should occur when the element is being rendered. /// </summary> protected override bool RequiresSmoothRendering { get { return true; } } /// <summary> /// Gets the bounds of the element. /// </summary> /// <value>The bounds.</value> public override System.Drawing.RectangleF Bounds { get { return this.Path.GetBounds(); } } /// <summary> /// Initializes a new instance of the <see cref="SvgPath"/> class. /// </summary> public SvgPath() { this._pathData = new SvgPathSegmentList(); this._pathData._owner = this; } } }