示例#1
0
 internal static void DoPaginateChildren(ControlPager pager, Control ctl, ref int firstAssignedPage)
 {
     if (ctl.HasControls())
     {
         foreach (Control child in ctl.Controls)
         {
             if (child.Visible)
             {
                 MobileControl mobileCtl = child as MobileControl;
                 if (mobileCtl != null)
                 {
                     mobileCtl.PaginateRecursive(pager);
                     if (firstAssignedPage == -1)
                     {
                         firstAssignedPage = mobileCtl.FirstPage;
                     }
                 }
                 else if (child is UserControl)
                 {
                     DoPaginateChildren(pager, child, ref firstAssignedPage);
                 }
             }
         }
     }
 }
示例#2
0
        private int PaginateForm()
        {
            int pageWeight = MobilePage.Adapter.OptimumPageWeight;

            if (Header != null)
            {
                pageWeight -= Header.VisibleWeight;
            }
            if (Footer != null)
            {
                pageWeight -= Footer.VisibleWeight;
            }
            if (pageWeight <= 0)
            {
                //


                pageWeight = MobilePage.Adapter.OptimumPageWeight / 2;
            }

            if (IsFormPaginationAllowed())
            {
                if ((Paginate) || (ControlToPaginate == this))
                {
                    ControlPager pager = new ControlPager(this, pageWeight);
                    base.PaginateRecursive(pager);
                    return(pager.PageCount);
                }
                else if (ControlToPaginate != null)
                {
                    ControlPager pager = new ControlPager(this, pageWeight);
                    SetControlPage(1);
                    Control       control = ControlToPaginate;
                    MobileControl ctp     = control as MobileControl;
                    if (ctp != null)
                    {
                        ctp.PaginateRecursive(pager);
                    }
                    else
                    {
                        int firstAssignedPage = -1;
                        DoPaginateChildren(pager, control, ref firstAssignedPage);
                    }
                    while (control != this)
                    {
                        MobileControl mc = control as MobileControl;
                        if (mc != null)
                        {
                            if (mc is Form)
                            {
                                throw(new Exception(SR.GetString(SR.Form_InvalidControlToPaginateForm)));
                            }
                            if (mc.FirstPage > ctp.FirstPage)
                            {
                                mc.FirstPage = ctp.FirstPage;
                            }
                            if (mc.LastPage < ctp.LastPage)
                            {
                                mc.LastPage = ctp.LastPage;
                            }
                        }
                        control = control.Parent;
                    }
                    this.LastPage = Math.Max(pager.PageCount, 1);
                    if (Header != null)
                    {
                        SetEnablePaginationRecursive(Header, false);
                    }
                    if (Footer != null)
                    {
                        SetEnablePaginationRecursive(Footer, false);
                    }
                    return(this.LastPage);
                }
            }

            return(1);
        }