SvgGroup.cs 2.19 KB
Newer Older
davescriven's avatar
davescriven committed
1
2
3
4
using System;
using System.Collections.Generic;
using System.Xml;
using System.Text;
5
using System.Drawing;
Tebjan Halm's avatar
Tebjan Halm committed
6
using System.Drawing.Drawing2D;
7
8
using System.Linq;
using Svg.Transforms;
davescriven's avatar
davescriven committed
9
10
11

namespace Svg
{
12
13
14
    /// <summary>
    /// An element used to group SVG shapes.
    /// </summary>
15
    [SvgElement("g")]
16
    public class SvgGroup : SvgVisualElement
davescriven's avatar
davescriven committed
17
18
19
20
21
    {
        public SvgGroup()
        {
        }

22
23
24
25
        /// <summary>
        /// Gets the <see cref="GraphicsPath"/> for this element.
        /// </summary>
        /// <value></value>
davescriven's avatar
davescriven committed
26
27
        public override System.Drawing.Drawing2D.GraphicsPath Path
        {
Tebjan Halm's avatar
Tebjan Halm committed
28
29
            get 
            { 
30
            	//var path = new GraphicsPath();
Tebjan Halm's avatar
Tebjan Halm committed
31
            	//AddPaths(this, path);
Tebjan Halm's avatar
Tebjan Halm committed
32
  
Tebjan Halm's avatar
Tebjan Halm committed
33
            	return GetPaths(this);
Tebjan Halm's avatar
Tebjan Halm committed
34
            }
35
36
            protected set
            { }
davescriven's avatar
davescriven committed
37
38
        }

39
40
41
42
        /// <summary>
        /// Gets the bounds of the element.
        /// </summary>
        /// <value>The bounds.</value>
davescriven's avatar
davescriven committed
43
44
        public override System.Drawing.RectangleF Bounds
        {
Tebjan Halm's avatar
Tebjan Halm committed
45
46
47
48
49
50
51
52
53
54
            get 
            { 
            	var r = new RectangleF();
            	foreach(var c in this.Children)
            	{
            		if(c is SvgVisualElement)
            			r = RectangleF.Union(r, ((SvgVisualElement)c).Bounds);
            	}
				return r;         	
            }
davescriven's avatar
davescriven committed
55
56
        }

57
58
59
60
        /// <summary>
        /// Renders the <see cref="SvgElement"/> and contents to the specified <see cref="Graphics"/> object.
        /// </summary>
        /// <param name="graphics">The <see cref="Graphics"/> object to render to.</param>
61
        protected override void Render(SvgRenderer renderer)
davescriven's avatar
davescriven committed
62
        {
63
            this.PushTransforms(renderer);
64
            this.SetClip(renderer);
65
            base.RenderChildren(renderer);
66
            this.ResetClip(renderer);
67
            this.PopTransforms(renderer);
davescriven's avatar
davescriven committed
68
        }
69
70
71
72
73
74
75
76
77
78
79
80
81
82

		
		public override SvgElement DeepCopy()
		{
			return DeepCopy<SvgGroup>();
		}

		public override SvgElement DeepCopy<T>()
		{
			var newObj = base.DeepCopy<T>() as SvgGroup;
			if (this.Fill != null)
				newObj.Fill = this.Fill.DeepCopy() as SvgPaintServer;
			return newObj;
		}
davescriven's avatar
davescriven committed
83
84
    }
}