SvgDefinitionDefaults.cs 1.95 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Svg
{
    /// <summary>
    /// Holds a dictionary of the default values of the SVG specification 
    /// </summary>
    public static class SvgDefaults
    {
        //internal dictionary for the defaults
        private static readonly Dictionary<string, string> _defaults = new Dictionary<string, string>();

        static SvgDefaults()
        {
Eric Domke's avatar
Eric Domke committed
18
19
            _defaults["d"] = "";

20
21
22
23
24
25
26
            _defaults["viewBox"] = "0, 0, 0, 0";

            _defaults["visibility"] = "visible";
            _defaults["opacity"] = "1";
            _defaults["clip-rule"] = "nonzero";

            _defaults["transform"] = "";
Tebjan Halm's avatar
Tebjan Halm committed
27
28
            _defaults["rx"] = "0";
            _defaults["ry"] = "0";
Tebjan Halm's avatar
Tebjan Halm committed
29
30
            _defaults["cx"] = "0";
            _defaults["cy"] = "0";
31

32
            _defaults["fill"] = "";
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
            _defaults["fill-opacity"] = "1";
            _defaults["fill-rule"] = "nonzero";

            _defaults["stroke"] = "none";
            _defaults["stroke-opacity"] = "1";
            _defaults["stroke-width"] = "1";
            _defaults["stroke-miterlimit"] = "4";
            _defaults["stroke-linecap"] = "butt";
            _defaults["stroke-linejoin"] = "miter";
            _defaults["stroke-dasharray"] = "none";
            _defaults["stroke-dashoffset"] = "0";
        }

        /// <summary>
        /// Checks whether the property value is the default value of the svg definition.
        /// </summary>
        /// <param name="attributeName">Name of the svg attribute</param>
50
        /// <param name="value">.NET value of the attribute</param>
51
52
53
54
55
56
57
58
59
60
        public static bool IsDefault(string attributeName, string value)
        {
            if (_defaults.ContainsKey(attributeName))
            {
                if (_defaults[attributeName] == value) return true;
            }
            return false;
        }
    }
}