예제 #1
0
        public virtual void PaginateRecursive(ControlPager pager)
        {
            if (!EnablePagination)
            {
                return;
            }

            if (PaginateChildren || this.Form.ControlToPaginate == this)
            {
                int firstAssignedPage = -1;
                DoPaginateChildren(pager, this, ref firstAssignedPage);
                if (firstAssignedPage != -1)
                {
                    this.FirstPage = firstAssignedPage;
                }
                else
                {
                    this.FirstPage = pager.GetPage(GetVisibleWeight());
                }
                this.LastPage = pager.PageCount;
            }
            else
            {
                int pageNumber = pager.GetPage(GetVisibleWeight());
                SetControlPageRecursive(this, pageNumber);
                this.FirstPage = pageNumber;
                this.LastPage  = pageNumber;
            }
        }
        /// <include file='doc\ItemPager.uex' path='docs/doc[@for="ItemPager.ItemPager1"]/*' />
        public ItemPager(ControlPager pager, MobileControl control, int itemCount, int itemsPerPage, int itemWeight)
        {
            _control = control;

            if (itemsPerPage > 0)
            {
                // User-specified pagination behavior, always given
                // number of items per page.

                if (itemCount < itemsPerPage)
                {
                    _firstPageItemCount = itemCount;
                    _firstPage          = _lastPage = pager.GetPage(itemCount * itemWeight);
                }
                else
                {
                    int numberOfPages = (itemCount - 1) / itemsPerPage + 1;
                    _firstPageItemCount = itemsPerPage;
                    _fullPageItemCount  = itemsPerPage;
                    _lastPageItemCount  = itemCount - (numberOfPages - 1) * itemsPerPage;
                    _firstPage          = pager.GetPage(itemsPerPage * itemWeight);
                    pager.PageCount    += numberOfPages - 1;
                    if (numberOfPages > 1)
                    {
                        pager.RemainingWeight = Math.Max(0, pager.PageWeight - _lastPageItemCount * itemWeight);
                    }
                    _lastPage = _firstPage + numberOfPages - 1;
                }
            }
            else
            {
                int totalItemWeight = itemCount * itemWeight;
                if (totalItemWeight <= pager.RemainingWeight)
                {
                    _firstPageItemCount = itemCount;
                    _firstPage          = _lastPage = pager.GetPage(totalItemWeight);
                }
                else
                {
                    _firstPageItemCount = pager.RemainingWeight / itemWeight;
                    int remainingItemCount = itemCount - _firstPageItemCount;
                    _fullPageItemCount = Math.Max(1, pager.PageWeight / itemWeight);
                    int fullPageCount = remainingItemCount / _fullPageItemCount;
                    _lastPageItemCount = remainingItemCount % _fullPageItemCount;

                    _firstPage = pager.PageCount;

                    //  increment for first page
                    pager.PageCount++;
                    pager.RemainingWeight = pager.PageWeight;

                    //  increment for full pages
                    pager.PageCount += fullPageCount;

                    //  remove remaining weight for last page
                    pager.RemainingWeight -= _lastPageItemCount * itemWeight;

                    //  correct if first page is empty
                    if (_firstPageItemCount == 0)
                    {
                        _firstPage++;
                        _firstPageItemCount = Math.Min(_fullPageItemCount, itemCount);
                    }
                    //  correct if last page is empty
                    if (_lastPageItemCount == 0)
                    {
                        pager.PageCount--;
                        _lastPageItemCount    = Math.Min(_fullPageItemCount, itemCount);
                        pager.RemainingWeight = 0;
                    }
                    _lastPage = pager.PageCount;
                }
            }
            _control.FirstPage = _firstPage;
            _control.LastPage  = _lastPage;
        }
예제 #3
0
        /// <include file='doc\ItemPager.uex' path='docs/doc[@for="ItemPager.ItemPager1"]/*' />
        public ItemPager(ControlPager pager, MobileControl control, int itemCount, int itemsPerPage, int itemWeight)
        {
            _control = control;

            if (itemsPerPage > 0)
            {
                // User-specified pagination behavior, always given
                // number of items per page.

                if (itemCount < itemsPerPage)
                {
                    _firstPageItemCount = itemCount;
                    _firstPage = _lastPage = pager.GetPage(itemCount * itemWeight);
                }
                else
                {
                    int numberOfPages = (itemCount - 1) / itemsPerPage + 1;
                    _firstPageItemCount = itemsPerPage;
                    _fullPageItemCount = itemsPerPage;
                    _lastPageItemCount = itemCount - (numberOfPages - 1) * itemsPerPage;
                    _firstPage = pager.GetPage(itemsPerPage * itemWeight);
                    pager.PageCount += numberOfPages - 1;
                    if (numberOfPages > 1)
                    {
                        pager.RemainingWeight = Math.Max(0, pager.PageWeight - _lastPageItemCount * itemWeight);
                    }
                    _lastPage = _firstPage + numberOfPages - 1;
                }
            }
            else
            {
                int totalItemWeight = itemCount * itemWeight;
                if (totalItemWeight <= pager.RemainingWeight)
                {
                    _firstPageItemCount = itemCount;
                    _firstPage = _lastPage = pager.GetPage(totalItemWeight);
                }
                else
                {
                    _firstPageItemCount = pager.RemainingWeight / itemWeight;
                    int remainingItemCount = itemCount - _firstPageItemCount;
                    _fullPageItemCount  = Math.Max(1, pager.PageWeight / itemWeight);
                    int fullPageCount = remainingItemCount / _fullPageItemCount;
                    _lastPageItemCount  = remainingItemCount % _fullPageItemCount;
    
                    _firstPage = pager.PageCount;
    
                    //  increment for first page
                    pager.PageCount++;
                    pager.RemainingWeight = pager.PageWeight;
    
                    //  increment for full pages
                    pager.PageCount += fullPageCount;
    
                    //  remove remaining weight for last page
                    pager.RemainingWeight -= _lastPageItemCount * itemWeight;
    
                    //  correct if first page is empty
                    if (_firstPageItemCount == 0)
                    {
                        _firstPage++;
                        _firstPageItemCount = Math.Min(_fullPageItemCount, itemCount);
                    }
                    //  correct if last page is empty
                    if (_lastPageItemCount == 0)
                    {
                        pager.PageCount--;
                        _lastPageItemCount = Math.Min(_fullPageItemCount, itemCount);
                        pager.RemainingWeight = 0;
                    }
                    _lastPage = pager.PageCount;
                }
            }
            _control.FirstPage = _firstPage;
            _control.LastPage = _lastPage;
        }
예제 #4
0
        /// <include file='doc\MobileControl.uex' path='docs/doc[@for="MobileControl.PaginateRecursive"]/*' />
        public virtual void PaginateRecursive(ControlPager pager)
        {
            if (!EnablePagination)
            {
                return;
            }

            if (PaginateChildren || this.Form.ControlToPaginate == this)
            {
                int firstAssignedPage = -1;
                DoPaginateChildren(pager, this, ref firstAssignedPage);
                if (firstAssignedPage != -1)
                {
                    this.FirstPage = firstAssignedPage;
                }
                else
                {
                    this.FirstPage = pager.GetPage(GetVisibleWeight());
                }
                this.LastPage = pager.PageCount;
            }
            else
            {
                int pageNumber = pager.GetPage(GetVisibleWeight());
                SetControlPageRecursive(this, pageNumber);
                this.FirstPage = pageNumber;
                this.LastPage = pageNumber;
            }
        }