Example #1
0
        private bool IsLastSibling(SVGUnit ele)
        {
            SVGUnit last = GetLastSibling(ele);

            if (last == null)
            {
                return(false);
            }

            return(ele.getInternalId() == last.getInternalId());
        }
Example #2
0
        private bool DeleteElement(SVGUnit ele, bool bDeleteFromParent)
        {
            SVGErr err = new SVGErr("SvgDoc", "DeleteElement");

            if (ele == null)
            {
                err.LogEnd(false);

                return(false);
            }

            SVGUnit parent = ele.getParent();

            if (parent == null)
            {
                err.Log("root node cannot be delete!", SVGErr._LogPriority.Info);
                err.LogEnd(false);

                return(false);
            }

            if (ele.getPrevious() != null)
            {
                ele.getPrevious().setNext(ele.getNext());
            }

            if (ele.getNext() != null)
            {
                ele.getNext().setPrevious(ele.getPrevious());
            }

            if (bDeleteFromParent)
            {
                if (IsFirstChild(ele))
                {
                    ele.getParent().setChild(ele.getNext());
                }
            }

            SVGUnit child = ele.getChild();

            while (child != null)
            {
                DeleteElement(child, false);
                child = child.getNext();
            }

            m_elements.Remove(ele.getInternalId());

            err.Log(ele.ElementInfo(), SVGErr._LogPriority.Info);
            err.LogEnd(true);

            return(true);
        }
Example #3
0
        private bool IsFirstChild(SVGUnit ele)
        {
            if (ele.getParent() == null)
            {
                return(false);
            }

            if (ele.getParent().getChild() == null)
            {
                return(false);
            }

            return(ele.getInternalId() == ele.getParent().getChild().getInternalId());
        }
Example #4
0
        /// <summary>
        /// 它将新元素eletoadd添加为给定父元素的最后一个子元素。
        /// </summary>
        public void AddElement(SVGUnit parent, SVGUnit eleToAdd, ref SVGUnit last)
        {
            SVGErr err = new SVGErr("SvgDoc", "AddElement");

            if (eleToAdd == null || m_root == null)
            {
                err.LogEnd(false);
                return;
            }

            SVGUnit parentToAdd = m_root;

            if (parent != null)
            {
                parentToAdd = parent;
            }

            eleToAdd.setInternalId(m_nNextId++);
            m_elements.Add(eleToAdd.getInternalId(), eleToAdd);

            eleToAdd.setParent(parentToAdd);
            if (parentToAdd.getChild() == null)
            {
                // 元素是第一个子元素
                parentToAdd.setChild(eleToAdd);
                last = eleToAdd;
            }
            else
            {
                // 将元素添加为最后一个同级
                //SvgElement last = GetLastSibling(parentToAdd.getChild());

                if (last != null)
                {
                    last.setNext(eleToAdd);
                    eleToAdd.setPrevious(last);
                    last = eleToAdd;
                }
                else
                {
                    last = parentToAdd.getChild();
                }
            }

            err.Log(eleToAdd.ElementInfo(), SVGErr._LogPriority.Info);
            err.LogEnd(true);
        }