Example #1
0
		internal SvgUseElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this._stylableHelper = new SvgStylableHelper(this, element);
			this._transformableHelper = new SvgTransformableHelper(element);

			var nan = new SvgLength(SvgLength.SvgLengthType.Unknown, float.NaN);
			this.X = element.ParseCoordinate("x", nan);
			this.Y = element.ParseCoordinate("y", nan);
			this.Width = element.ParseLength("width", nan);
			this.Height = element.ParseLength("height", nan);
			this.Href = element.GetAttribute("xlink:href").Substring(1);
			
			var child = (SvgElement)this.OwnerDocument.GetElementById(this.Href).CloneNode(true);
			if (child.GetType() == typeof(SvgSymbolElement))
			{
				throw new NotImplementedException();
			}
			else if (child.GetType() == typeof(SvgRectElement))
			{
				var casted = (SvgRectElement)child;
				if (this.Width.UnitType != SvgLength.SvgLengthType.Unknown) casted.Width = this.Width;
				if (this.Height.UnitType != SvgLength.SvgLengthType.Unknown) casted.Height = this.Height;
			}
			this.InstanceRoot = child;

			if (this.X.UnitType != SvgLength.SvgLengthType.Unknown && this.Y.UnitType != SvgLength.SvgLengthType.Unknown)
			{
				this.Transform.Add(SvgTransform.CreateTranslate(
					this.X.UnitType != SvgLength.SvgLengthType.Unknown ? this.X.ValueAsPixel : 0.0F,
					this.Y.UnitType != SvgLength.SvgLengthType.Unknown ? this.Y.ValueAsPixel : 0.0F));
			}
		}
		internal SvgLinearGradientElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this.X1 = element.ParseCoordinate("x1", 0.0F);
			this.Y1 = element.ParseCoordinate("y1", 0.0F);
			this.X2 = element.ParseCoordinate("x2", 100.0F);
			this.Y2 = element.ParseCoordinate("y2", 0.0F);
		}
		internal SvgRadialGradientElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this.CenterX = element.ParseCoordinate("cx", 0.5F);
			this.CenterY = element.ParseCoordinate("cy", 0.5F);
			this.Radius = element.ParseLength("r", 0.5F);
			this.FocusX = element.ParseCoordinate("fx", this.CenterX);
			this.FocusY = element.ParseCoordinate("fy", this.CenterY);
		}
Example #4
0
		internal SvgCircleElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this._stylableHelper = new SvgStylableHelper(this, element);
			this._transformableHelper = new SvgTransformableHelper(element);

			this.CenterX = element.ParseCoordinate("cx", 0.0F);
			this.CenterY = element.ParseCoordinate("cy", 0.0F);
			this.Radius = element.ParseLength("r", 0.0F);
		}
Example #5
0
		internal SvgLineElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this._stylableHelper = new SvgStylableHelper(this, element);
			this._transformableHelper = new SvgTransformableHelper(element);

			this.X1 = element.ParseCoordinate("x1", 0.0F);
			this.Y1 = element.ParseCoordinate("y1", 0.0F);
			this.X2 = element.ParseCoordinate("x2", 0.0F);
			this.Y2 = element.ParseCoordinate("y2", 0.0F);
		}
Example #6
0
		internal SvgRectElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this._stylableHelper = new SvgStylableHelper(this, element);
			this._transformableHelper = new SvgTransformableHelper(element);

			this.X = element.ParseCoordinate("x", 0.0F);
			this.Y = element.ParseCoordinate("y", 0.0F);
			this.Width = element.ParseLength("width", 0.0F);
			this.Height = element.ParseLength("height", 0.0F);

			SvgLength rx, ry;
			var fx = element.TryParseLength("rx", out rx);
			if (fx && rx < 0.0F) fx = false;

			var fy = element.TryParseLength("ry", out ry);
			if (fy && ry < 0.0F) fy = false;

			if (!fx && !fy)
			{
				rx = 0.0F;
				ry = 0.0F;
			}
			else if (fx && !fy)
			{
				ry = rx;
			}
			else if (!fx && fy)
			{
				rx = ry;
			}

			var hw = this.Width / 2.0F;
			if (rx > hw) rx = hw;

			var hh = this.Height / 2.0F;
			if (ry > hh) ry = hh;

			this.RoundedX = rx;
			this.RoundedY = ry;
		}