Пример #1
0
        public void ChildrenUpdate(int itemCount)
        {
            int pageIndex = This.CurrentPageIndex, countPerPage = This.ItemCountPerPage;
            int countInPage = PageUtil.ItemCountInPage(itemCount, countPerPage, pageIndex);

            // Remove redundant child drawers.
            while (This.ChildCount > countInPage)
            {
                This.LastChild.Parent = null;
            }

            if (countInPage == 0)
            {
                return;
            }

            int startIndex = PageUtil.FirstItemIndexOfPage(countPerPage, pageIndex);
            int stopIndex  = PageUtil.LastItemIndexOfPage(itemCount, countPerPage, pageIndex);

            for (int index = startIndex; index <= stopIndex; ++index)
            {
                if (index >= itemCount)
                {
                    continue;
                }

                var itemType  = ItemTypeGetter(index);
                var childType = ValueDrawerTypes.GetOrBuild(typeof(TCollection), itemType);

                int childIndex = index - startIndex;
                var child      = This.GetChild(childIndex) as ValueDrawer;
                if (child != null)
                {
                    if (child.GetType() != childType)
                    {
                        child = (ValueDrawer)Drawer.Create(childType);
                        This.ReplaceChild(childIndex, child);
                    }
                    else
                    {
                        //if (child.DrawingValue )
                    }
                }
                else
                {
                    child = (ValueDrawer)Drawer.Create(childType);
                    child.ChangeParent(This, childIndex);
                }
                child.Name       = index.ToString();
                child.ValueEntry = ValueEntryCreator(index, This.TypedDrawingValue);
            }
        }
Пример #2
0
        public void ChildrenUpdate(TList list)
        {
            int countInPage = This.ItemCountInCurrentPage;

            // Remove redundant child drawers.
            while (This.ChildCount > countInPage)
            {
                This.LastChild.Parent = null;
            }

            int firstItemIndex = This.FirstItemIndexOfCurrentPage;

            for (int i = 0; i < countInPage; ++i)
            {
                int  itemIndex = firstItemIndex + i;
                Type itemType;
                ItemTypeGetter.GetValue(list, itemIndex, out itemType, DefaultItemType);
                var childType = ValueDrawerTypes.GetOrBuild(typeof(TList), itemType);

                var child = This.GetChild(i) as ValueDrawer;
                if (child != null)
                {
                    if (child.GetType() != childType)
                    {
                        child = (ValueDrawer)Drawer.Create(childType);
                        This.ReplaceChild(i, child);
                    }
                }
                else
                {
                    child = (ValueDrawer)Drawer.Create(childType);
                    child.ChangeParent(This, i);
                }
                child.Name       = itemIndex.ToString();
                child.ValueEntry = ChildValueEntryCreator(list, itemType, itemIndex);
            }
        }