Example #1
0
        public virtual void AddNode(LNNode node, int z)
        {
            if (this.Contains(node))
            {
                return;
            }
            if (node.GetContainer() != null)
            {
                node.SetContainer(null);
            }
            node.SetContainer(this);
            int  index = 0;
            bool flag  = false;

            for (int i = 0; i < this._childCount; i++)
            {
                LNNode node2 = this.childs[i];
                int    zd    = 0;
                if (node2 != null)
                {
                    zd = node2.GetZOrder();
                }
                if (zd > z)
                {
                    flag        = true;
                    this.childs = (LNNode[])CollectionUtils.Expand(this.childs, 1,
                                                                   false);
                    childs[index] = node;
                    _childCount++;
                    node.SetScreen(_screen);
                    this.latestInserted = node;
                    break;
                }
                index++;
            }
            if (!flag)
            {
                this.childs = (LNNode[])CollectionUtils.Expand(this.childs, 1,
                                                               false);
                this.childs[0] = node;
                this._childCount++;
                node.SetScreen(_screen);
                this.latestInserted = node;
            }
            node.SetZOrder(z);
            node.SetParent(this);
            Arrays.Sort(childs, comparator);
        }
Example #2
0
        public virtual void Add(LNNode node, int index)
        {
            if (node.GetContainer() != null)
            {
                throw new InvalidOperationException(node
                                                    + " already reside in another node!!!");
            }
            node.SetContainer(this);
            LNNode[] newChilds = new LNNode[this.childs.Length + 1];
            this._childCount++;
            int ctr = 0;

            for (int i = 0; i < this._childCount; i++)
            {
                if (i != index)
                {
                    newChilds[i] = this.childs[ctr];
                    ctr++;
                }
            }
            this.childs        = newChilds;
            this.childs[index] = node;
            node.SetScreen(_screen);
            this.SortComponents();
            this.latestInserted = node;
        }