SvgUse.cs 1.49 KB
Newer Older
davescriven's avatar
davescriven committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Xml;
using System.Xml.Serialization;

namespace Svg
{
    public class SvgUse : SvgGraphicsElement
    {
        private Uri _referencedElement;

        [SvgAttribute("href")]
        public virtual Uri ReferencedElement
        {
            get { return this._referencedElement; }
            set { this._referencedElement = value; }
        }

        public SvgUse()
        {
            
        }

        public override System.Drawing.Drawing2D.GraphicsPath Path
        {
            get { return null; }
        }

        public override System.Drawing.RectangleF Bounds
        {
            get { return new System.Drawing.RectangleF(); }
        }

        protected override string  ElementName
        {
            get { return "use"; }
        }

        protected override void Render(System.Drawing.Graphics graphics)
        {
            this.PushTransforms(graphics);

            SvgGraphicsElement element = (SvgGraphicsElement)this.OwnerDocument.IdManager.GetElementById(this.ReferencedElement);
            // For the time of rendering we want the referenced element to inherit
            // this elements transforms
            SvgElement parent = element._parent;
            element._parent = this;
            element.RenderElement(graphics);
            element._parent = parent;

            this.PopTransforms(graphics);
        }
    }
}