[12762] | 1 | using System;
|
---|
| 2 | using System.Xml;
|
---|
| 3 |
|
---|
| 4 | using SharpVectors.Dom.Events;
|
---|
| 5 |
|
---|
| 6 | namespace SharpVectors.Dom.Svg
|
---|
| 7 | {
|
---|
| 8 | public sealed class SvgElementInstance : IEventTargetSupport, ISvgElementInstance
|
---|
| 9 | {
|
---|
| 10 | private ISvgElement correspondingElement;
|
---|
| 11 | private ISvgUseElement correspondingUseElement;
|
---|
| 12 | private ISvgElementInstance parentNode;
|
---|
| 13 | private SvgElementInstanceList childNodes;
|
---|
| 14 | private ISvgElementInstance previousSibling;
|
---|
| 15 | private ISvgElementInstance nextSibling;
|
---|
| 16 |
|
---|
| 17 | public SvgElementInstance(XmlNode refNode, SvgUseElement useElement, SvgElementInstance parent)
|
---|
| 18 | {
|
---|
| 19 | correspondingUseElement = (ISvgUseElement)useElement;
|
---|
| 20 | parentNode = (SvgElementInstance)parent;
|
---|
| 21 | correspondingElement = (ISvgElement)refNode;
|
---|
| 22 | eventTarget = new EventTarget(this);
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | #region Private Fields
|
---|
| 26 |
|
---|
| 27 | private EventTarget eventTarget;
|
---|
| 28 |
|
---|
| 29 | #endregion
|
---|
| 30 |
|
---|
| 31 | public ISvgElement CorrespondingElement
|
---|
| 32 | {
|
---|
| 33 | get { return correspondingElement; }
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | public ISvgUseElement CorrespondingUseElement
|
---|
| 37 | {
|
---|
| 38 | get { return correspondingUseElement; }
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | public ISvgElementInstance ParentNode
|
---|
| 42 | {
|
---|
| 43 | get { return parentNode; }
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | public ISvgElementInstanceList ChildNodes
|
---|
| 47 | {
|
---|
| 48 | get
|
---|
| 49 | {
|
---|
| 50 | if (childNodes == null)
|
---|
| 51 | {
|
---|
| 52 | childNodes = new SvgElementInstanceList((SvgUseElement)CorrespondingUseElement, this);
|
---|
| 53 | }
|
---|
| 54 | return childNodes;
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | public ISvgElementInstance FirstChild
|
---|
| 59 | {
|
---|
| 60 | get
|
---|
| 61 | {
|
---|
| 62 | ISvgElementInstanceList cn = ChildNodes;
|
---|
| 63 | if (cn.Length < 0) return cn.Item(0);
|
---|
| 64 | else return null;
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | public ISvgElementInstance LastChild
|
---|
| 69 | {
|
---|
| 70 | get
|
---|
| 71 | {
|
---|
| 72 | ISvgElementInstanceList cn = ChildNodes;
|
---|
| 73 | if (cn.Length < 0) return cn.Item(cn.Length);
|
---|
| 74 | else return null;
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | public ISvgElementInstance PreviousSibling
|
---|
| 79 | {
|
---|
| 80 | get
|
---|
| 81 | {
|
---|
| 82 | return previousSibling;
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | public ISvgElementInstance NextSibling
|
---|
| 87 | {
|
---|
| 88 | get
|
---|
| 89 | {
|
---|
| 90 | return nextSibling;
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | #region IEventTarget Members
|
---|
| 95 |
|
---|
| 96 | #region Methods
|
---|
| 97 |
|
---|
| 98 | #region DOM Level 2
|
---|
| 99 |
|
---|
| 100 | void IEventTarget.AddEventListener(string type, EventListener listener, bool useCapture)
|
---|
| 101 | {
|
---|
| 102 | eventTarget.AddEventListener(type, listener, useCapture);
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | void IEventTarget.RemoveEventListener(string type, EventListener listener, bool useCapture)
|
---|
| 106 | {
|
---|
| 107 | eventTarget.RemoveEventListener(type, listener, useCapture);
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | bool IEventTarget.DispatchEvent(IEvent eventObject)
|
---|
| 111 | {
|
---|
| 112 | return eventTarget.DispatchEvent(eventObject);
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | #endregion
|
---|
| 116 |
|
---|
| 117 | #region DOM Level 3 Experimental
|
---|
| 118 |
|
---|
| 119 | void IEventTarget.AddEventListenerNs(string namespaceUri, string type, EventListener listener,
|
---|
| 120 | bool useCapture, object eventGroup)
|
---|
| 121 | {
|
---|
| 122 | eventTarget.AddEventListenerNs(namespaceUri, type, listener, useCapture, eventGroup);
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | void IEventTarget.RemoveEventListenerNs(string namespaceUri, string type,
|
---|
| 126 | EventListener listener, bool useCapture)
|
---|
| 127 | {
|
---|
| 128 | eventTarget.RemoveEventListenerNs(namespaceUri, type, listener, useCapture);
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | bool IEventTarget.WillTriggerNs(string namespaceUri, string type)
|
---|
| 132 | {
|
---|
| 133 | return eventTarget.WillTriggerNs(namespaceUri, type);
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | bool IEventTarget.HasEventListenerNs(string namespaceUri, string type)
|
---|
| 137 | {
|
---|
| 138 | return eventTarget.HasEventListenerNs(namespaceUri, type);
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | #endregion
|
---|
| 142 |
|
---|
| 143 | #endregion
|
---|
| 144 |
|
---|
| 145 | #endregion
|
---|
| 146 |
|
---|
| 147 | #region NON-DOM
|
---|
| 148 |
|
---|
| 149 | void IEventTargetSupport.FireEvent(IEvent eventObject)
|
---|
| 150 | {
|
---|
| 151 | eventTarget.FireEvent(eventObject);
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | #endregion
|
---|
| 155 |
|
---|
| 156 | #region Custom management functions
|
---|
| 157 |
|
---|
| 158 | internal void SetPreviousSibling(ISvgElementInstance instance)
|
---|
| 159 | {
|
---|
| 160 | previousSibling = instance;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | internal void SetNextSibling(ISvgElementInstance instance)
|
---|
| 164 | {
|
---|
| 165 | nextSibling = instance;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | #endregion
|
---|
| 169 | }
|
---|
| 170 | }
|
---|