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.
///
/// The width.
[SvgAttribute("width")]
public SvgUnit Width
{
get { return this._width; }
set { this._width = value; }
}
///
/// Gets or sets the height.
///
/// 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; }
}
///
/// Gets the name of the element.
///
///
protected override string ElementName
{
get { return "svg"; }
}
///
/// Pushes the transforms.
///
/// The graphics.
protected internal override void PushTransforms(Graphics graphics)
{
base.PushTransforms(graphics);
if (!this.ViewBox.Equals(SvgViewBox.Empty))
{
if (this.ViewBox.MinX > 0 || this.ViewBox.MinY > 0)
{
graphics.TranslateTransform(this.ViewBox.MinX, this.ViewBox.MinY, MatrixOrder.Append);
}
graphics.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;
}
}
}