コード例 #1
0
ファイル: CBaseReport.cs プロジェクト: pjamenaja/onixlegacy
        private void populatePageItems <T>(CReportPageParam prm, int itemPerPage, int pageNo, ObservableCollection <T> collection) where T : MBaseModel
        {
            int start = (pageNo - 1) * itemPerPage + 1;
            int end   = start + itemPerPage - 1;

            prm.Items.Clear();

            int i = 0;

            foreach (T m in collection)
            {
                if (m.ExtFlag.Equals("D"))
                {
                    continue;
                }

                i++;

                if ((i >= start) && (i <= end))
                {
                    prm.Items.Add(m);
                }
            }

            prm.StartIndex     = start;
            prm.EndIndex       = end;
            prm.TotalItemCount = collection.Count;

            int remain = itemPerPage - prm.Items.Count;

            prm.PatchRow = remain;
        }
コード例 #2
0
ファイル: CBaseReport.cs プロジェクト: pjamenaja/onixlegacy
        //Form fixed document
        public virtual FixedDocument CreateFixedDocument()
        {
            ArrayList pageParams = new ArrayList();

            if (dataSource != null)
            {
                initPageCreateFlow();
                pageParams = createPageParam();
            }
            else
            {
                CReportPageParam dummyPage = new CReportPageParam();
                pageParams.Add(dummyPage);
            }

            int pc = pageParams.Count;

            FixedDocument fd = new FixedDocument();
            Size          s  = new Size(rptCfg.PageWidthDot, rptCfg.PageHeightDot);

            fd.DocumentPaginator.PageSize = s;

            pages.Clear();

            for (int i = 1; i <= pc; i++)
            {
                if (!isInRange(i))
                {
                    continue;
                }

                CReportPageParam pageParam = (CReportPageParam)pageParams[i - 1];
                UserControl      page      = createPageObject(s, i, pc, pageParam);

                page.Width  = rptCfg.AreaWidthDot;
                page.Height = rptCfg.AreaHeightDot;
                page.Measure(s);

                FixedPage fp = new FixedPage();
                fp.Margin = new Thickness(rptCfg.MarginLeftDot, rptCfg.MarginTopDot, rptCfg.MarginRightDot, rptCfg.MarginBottomDot);

                PageContent pageContent = new PageContent();
                ((System.Windows.Markup.IAddChild)pageContent).AddChild(fp);

                fd.Pages.Add(pageContent);
                fp.Children.Add(page);

                pages.Add(fp);
            }

            keepFixedDoc = fd;

            return(fd);
        }
コード例 #3
0
ファイル: CBaseReport.cs プロジェクト: pjamenaja/onixlegacy
        protected ArrayList createPageParamEasy <T>(ObservableCollection <T> collection, int itemPerPage) where T : MBaseModel
        {
            int arrcnt = 0;

            foreach (T mi in collection)
            {
                if (!mi.ExtFlag.Equals("D"))
                {
                    arrcnt++;
                }
            }

            int pcnt      = 0;
            int remainder = 0;

            if (itemPerPage > 0)
            {
                pcnt      = arrcnt / itemPerPage;
                remainder = arrcnt % itemPerPage;
            }

            int pageCount = 0;

            if (pcnt == 0)
            {
                pageCount = 1;
            }
            else if (remainder == 0)
            {
                pageCount = pcnt;
            }
            else
            {
                pageCount = pcnt + 1;
            }

            ArrayList pageParams = new ArrayList();

            for (int i = 0; i < pageCount; i++)
            {
                CReportPageParam prm = new CReportPageParam();
                prm.ItemPerPage = itemPerPage;

                populatePageItems(prm, itemPerPage, i + 1, collection);

                pageParams.Add(prm);
            }

            return(pageParams);
        }
コード例 #4
0
ファイル: CBaseReport.cs プロジェクト: pjamenaja/onixlegacy
 protected virtual UserControl createPageObject(Size s, int page, int pageCount, CReportPageParam param)
 {
     return(null);
 }
コード例 #5
0
ファイル: CBaseReport.cs プロジェクト: pjamenaja/onixlegacy
        protected ArrayList createPageParamComplex <T>(ObservableCollection <T> collection, int itemPerPage) where T : MBaseModel
        {
            ArrayList pageParams = new ArrayList();

            double areaHeight = CUtil.StringToDouble(rptCfg.GetConfigValue("PrevAreaHeight"));
            double itemWidth  = CUtil.StringToDouble(rptCfg.GetConfigValue("PrevItemWidth"));

            double defaultItemHeigh = getItemHeight(itemWidth, null, "");

            int arrcnt = 0;

            foreach (T mi in collection)
            {
                if (!mi.ExtFlag.Equals("D"))
                {
                    arrcnt++;
                }
            }

            CReportPageParam prm          = null;
            double           remainHeight = areaHeight;
            int itemNo = 0;

            foreach (T mi in collection)
            {
                if (mi.ExtFlag.Equals("D"))
                {
                    continue;
                }

                if (itemNo == 0)
                {
                    prm            = new CReportPageParam();
                    prm.StartIndex = 1;
                    prm.EndIndex   = 1;

                    pageParams.Add(prm);
                }

                itemNo++;
                double itemHeight = getItemHeight(itemWidth, mi, itemPropertyName); //getItemHeight(itemWidth, mi);

                if (itemHeight > remainHeight)
                {
                    //New page
                    prm            = new CReportPageParam();
                    prm.StartIndex = itemNo;

                    pageParams.Add(prm);

                    remainHeight = areaHeight;
                }

                remainHeight = remainHeight - itemHeight;
                prm.Items.Add(mi);
                prm.EndIndex       = itemNo;
                prm.ItemPerPage    = prm.EndIndex - prm.StartIndex + 1;
                prm.TotalItemCount = arrcnt;
                prm.PatchRow       = (int)Math.Ceiling(remainHeight / defaultItemHeigh);
            }

            return(pageParams);
        }