Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
 public int FirstItemIndexOfPage(int pageIndex)
 {
     return(PageUtil.FirstItemIndexOfPage(ItemCountPerPage, pageIndex));
 }