Exemplo n.º 1
0
        public static IEnumerable <PageRegion> UnionPageRegions(
            this IEnumerable <PageRegion> pageRegions,
            Margin contentMargin)
        {
            var unioned = pageRegions
                          .GroupBy(pr => pr.PagePosition)
                          .Select(grp =>
            {
                var rectangle = Rectangle.Union(grp.Select(r => r.Region));
                return(new PageRegion(grp.Key, rectangle));
            })
                          .Select((pr, i) =>
            {
                var top = i == 0
                        ? contentMargin.Top
                        : 0;
                var npr = new PageRegion(pr.PagePosition, pr.Region.Inflate(top, contentMargin.Right, 0, contentMargin.Left));
                return(npr);
            })
                          .ToArray();

            var last = unioned.Last();

            unioned[unioned.Length - 1] = new PageRegion(last.PagePosition, last.Region.Inflate(0, 0, contentMargin.Bottom, 0));

            return(unioned);
        }
Exemplo n.º 2
0
 protected void SetPageRegion(PageRegion pageRegion)
 {
     this.PageRegions = this.PageRegions
                        .Where(pr => pr.PagePosition != pageRegion.PagePosition)
                        .Union(new[] { pageRegion })
                        .OrderBy(pr => pr.PagePosition)
                        .ToArray();
 }