[12762] | 1 | // <developer>niklas@protocol7.com</developer>
|
---|
| 2 | // <completed>100</completed>
|
---|
| 3 |
|
---|
| 4 | using System;
|
---|
| 5 | using System.Xml;
|
---|
| 6 |
|
---|
| 7 | using SharpVectors.Dom.Events;
|
---|
| 8 |
|
---|
| 9 | namespace SharpVectors.Dom.Svg
|
---|
| 10 | {
|
---|
| 11 | /// <summary>
|
---|
| 12 | /// The SVGRectElement interface corresponds to the 'rect' element.
|
---|
| 13 | /// </summary>
|
---|
| 14 | public sealed class SvgRectElement : SvgTransformableElement, ISvgRectElement
|
---|
| 15 | {
|
---|
| 16 | #region Private Fields
|
---|
| 17 |
|
---|
| 18 | private ISvgAnimatedLength x;
|
---|
| 19 | private ISvgAnimatedLength y;
|
---|
| 20 | private ISvgAnimatedLength rx;
|
---|
| 21 | private ISvgAnimatedLength ry;
|
---|
| 22 | private ISvgAnimatedLength width;
|
---|
| 23 | private ISvgAnimatedLength height;
|
---|
| 24 |
|
---|
| 25 | private SvgTests svgTests;
|
---|
| 26 | private SvgExternalResourcesRequired svgExternalResourcesRequired;
|
---|
| 27 |
|
---|
| 28 | #endregion
|
---|
| 29 |
|
---|
| 30 | #region Constructors and Destructor
|
---|
| 31 |
|
---|
| 32 | public SvgRectElement(string prefix, string localname, string ns, SvgDocument doc)
|
---|
| 33 | : base(prefix, localname, ns, doc)
|
---|
| 34 | {
|
---|
| 35 | svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
|
---|
| 36 | svgTests = new SvgTests(this);
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | #endregion
|
---|
| 40 |
|
---|
| 41 | #region Public Methods
|
---|
| 42 |
|
---|
| 43 | public void Invalidate()
|
---|
| 44 | {
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | public override void HandleAttributeChange(XmlAttribute attribute)
|
---|
| 48 | {
|
---|
| 49 | if (attribute.NamespaceURI.Length == 0)
|
---|
| 50 | {
|
---|
| 51 | switch (attribute.LocalName)
|
---|
| 52 | {
|
---|
| 53 | case "x":
|
---|
| 54 | x = null;
|
---|
| 55 | Invalidate();
|
---|
| 56 | return;
|
---|
| 57 | case "y":
|
---|
| 58 | y = null;
|
---|
| 59 | Invalidate();
|
---|
| 60 | return;
|
---|
| 61 | case "width":
|
---|
| 62 | width = null;
|
---|
| 63 | Invalidate();
|
---|
| 64 | return;
|
---|
| 65 | case "height":
|
---|
| 66 | height = null;
|
---|
| 67 | Invalidate();
|
---|
| 68 | return;
|
---|
| 69 | case "rx":
|
---|
| 70 | rx = null;
|
---|
| 71 | Invalidate();
|
---|
| 72 | return;
|
---|
| 73 | case "ry":
|
---|
| 74 | ry = null;
|
---|
| 75 | Invalidate();
|
---|
| 76 | return;
|
---|
| 77 | // Color.attrib, Paint.attrib
|
---|
| 78 | case "color":
|
---|
| 79 | case "fill":
|
---|
| 80 | case "fill-rule":
|
---|
| 81 | case "stroke":
|
---|
| 82 | case "stroke-dasharray":
|
---|
| 83 | case "stroke-dashoffset":
|
---|
| 84 | case "stroke-linecap":
|
---|
| 85 | case "stroke-linejoin":
|
---|
| 86 | case "stroke-miterlimit":
|
---|
| 87 | case "stroke-width":
|
---|
| 88 | // Opacity.attrib
|
---|
| 89 | case "opacity":
|
---|
| 90 | case "stroke-opacity":
|
---|
| 91 | case "fill-opacity":
|
---|
| 92 | // Graphics.attrib
|
---|
| 93 | case "display":
|
---|
| 94 | case "image-rendering":
|
---|
| 95 | case "shape-rendering":
|
---|
| 96 | case "text-rendering":
|
---|
| 97 | case "visibility":
|
---|
| 98 | Invalidate();
|
---|
| 99 | break;
|
---|
| 100 | case "transform":
|
---|
| 101 | Invalidate();
|
---|
| 102 | break;
|
---|
| 103 | case "onclick":
|
---|
| 104 | break;
|
---|
| 105 |
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | base.HandleAttributeChange(attribute);
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | #endregion
|
---|
| 113 |
|
---|
| 114 | #region ISvgElement Members
|
---|
| 115 |
|
---|
| 116 | /// <summary>
|
---|
| 117 | /// Gets a value providing a hint on the rendering defined by this element.
|
---|
| 118 | /// </summary>
|
---|
| 119 | /// <value>
|
---|
| 120 | /// An enumeration of the <see cref="SvgRenderingHint"/> specifying the rendering hint.
|
---|
| 121 | /// This will always return <see cref="SvgRenderingHint.Shape"/>
|
---|
| 122 | /// </value>
|
---|
| 123 | public override SvgRenderingHint RenderingHint
|
---|
| 124 | {
|
---|
| 125 | get
|
---|
| 126 | {
|
---|
| 127 | return SvgRenderingHint.Shape;
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | #endregion
|
---|
| 132 |
|
---|
| 133 | #region ISvgExternalResourcesRequired Members
|
---|
| 134 |
|
---|
| 135 | public ISvgAnimatedBoolean ExternalResourcesRequired
|
---|
| 136 | {
|
---|
| 137 | get
|
---|
| 138 | {
|
---|
| 139 | return svgExternalResourcesRequired.ExternalResourcesRequired;
|
---|
| 140 | }
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | #endregion
|
---|
| 144 |
|
---|
| 145 | #region ISvgRectElement Members
|
---|
| 146 |
|
---|
| 147 | public ISvgAnimatedLength Width
|
---|
| 148 | {
|
---|
| 149 | get
|
---|
| 150 | {
|
---|
| 151 | if (width == null)
|
---|
| 152 | {
|
---|
| 153 | width = new SvgAnimatedLength(this, "width", SvgLengthDirection.Horizontal, "100");
|
---|
| 154 | }
|
---|
| 155 | return width;
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | public ISvgAnimatedLength Height
|
---|
| 160 | {
|
---|
| 161 | get
|
---|
| 162 | {
|
---|
| 163 | if (height == null)
|
---|
| 164 | {
|
---|
| 165 | height = new SvgAnimatedLength(this, "height", SvgLengthDirection.Vertical, "100");
|
---|
| 166 | }
|
---|
| 167 | return height;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | public ISvgAnimatedLength X
|
---|
| 173 | {
|
---|
| 174 | get
|
---|
| 175 | {
|
---|
| 176 | if (x == null)
|
---|
| 177 | {
|
---|
| 178 | x = new SvgAnimatedLength(this, "x", SvgLengthDirection.Horizontal, "0");
|
---|
| 179 | }
|
---|
| 180 | return x;
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | public ISvgAnimatedLength Y
|
---|
| 186 | {
|
---|
| 187 | get
|
---|
| 188 | {
|
---|
| 189 | if (y == null)
|
---|
| 190 | {
|
---|
| 191 | y = new SvgAnimatedLength(this, "y", SvgLengthDirection.Vertical, "0");
|
---|
| 192 | }
|
---|
| 193 | return y;
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | public ISvgAnimatedLength Rx
|
---|
| 199 | {
|
---|
| 200 | get
|
---|
| 201 | {
|
---|
| 202 | if (rx == null)
|
---|
| 203 | {
|
---|
| 204 | rx = new SvgAnimatedLength(this, "rx", SvgLengthDirection.Horizontal, "0");
|
---|
| 205 | }
|
---|
| 206 | return rx;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | public ISvgAnimatedLength Ry
|
---|
| 212 | {
|
---|
| 213 | get
|
---|
| 214 | {
|
---|
| 215 | if (ry == null)
|
---|
| 216 | {
|
---|
| 217 | ry = new SvgAnimatedLength(this, "ry", SvgLengthDirection.Vertical, "0");
|
---|
| 218 | }
|
---|
| 219 | return ry;
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 | #endregion
|
---|
| 224 |
|
---|
| 225 | #region ISvgTests Members
|
---|
| 226 |
|
---|
| 227 | public ISvgStringList RequiredFeatures
|
---|
| 228 | {
|
---|
| 229 | get { return svgTests.RequiredFeatures; }
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | public ISvgStringList RequiredExtensions
|
---|
| 233 | {
|
---|
| 234 | get { return svgTests.RequiredExtensions; }
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | public ISvgStringList SystemLanguage
|
---|
| 238 | {
|
---|
| 239 | get { return svgTests.SystemLanguage; }
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | public bool HasExtension(string extension)
|
---|
| 243 | {
|
---|
| 244 | return svgTests.HasExtension(extension);
|
---|
| 245 | }
|
---|
| 246 |
|
---|
| 247 | #endregion
|
---|
| 248 | }
|
---|
| 249 | }
|
---|