Esempio n. 1
0
        /// <summary>
        /// Gets the range.
        /// </summary>
        /// <param name="context">The context</param>
        /// <param name="x">The x</param>
        /// <param name="y">The y</param>
        /// <param name="width">The width</param>
        /// <param name="high">The height</param>
        /// <param name="blocks">The blocks</param>
        /// <param name="allSize">All sizes</param>
        /// <param name="buildInControlState">State of the build in control</param>
        /// <param name="horizontal">If set to <c>true</c>, [horizontal]</param>
        /// <param name="continuePage">If set to <c>true</c>, [continue page]</param>
        /// <returns></returns>
        internal virtual GcRangeBlock GetRange(GcReportContext context, int x, int y, int width, int high, List <GcBlock> blocks, Windows.Foundation.Size allSize, object buildInControlState, bool horizontal, bool continuePage)
        {
            List <GcRangeBlock> list = this.GetBuildInControlRange(context, x, y, width, high, buildInControlState, horizontal, continuePage);

            Windows.Foundation.Size size = allSize;
            Windows.Foundation.Rect rect = new Windows.Foundation.Rect(0.0, 0.0, size.Width, size.Height);
            if ((list != null) && (list.Count > 0))
            {
                foreach (GcRangeBlock block in list)
                {
                    rect.Union(new Windows.Foundation.Rect(block.X, block.Y, block.Width, block.Height));
                }
            }
            Windows.Foundation.Rect rect2 = new Windows.Foundation.Rect((double)x, (double)y, (double)width, (double)high);
            if (!IsIntersect(rect, rect2))
            {
                return(new GcRangeBlock(0.0, 0.0, 0.0, 0.0));
            }
            rect.Intersect(rect2);
            GcRangeBlock block2 = new GcRangeBlock(0.0, 0.0, (double)((int)Math.Ceiling(rect.Width)), (double)((int)Math.Ceiling(rect.Height)))
            {
                OffsetX = (int)rect.X,
                OffsetY = (int)rect.Y
            };

            if ((list != null) && (list.Count > 0))
            {
                foreach (GcRangeBlock block3 in list)
                {
                    block2.Blocks.Add(block3);
                }
            }
            foreach (GcBlock block4 in blocks)
            {
                if (block4.IntersectWith((double)((int)rect.X), (double)((int)rect.Y), (double)((int)rect.Width), (double)((int)rect.Height)))
                {
                    block2.Blocks.Add(block4.Clone());
                }
            }
            return(block2);
        }
Esempio n. 2
0
        /// <summary>
        /// Generates the pages.
        /// </summary>
        /// <param name="context">The context</param>
        /// <param name="continuePage">If set to <c>true</c>, [continue page]</param>
        /// <param name="offset">The offset</param>
        /// <param name="pageHeaderOffset">The page header offset</param>
        /// <returns></returns>
        internal virtual bool GeneratePages(GcReportContext context, bool continuePage, ref double offset, ref double pageHeaderOffset)
        {
            int num;
            GcPageHeaderSection pageHeader = context.PageHeader;
            GcPageFooterSection pageFooter = context.PageFooter;

            GcSection.GcSectionCache pageHeaderCache = context.PageHeaderCache;
            GcSection.GcSectionCache pageFooterCache = context.PageFooterCache;
            List <int> horizontalPageBreaks          = this.GetHorizontalPageBreaks();

            GcSection.GcSectionCache cache   = base.GetCache(context);
            Windows.Foundation.Size  allSize = base.GetAllSize(cache);
            PaperCutter cutter = new PaperCutter((int)context.PageRects.CropRectangle.Height, (int)allSize.Height, (IEnumerable <int>)horizontalPageBreaks);
            bool        flag   = this is IGcAllowAppendixSection;

            if (flag)
            {
                if (pageHeader != null)
                {
                    cutter.MaxLength -= (int)pageHeader.GetAllSize(pageHeaderCache).Height;
                }
                if (pageFooter != null)
                {
                    cutter.MaxLength -= (int)pageFooter.GetAllSize(pageFooterCache).Height;
                }
            }
            if (this.PageBreakBefore || (offset >= cutter.MaxLength))
            {
                continuePage = false;
            }
            if (!continuePage)
            {
                offset           = 0.0;
                pageHeaderOffset = 0.0;
            }
            List <GcPageBlock> list2 = (continuePage && (context.Pages.Count > 0)) ? context.Pages[context.Pages.Count - 1] : new List <GcPageBlock>();

            if (continuePage)
            {
                cutter.AddBreakIfFirst((int)(cutter.MaxLength - offset));
            }
            object buildInControlState = this.CreateBuildInControlState(context);
            double num2       = offset;
            bool   horizontal = false;
            int    num3       = 0;

            while (cutter.Next(out num) || this.HasMorePage(buildInControlState, horizontal))
            {
                int        num6;
                List <int> verticalPageBreaks = this.GetVerticalPageBreaks();
                int        width = (int)allSize.Width;
                if (flag)
                {
                    width = Math.Max(width, context.PageHeaderFooterMaxWidth);
                }
                PaperCutter cutter2 = new PaperCutter((int)context.PageRects.CropRectangle.Width, width, (IEnumerable <int>)verticalPageBreaks);
                int         num5    = 0;
                while (cutter2.Next(out num6) || this.HasMorePage(buildInControlState, horizontal))
                {
                    if (num5 >= list2.Count)
                    {
                        list2.Add(context.CreateNewPage());
                    }
                    GcPageBlock block  = list2[num5];
                    int         x      = cutter2.Current - num6;
                    int         y      = cutter.Current - num;
                    int         height = 0;
                    if (flag)
                    {
                        if ((pageHeader != null) && (block.PageHeader == null))
                        {
                            height = (int)pageHeader.GetAllSize(pageHeaderCache).Height;
                        }
                        if (pageFooter != null)
                        {
                            num3 = (int)pageFooter.GetAllSize(pageFooterCache).Height;
                        }
                        if ((height + num3) >= num)
                        {
                            num3 = 0;
                        }
                        if ((height + num3) >= num)
                        {
                            height = 0;
                        }
                    }
                    else if ((pageFooter != null) && (block.PageFooter != null))
                    {
                        num3 = (int)pageFooter.GetAllSize(pageFooterCache).Height;
                        if ((height + num3) >= num)
                        {
                            num3 = 0;
                        }
                    }
                    GcRangeBlock block2 = base.GetRange(context, x, y, num6, num, cache, buildInControlState, horizontal, continuePage);
                    if (flag)
                    {
                        if (((pageHeader != null) && (block.PageHeader == null)) && (height > 0))
                        {
                            block.PageHeader = pageHeader.GetRange(context, pageHeader.HorizontalExtend ? x : 0, 0, (int)context.PageRects.PageHeaderRectangle.Width, (int)context.PageRects.PageHeaderRectangle.Height, pageHeaderCache, buildInControlState, horizontal, continuePage);
                            if (continuePage)
                            {
                                GcRangeBlock block1 = block.PageHeader;
                                block1.Y += pageHeaderOffset;
                            }
                        }
                        if (((pageFooter != null) && (block.PageFooter == null)) && (num3 > 0))
                        {
                            block.PageFooter   = pageFooter.GetRange(context, pageFooter.HorizontalExtend ? x : 0, 0, (int)context.PageRects.PageFooterRectangle.Width, (int)context.PageRects.PageFooterRectangle.Height, pageFooterCache, buildInControlState, horizontal, continuePage);
                            block.PageFooter.Y = ((int)context.PageRects.CropRectangle.Height) - num3;
                        }
                    }
                    if ((context.TopMargin != null) && (block.TopMargin == null))
                    {
                        block.TopMargin   = context.TopMargin.GetRange(context, context.TopMargin.HorizontalExtend ? x : 0, 0, (int)context.PageRects.TopMarginRectangle.Width, (int)context.PageRects.TopMarginRectangle.Height, context.TopMarginCache, buildInControlState, horizontal, continuePage);
                        block.TopMargin.X = context.PageRects.TopMarginRectangle.X;
                        block.TopMargin.Y = context.PageRects.TopMarginRectangle.Y;
                    }
                    if ((context.BottomMargin != null) && (block.BottomMargin == null))
                    {
                        block.BottomMargin   = context.BottomMargin.GetRange(context, context.BottomMargin.HorizontalExtend ? x : 0, 0, (int)context.PageRects.BottomMarginRectangle.Width, (int)context.PageRects.BottomMarginRectangle.Height, context.BottomMarginCache, buildInControlState, horizontal, continuePage);
                        block.BottomMargin.X = context.PageRects.BottomMarginRectangle.X;
                        block.BottomMargin.Y = context.PageRects.BottomMarginRectangle.Y;
                    }
                    block2.Y += height;
                    if (continuePage)
                    {
                        block2.Y += num2;
                    }
                    if ((!flag && (pageFooter != null)) && (block.PageFooter != null))
                    {
                        block.PageFooter.Y = block2.Y;
                        block2.Y          += num3;
                    }
                    block.Blocks.Add(block2);
                    if (!horizontal)
                    {
                        offset = (num2 + block2.Height) + height;
                    }
                    num5++;
                    horizontal = true;
                }
                pageHeaderOffset = 0.0;
                num2             = 0.0;
                horizontal       = false;
                continuePage     = false;
                if (!context.Pages.Contains(list2))
                {
                    context.Pages.Add(list2);
                }
                list2 = new List <GcPageBlock>();
            }
            continuePage = !this.PageBreakAfter;
            if (continuePage && (offset >= (context.PageRects.CropRectangle.Height - num3)))
            {
                continuePage = !continuePage;
            }
            if (!continuePage)
            {
                offset = 0.0;
            }
            pageHeaderOffset = flag ? 0.0 : offset;
            return(continuePage);
        }