Пример #1
0
        /// <summary>
        /// 将指定的节点紧接着插入指定的引用节点之后。
        /// </summary>
        /// <param name="newChild">指定的新节点</param>
        /// <param name="refChild">指定的引用节点</param>
        public virtual void InsertAfter(XhtmlElement newChild, XhtmlElement refChild)
        {
            this.AsXmlNode.InsertAfter(newChild.AsXmlNode, refChild.AsXmlNode);
            int i = this._ChildElements.IndexOf(refChild);

            this._ChildElements.Insert(i, newChild);
        }
Пример #2
0
 /// <summary>
 /// 将指定的节点添加到该节点的子节点列表的末尾。
 /// </summary>
 /// <param name="element">指定的节点</param>
 public virtual void AppendChild(XhtmlElement element)
 {
     if (element == null)
     {
         return;
     }
     if (this.AsXmlNode is XmlDocument)
     {
         XmlDocument doc = (XmlDocument)this.AsXmlNode;
         if (doc.DocumentElement == null)
         {
             doc.AppendChild(element.AsXmlNode);
         }
         else
         {
             doc.DocumentElement.AppendChild(element.AsXmlNode);
         }
     }
     else if (this.AsXmlNode is XmlElement)
     {
         this.AsXmlNode.AppendChild(element.AsXmlNode);
     }
     else
     {
         return;
     }
     this._ChildElements.Add(element);
 }
Пример #3
0
        /// <summary>
        /// 将指定的节点紧接着插入指定的引用节点之前。
        /// </summary>
        /// <param name="newChild">指定的新节点</param>
        /// <param name="refChild">指定的引用节点</param>
        public virtual void InsertBefore(XhtmlElement newChild, XhtmlElement refChild)
        {
            this.AsXmlNode.InsertBefore(newChild.AsXmlNode, refChild.AsXmlNode);
            int i = this._ChildElements.IndexOf(refChild);

            if (i < 0)
            {
                Debug.Fail(" i < 0 ");
                this._ChildElements.Insert(0, newChild);
            }
            else
            {
                this._ChildElements.Insert(i - 1, newChild);
            }
        }
Пример #4
0
        /// <summary>
        /// 将一个片断(Jeelu.XhtmlSection)导入到引用节点(深度克隆)。
        /// 功能实现重点:是将一个文档的片断导入到另一个文档
        /// </summary>
        /// <param name="section">即将被导入的片断</param>
        /// <param name="refElement">引用的节点,片断将被导入这个节点的子节点列表的末尾</param>
        /// <returns>导入成功与否。true成功,false失败</returns>
        public virtual bool ImportSection(XhtmlSection section, XhtmlElement refElement)
        {
            if (section == null || refElement == null)
            {
                return(false);
            }
            XmlNode newNode = ((XmlDocument)this.AsXmlNode).ImportNode(((XmlDocument)section.AsXmlNode).DocumentElement, true);

            if (refElement.AsXmlNode is XmlDocument)
            {
                XmlDocument doc = (XmlDocument)refElement.AsXmlNode;
                doc.DocumentElement.AppendChild(newNode);
                return(true);
            }
            else
            {
                refElement.AsXmlNode.AppendChild(newNode);
                return(true);
            }
        }
Пример #5
0
 /// <summary>
 /// 设置本节点的父节点
 /// </summary>
 /// <param name="parentElement">父节点</param>
 internal void SetParent(XhtmlElement parentElement)
 {
     this.ParentElement = parentElement;
 }
Пример #6
0
 /// <summary>
 /// 移除指定的子节点。
 /// </summary>
 /// <param name="element">正在被移除的节点。</param>
 public virtual void RemoveChild(XhtmlElement element)
 {
     this.AsXmlNode.RemoveChild(element.AsXmlNode);
     this._ChildElements.Remove(element);
 }
Пример #7
0
 /// <summary>
 /// 用 newElement 节点替换子节点 oldElement。
 /// </summary>
 /// <param name="newElement">新的节点</param>
 /// <param name="oldElement">指定的旧节点</param>
 public virtual void ReplaceChild(XhtmlElement newElement, XhtmlElement oldElement)
 {
     this.AsXmlNode.ReplaceChild(newElement.AsXmlNode, oldElement.AsXmlNode);
     this._ChildElements.Remove(oldElement);
     this._ChildElements.Add(newElement);
 }
Пример #8
0
        /// <summary>
        /// This will move all the nodes from the specified index to the new parent.
        /// </summary>
        /// <param name="nodes">The collection of nodes</param>
        /// <param name="node_index">The index of the first node (in the above collection) to move</param>
        /// <param name="new_parent">The node which will become the parent of the moved nodes</param>
        private static void MoveNodesDown(ref XhtmlTCollection <XhtmlElement> nodes, int node_index, XhtmlElement new_parent)
        {
            for (int i = node_index; i < nodes.Count; i++)
            {
                ((XhtmlElement)new_parent).AppendChild(nodes[i]);
                nodes[i].SetParent(new_parent);
            }
            int c = nodes.Count;

            for (int i = node_index; i < c; i++)
            {
                nodes.RemoveAt(node_index);
            }
            new_parent.IsExplicitlyTerminated = true;
        }
Пример #9
0
 /// <summary>
 /// 构造函数,生成一个XhtmlAttributeCollection实例
 /// </summary>
 /// <param name="element">该属性集合所附属(父级)的节点</param>
 public XhtmlAttributeCollection(XhtmlElement element)
 {
     this.ParentElement = element;
 }