コード例 #1
0
        public void AddData(int prototype, object data)
        {
            InitPrototypes();
            Element ele = new Element(prototype);

            ele.size = SizeOfPrototype(prototype);
            ele.data = data;
            if (mFirst == null)
            {
                mFirst     = ele;
                mResize    = true;
                mResizeRow = mFirstRow;
                mLast      = ele;
                return;
            }
            if (m_SortData)
            {
                var node = mLast;
                while (node != null)
                {
                    if (CompareData(node, ele) < 0)
                    {
                        break;
                    }
                    node = node.previous;
                }
                if (node == null)
                {
                    mFirst.AddBefore(ele);
                    mResize    = true;
                    mResizeRow = null;
                    mFirst     = ele;
                }
                else
                {
                    node.AddAfter(ele);
                    if (node == mLast)
                    {
                        mLast = ele;
                    }
                    mResize = true;
                    if (node.row == null)
                    {
                        mResizeRow = null;
                    }
                    else if (mResizeRow == null || mResizeRow.index > node.row.index)
                    {
                        mResizeRow = node.row;
                    }
                }
            }
            else
            {
                mLast.AddAfter(ele);
                mLast      = ele;
                mResize    = true;
                mResizeRow = mLastRow;
            }
        }
コード例 #2
0
        public void BindData <T>(IEnumerable <T> iter) where T : class
        {
            InitPrototypes();
            int p = GetPrototype <T>();

            if (p == -1)
            {
                return;
            }
            Vector2 size = SizeOfPrototype(p);

            ClearData();
            var it = iter.GetEnumerator();

            //Element node = null;
            if (m_SortData)
            {
                while (it.MoveNext())
                {
                    var ele = new Element(p);
                    ele.data = it.Current;
                    ele.size = size;
                    if (mLast == null)
                    {
                        mFirst = ele;
                        mLast  = ele;
                    }
                    else
                    {
                        var prev = mLast;
                        while (prev != null)
                        {
                            if (CompareData(prev, ele) <= 0)
                            {
                                break;
                            }
                            prev = prev.previous;
                        }
                        if (prev == null)
                        {
                            ele.AddAfter(mFirst);
                            mFirst = ele;
                        }
                        else
                        {
                            prev.AddAfter(ele);
                            if (prev == mLast)
                            {
                                mLast = ele;
                            }
                        }
                    }
                }
            }
            else
            {
                while (it.MoveNext())
                {
                    Element ele = new Element(p);
                    ele.data = it.Current;
                    ele.size = size;
                    if (mFirst == null)
                    {
                        mFirst = ele;
                        mLast  = ele;
                    }
                    else
                    {
                        mLast.AddAfter(ele);
                        mLast = ele;
                    }
                }
            }
            mResize    = true;
            mResizeRow = null;
        }