using System; using System.Collections.Generic; using System.Text; using System.Xml; using System.Drawing.Drawing2D; using System.Drawing; using System.ComponentModel; namespace Svg { /// /// An represents an SVG fragment that can be the root element or an embedded fragment of an SVG document. /// public class SvgFragment : SvgElement, ISvgViewPort { private SvgUnit _width; private SvgUnit _height; private SvgViewBox _viewBox; /// /// Gets the SVG namespace string. /// public static readonly Uri Namespace = new Uri("http://www.w3.org/2000/svg"); /// /// Gets or sets the width of the fragment. /// /// The width. [SvgAttribute("width")] public SvgUnit Width { get { return this._width; } set { this._width = value; } } /// /// Gets or sets the height of the fragment. /// /// The height. [SvgAttribute("height")] public SvgUnit Height { get { return this._height; } set { this._height = value; } } /// /// Gets or sets the viewport of the element. /// /// [SvgAttribute("viewBox")] public SvgViewBox ViewBox { get { return this._viewBox; } set { this._viewBox = value; } } /// /// Applies the required transforms to . /// /// The to be transformed. protected internal override void PushTransforms(SvgRenderer renderer) { base.PushTransforms(renderer); if (!this.ViewBox.Equals(SvgViewBox.Empty)) { if (this.ViewBox.MinX > 0 || this.ViewBox.MinY > 0) { renderer.TranslateTransform(this.ViewBox.MinX, this.ViewBox.MinY, MatrixOrder.Append); } renderer.ScaleTransform(this.Width.ToDeviceValue() / this.ViewBox.Width, this.Height.ToDeviceValue() / this.ViewBox.Height, MatrixOrder.Append); } } /// /// Initializes a new instance of the class. /// public SvgFragment() { this._height = new SvgUnit(SvgUnitType.Percentage, 100.0f); this._width = 1000.0f; this.ViewBox = SvgViewBox.Empty; } } }