Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 它将元素移动到当前的上一个同级之前。
        /// </summary>
        public bool ElementPositionUp(SVGUnit ele)
        {
            SVGErr err = new SVGErr("SvgDoc", "ElementPositionUp");

            err.Log("Element to move " + ele.ElementInfo(), SVGErr._LogPriority.Info);

            SVGUnit parent = ele.getParent();

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

                return(false);
            }

            if (IsFirstChild(ele))
            {
                err.Log("Element is already at the first position", SVGErr._LogPriority.Info);
                err.LogEnd(false);

                return(false);
            }

            SVGUnit nxt  = ele.getNext();
            SVGUnit prv  = ele.getPrevious();
            SVGUnit prv2 = null;

            ele.setNext(null);
            ele.setPrevious(null);

            if (nxt != null)
            {
                nxt.setPrevious(prv);
            }

            if (prv != null)
            {
                prv.setNext(nxt);
                prv2 = prv.getPrevious();
                prv.setPrevious(ele);

                if (IsFirstChild(prv))
                {
                    if (prv.getParent() != null)
                    {
                        prv.getParent().setChild(ele);
                    }
                }
            }

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

            ele.setNext(prv);
            ele.setPrevious(prv2);

            err.Log("Element moved " + ele.ElementInfo(), SVGErr._LogPriority.Info);
            err.LogEnd(true);

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// It moves the element after its current next sibling.
        /// </summary>
        public bool ElementPositionDown(SVGUnit ele)
        {
            SVGErr err = new SVGErr("SvgDoc", "ElementPositionDown");

            err.Log("Element to move " + ele.ElementInfo(), SVGErr._LogPriority.Info);

            SVGUnit parent = ele.getParent();

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

                return(false);
            }

            if (IsLastSibling(ele))
            {
                err.Log("Element is already at the last sibling position", SVGErr._LogPriority.Info);
                err.LogEnd(false);

                return(false);
            }

            SVGUnit nxt  = ele.getNext();
            SVGUnit nxt2 = null;
            SVGUnit prv  = ele.getPrevious();

            // fix Next
            if (nxt != null)
            {
                nxt.setPrevious(ele.getPrevious());
                nxt2 = nxt.getNext();
                nxt.setNext(ele);
            }

            // fix Previous
            if (prv != null)
            {
                prv.setNext(nxt);
            }

            // fix Element
            if (IsFirstChild(ele))
            {
                parent.setChild(nxt);
            }

            ele.setPrevious(nxt);
            ele.setNext(nxt2);

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

            err.Log("Element moved " + ele.ElementInfo(), SVGErr._LogPriority.Info);
            err.LogEnd(true);

            return(true);
        }