Example #1
0
        /// <summary>
        /// Internal only.
        /// Gets the block.
        /// </summary>
        /// <param name="context">The context</param>
        /// <returns></returns>
        internal override GcBlock GetBlock(GcReportContext context)
        {
            GcBlock block = base.GetBlock(context);

            block.Cache = GenerateRangeBlock(this, this.leftSource, this.centerSource, this.rightSource, context);
            return(block);
        }
Example #2
0
 /// <summary>
 /// Gets the block.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <returns></returns>
 internal virtual GcBlock GetBlock(GcReportContext context)
 {
     Windows.Foundation.Size actualSize = this.GetActualSize(context);
     if (this.RotationAngle != 0.0)
     {
         Windows.Foundation.Rect rect = Shape.GetRotatedBounds(0.0, 0.0, actualSize.Width, actualSize.Height, this.RotationAngle, actualSize.Width / 2.0, actualSize.Height / 2.0);
         actualSize = new Windows.Foundation.Size(rect.Width, rect.Height);
     }
     return(new GcBlock((double)this.X, (double)this.Y, actualSize.Width, actualSize.Height, this));
 }
Example #3
0
        /// <summary>
        /// Gets all blocks.
        /// </summary>
        /// <param name="context">The context</param>
        /// <returns></returns>
        internal List <GcBlock> GetAllBlocks(GcReportContext context)
        {
            List <GcBlock> list = new List <GcBlock>();

            this.controls.Sort();
            foreach (GcPrintableControl control in this.controls.PrintableControls)
            {
                if (control.Visible)
                {
                    list.Add(control.GetBlock(context));
                }
            }
            return(list);
        }
Example #4
0
        /// <summary>
        /// Gets the actual size.
        /// </summary>
        /// <param name="context">The context</param>
        /// <returns></returns>
        internal virtual Windows.Foundation.Size GetActualSize(GcReportContext context)
        {
            int height = this.Height;

            if (this.CanGrow || this.CanShrink)
            {
                height = (int)Math.Ceiling(this.GetPreferredSize(context).Height);
                if (((height > this.Height) && !this.CanGrow) || ((height < this.Height) && !this.CanShrink))
                {
                    height = this.Height;
                }
            }
            return(new Windows.Foundation.Size((double)this.Width, (double)height));
        }
Example #5
0
        /// <summary>
        /// Gets the page count.
        /// </summary>
        /// <remarks>The PageRange property of the GcReport class is ignored.</remarks>
        /// <returns>Returns the number of pages in the PDF file.</returns>
        public int GetPageCount()
        {
            this.openTypeFontUtility = new OpenTypeFontUtility(GcReportContext.defaultFont, this.Dpi);
            GcReportContext context = new GcReportContext(this.report, this.Dpi, this.openTypeFontUtility)
            {
                UnitsPerInch = 0x48
            };

            this.context = context;
            this.context.GeneratePageBlocks();
            int num = 0;

            foreach (List <GcPageBlock> list in this.context.Pages)
            {
                num += list.Count;
            }
            return(num);
        }
Example #6
0
        /// <summary>
        /// Adjusts the line by part.
        /// </summary>
        /// <param name="lists">The lists.</param>
        /// <param name="context">The context.</param>
        /// <param name="part">The part.</param>
        /// <param name="includeY">if set to <c>true</c> [include Y].</param>
        /// <param name="allHeight">All height.</param>
        /// <param name="rect">The rect.</param>
        /// <returns></returns>
        internal static int AdjustLineByPart(List <GcPrintableControl> lists, GcReportContext context, int part, bool includeY, int allHeight, Windows.Foundation.Rect rect)
        {
            int num  = 0;
            int num2 = 0;

            foreach (GcPrintableControl control in lists)
            {
                if (control is GcLabel)
                {
                    ((GcLabel)control).AutoSize(context);
                }
                control.X = num2;
                num2     += control.Width;
                if (includeY)
                {
                    control.Y = allHeight;
                    num       = Math.Max(control.Height, num);
                }
            }
            switch (part)
            {
            case -1:
                num2 = 0;
                break;

            case 0:
                num2 = (int)((rect.Width - num2) / 2.0);
                break;

            case 1:
                num2 = (int)(rect.Width - num2);
                break;
            }
            foreach (GcPrintableControl control2 in lists)
            {
                control2.X += num2;
                if (includeY)
                {
                    control2.Y += num - control2.Height;
                }
            }
            return(num);
        }
Example #7
0
        /// <summary>
        /// Gets the preferred size.
        /// </summary>
        /// <param name="context">The context</param>
        /// <returns></returns>
        internal override Windows.Foundation.Size GetPreferredSize(GcReportContext context)
        {
            int num = base.width - this.alignment.TextIndent;

            num = Math.Max(0, num);
            if (this.padding.Horizontal > 0)
            {
                num -= this.padding.Horizontal;
            }
            if (num < 0)
            {
                num = 0;
            }
            Windows.Foundation.Size size = Utilities.MeasureStringByAlignment(context, this.Text, base.font, this.alignment, num);
            if (!size.IsEmpty && (this.padding.Vertical > 0))
            {
                size.Height += this.padding.Vertical;
            }
            return(size);
        }
Example #8
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);
        }
Example #9
0
 /// <summary>
 /// Creates the state of the build in control.
 /// </summary>
 /// <param name="context">The context</param>
 /// <returns></returns>
 internal virtual object CreateBuildInControlState(GcReportContext context)
 {
     return(null);
 }
Example #10
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="cache">The cache</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 GcRangeBlock GetRange(GcReportContext context, int x, int y, int width, int high, GcSectionCache cache, object buildInControlState, bool horizontal, bool continuePage)
 {
     return(this.GetRange(context, x, y, width, high, cache.AllBlocks, cache.AllSize, buildInControlState, horizontal, continuePage));
 }
Example #11
0
        /// <summary>
        /// Gets the cache.
        /// </summary>
        /// <param name="context">The context</param>
        /// <returns></returns>
        internal GcSectionCache GetCache(GcReportContext context)
        {
            List <GcBlock> allBlocks = this.GetAllBlocks(context);

            return(new GcSectionCache(this.GetAllSize((IEnumerable <GcBlock>)allBlocks), allBlocks));
        }
Example #12
0
 /// <summary>
 /// Gets the build in control 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="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 List <GcRangeBlock> GetBuildInControlRange(GcReportContext context, int x, int y, int width, int high, object buildInControlState, bool horizontal, bool continuePage)
 {
     return(null);
 }
Example #13
0
        /// <summary>
        /// Exports the inner.
        /// </summary>
        /// <param name="stream">The stream</param>
        /// <param name="doc">The doc.</param>
        /// <param name="saveAuto">if set to <c>true</c> [save auto].</param>
        /// <param name="checkEmpty">if set to <c>true</c> [check empty].</param>
        /// <param name="processSettings">if set to <c>true</c> [process settings].</param>
        /// <param name="otfu">The otfu.</param>
        /// <param name="frc">The FRC.</param>
        /// <param name="pageCount">The page count.</param>
        internal void ExportInner(Stream stream, PdfDocument doc, bool saveAuto, bool checkEmpty, bool processSettings, OpenTypeFontUtility otfu, GcReportContext frc, int pageCount)
        {
            bool flag2;

            doc             = doc ?? CreatePdfDocument();
            this.currentDoc = doc;
            if (processSettings)
            {
                this.settings.AppendTo(doc);
            }
            bool flag = false;

            if (otfu != null)
            {
                this.openTypeFontUtility     = otfu;
                this.openTypeFontUtility.Dpi = this.Dpi;
            }
            else
            {
                this.openTypeFontUtility = new OpenTypeFontUtility(GcReportContext.defaultFont, this.Dpi);
                flag = true;
                this.openTypeFontUtility.ExternalFont += this.ExternalFont;
            }
            if (frc != null)
            {
                this.context = frc;
            }
            else
            {
                GcReportContext context = new GcReportContext(this.report, this.Dpi, this.openTypeFontUtility)
                {
                    UnitsPerInch = 0x48
                };
                this.context = context;
                this.context.GeneratePageBlocks();
            }
            if (this.report.Watermark != null)
            {
                this.report.Watermark.Height = (int)this.context.PageRects.PageRectangle.Height;
                this.report.Watermark.Width  = (int)this.context.PageRects.PageRectangle.Width;
            }
            ExporterState state = new ExporterState(this.context)
            {
                BlackAndWhite = this.report.BlackAndWhite
            };
            int num = 0;

            foreach (List <GcPageBlock> list in this.context.Pages)
            {
                state.PageCount += list.Count;
                num              = Math.Max(list.Count, num);
            }
            if (pageCount >= 0)
            {
                state.PageCount = pageCount;
            }
            else
            {
                state.PageCount += this.report.FirstPageNumber - 1;
            }
            switch (this.context.Report.PageOrder)
            {
            case PrintPageOrder.Auto:
                flag2 = this.context.Pages.Count >= num;
                break;

            case PrintPageOrder.DownThenOver:
                flag2 = true;
                break;

            case PrintPageOrder.OverThenDown:
                flag2 = false;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            List <PageState> list2 = new List <PageState>();

            if (flag2)
            {
                for (int i = 0; i < num; i++)
                {
                    state.CurrentHPageNumber++;
                    state.CurrentVPageNumber = 0;
                    foreach (List <GcPageBlock> list3 in this.context.Pages)
                    {
                        if (list3.Count > i)
                        {
                            state.CurrentPageNumber++;
                            state.CurrentVPageNumber++;
                            list2.Add(new PageState(state.CurrentHPageNumber, state.CurrentVPageNumber, state.CurrentPageNumber, list3[i]));
                        }
                    }
                }
            }
            else
            {
                foreach (List <GcPageBlock> list4 in this.context.Pages)
                {
                    state.CurrentVPageNumber++;
                    state.CurrentHPageNumber = 0;
                    foreach (GcPageBlock block in list4)
                    {
                        state.CurrentPageNumber++;
                        state.CurrentHPageNumber++;
                        list2.Add(new PageState(state.CurrentHPageNumber, state.CurrentVPageNumber, state.CurrentPageNumber, block));
                    }
                }
            }
            if (list2.Count > 0)
            {
                if (string.IsNullOrEmpty(this.report.PageRange))
                {
                    foreach (PageState state2 in list2)
                    {
                        state.CurrentHPageNumber = state2.HPageIndex;
                        state.CurrentVPageNumber = state2.VPageIndex;
                        state.CurrentPageNumber  = (state2.PageIndex + this.report.FirstPageNumber) - 1;
                        this.ExportPage(state, doc, state2.PageBlock);
                    }
                }
                else
                {
                    foreach (int num3 in Utilities.GetPageRange(this.report.PageRange, list2.Count))
                    {
                        PageState state3 = list2[num3 - 1];
                        state.CurrentHPageNumber = state3.HPageIndex;
                        state.CurrentVPageNumber = state3.VPageIndex;
                        state.CurrentPageNumber  = (state3.PageIndex + this.report.FirstPageNumber) - 1;
                        this.ExportPage(state, doc, state3.PageBlock);
                    }
                }
            }
            if (checkEmpty && (doc.Pages.PageCount <= 0))
            {
                this.ExportEmptyPage(state, doc);
            }
            if (state.Bookmarks.Count > 0)
            {
                PdfOutlineItem item;
                if (doc.Outlines.Items.Count > 0)
                {
                    item = doc.Outlines.Items[0];
                }
                else
                {
                    item = new PdfOutlineItem(this.report.Bookmark, state.FirstPage);
                    doc.Outlines.Items.Add(item);
                }
                Dictionary <Bookmark, List <PdfOutlineItem> > dictionary = new Dictionary <Bookmark, List <PdfOutlineItem> >();
                foreach (ExporterState.BookmarkState state4 in state.Bookmarks)
                {
                    PdfOutlineItem item2 = new PdfOutlineItem(state4.Bookmark.Text, new PdfXYZDestination(state4.Page, (float)state4.Location.X, (float)state4.Location.Y, 0f));
                    if (!dictionary.ContainsKey(state4.Bookmark))
                    {
                        dictionary.Add(state4.Bookmark, new List <PdfOutlineItem>());
                    }
                    dictionary[state4.Bookmark].Add(item2);
                }
                foreach (KeyValuePair <Bookmark, List <PdfOutlineItem> > pair in dictionary)
                {
                    Bookmark bookmark           = pair.Key;
                    List <PdfOutlineItem> list6 = pair.Value;
                    if ((bookmark.Parent == null) || !dictionary.ContainsKey(bookmark.Parent))
                    {
                        foreach (PdfOutlineItem item3 in list6)
                        {
                            item.ChildItems.Add(item3);
                        }
                    }
                    else
                    {
                        List <PdfOutlineItem> list7 = dictionary[bookmark.Parent];
                        foreach (PdfOutlineItem item4 in list6)
                        {
                            PdfOutlineItem item5 = list7[0];
                            if (list7.Count > 1)
                            {
                                foreach (PdfOutlineItem item6 in list7)
                                {
                                    if (item6.Dest.TargetPage == item4.Dest.TargetPage)
                                    {
                                        item5 = item6;
                                        break;
                                    }
                                }
                            }
                            item5.ChildItems.Add(item4);
                        }
                    }
                }
            }
            if (processSettings)
            {
                if ((this.settings.DestinationType != DestinationType.Auto) || (doc.Pages.PageCount > 0))
                {
                    PdfArray array = new PdfArray();
                    if ((this.settings.OpenPageNumber <= doc.Pages.PageCount) && (doc.Pages.PageCount > 0))
                    {
                        array.Add(doc.Pages.Kids[this.settings.OpenPageNumber - 1]);
                    }
                    else
                    {
                        array.Add(doc.Pages.Kids[0]);
                    }
                    switch (this.settings.DestinationType)
                    {
                    case DestinationType.Auto:
                        break;

                    case DestinationType.FitPage:
                        array.Add(PdfName.Fit);
                        break;

                    case DestinationType.FitWidth:
                        array.Add(PdfName.FitH);
                        break;

                    case DestinationType.FitHeight:
                        array.Add(PdfName.FitV);
                        array.Add(PdfNumber.Zero);
                        break;

                    case DestinationType.FitBox:
                        array.Add(PdfName.FitB);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    doc.Add(PdfName.OpenAction, array);
                }
                if ((this.settings.DocumentAttachments.Count > 0) && (doc.Pages.PageCount > 0))
                {
                    PdfPage page = doc.Pages.Kids[doc.Pages.PageCount - 1] as PdfPage;
                    if (page != null)
                    {
                        foreach (DocumentAttachment attachment in this.settings.DocumentAttachments)
                        {
                            if ((!string.IsNullOrEmpty(attachment.Name) && (attachment.FileStreamInner != null)) && attachment.FileStreamInner.CanRead)
                            {
                                PdfFileAttachmentAnnotation annotation = new PdfFileAttachmentAnnotation {
                                    FileSpecification = { FileName = attachment.Name }
                                };
                                attachment.FileStreamInner.WriteTo((Stream)annotation.FileSpecification.FileStream.Data);
                                annotation.FileSpecification.FileStream.Size = attachment.FileStreamInner.Length;
                                annotation.FileSpecification.FileStream.MIME = attachment.ContentType;
                                annotation.ModifiedDate = DateTime.Now;
                                annotation.FileSpecification.FileStream.ModifyDate   = DateTime.Now;
                                annotation.FileSpecification.FileStream.CreationDate = DateTime.Now;
                                if (!string.IsNullOrEmpty(attachment.Description))
                                {
                                    annotation.Contents = attachment.Description;
                                }
                                if (attachment.Compress)
                                {
                                    annotation.FileSpecification.FileStream.Filters.Enqueue(PdfFilter.FlateFilter);
                                }
                                annotation.Flags     = PdfAnnotationBase.Flag.NoView | PdfAnnotationBase.Flag.Hidden | PdfAnnotationBase.Flag.Invisible;
                                annotation.Rectangle = new PdfRectangle(-100f, -100f, 1f, 1f);
                                page.Annotations.Add(annotation);
                            }
                        }
                    }
                }
            }
            if (saveAuto)
            {
                SavePdfDocment(doc, stream);
            }
            if (flag)
            {
                this.openTypeFontUtility.ExternalFont -= this.ExternalFont;
            }
        }
Example #14
0
 internal GcBlock GetBlock(GcReportContext context)
 {
     return(this.innerLabel.GetBlock(context));
 }
Example #15
0
        /// <summary>
        /// Generates the range block part.
        /// </summary>
        /// <param name="rLabel">The r label.</param>
        /// <param name="source">The source.</param>
        /// <param name="rect">The rect.</param>
        /// <param name="part">The part.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        static List <List <GcPrintableControl> > GenerateRangeBlockPart(GcRichLabel rLabel, string source, Windows.Foundation.Rect rect, int part, GcReportContext context)
        {
            List <List <GcPrintableControl> > list = new List <List <GcPrintableControl> >();

            if ((!string.IsNullOrEmpty(source) && !rect.IsEmpty) && ((rect.Width != 0.0) && (rect.Height != 0.0)))
            {
                string        str;
                StringReader  reader         = new StringReader(source);
                int           allHeight      = 0;
                Font          font           = rLabel.Font ?? context.DefaultFont;
                string        fontFamilyName = font.FontFamilyName;
                bool          strikeout      = font.Strikeout;
                double        fontSize       = font.FontSize;
                UnderlineType underline      = font.Underline;
                bool          bold           = font.Bold;
                bool          italic         = font.Italic;
                Brush         foreground     = rLabel.Foreground;
                Image         leftImage      = null;
                switch (part)
                {
                case -1:
                    leftImage = rLabel.LeftImage;
                    break;

                case 0:
                    leftImage = rLabel.CenterImage;
                    break;

                case 1:
                    leftImage = rLabel.RightImage;
                    break;
                }
                while ((str = reader.ReadLine()) != null)
                {
                    List <GcPrintableControl> lists = GenerateRangeBlockLine(rLabel, str, rect, leftImage, ref font, ref fontFamilyName, ref strikeout, ref fontSize, ref underline, ref bold, ref italic, ref foreground);
                    int num3 = AdjustLineByPart(lists, context, part, true, allHeight, rect);
                    list.Add(lists);
                    if ((num3 <= 0) && (lists.Count <= 0))
                    {
                        num3 = (int)Math.Ceiling(context.MeasureNoWrapString("X", font).Height);
                    }
                    allHeight += num3;
                }
                int num4 = 0;
                switch (rLabel.VerticalAlignment)
                {
                case TextVerticalAlignment.General:
                case TextVerticalAlignment.Top:
                case TextVerticalAlignment.Justify:
                    break;

                case TextVerticalAlignment.Center:
                case TextVerticalAlignment.Distributed:
                    num4 = (int)((rect.Height - allHeight) / 2.0);
                    break;

                case TextVerticalAlignment.Bottom:
                    num4 = (int)(rect.Height - allHeight);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                if (num4 != 0)
                {
                    using (List <List <GcPrintableControl> > .Enumerator enumerator = list.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            foreach (GcPrintableControl local1 in enumerator.Current)
                            {
                                local1.Y += num4;
                            }
                        }
                    }
                }
            }
            return(list);
        }
Example #16
0
        /// <summary>
        /// Generates the range block.
        /// </summary>
        /// <param name="rLabel">The r label.</param>
        /// <param name="leftSource">The left source.</param>
        /// <param name="centerSource">The center source.</param>
        /// <param name="rightSource">The right source.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        static List <List <List <GcPrintableControl> > > GenerateRangeBlock(GcRichLabel rLabel, string leftSource, string centerSource, string rightSource, GcReportContext context)
        {
            int width  = rLabel.Width;
            int height = rLabel.Height;

            if (rLabel.Padding.Horizontal > 0)
            {
                width -= rLabel.Padding.Horizontal;
            }
            if (rLabel.Padding.Vertical > 0)
            {
                width -= rLabel.Padding.Vertical;
            }
            Windows.Foundation.Rect rect = new Windows.Foundation.Rect(0.0, 0.0, (double)width, (double)height);
            List <List <List <GcPrintableControl> > > list = new List <List <List <GcPrintableControl> > > {
                null, null, null
            };

            if ((!string.IsNullOrEmpty(leftSource) || !string.IsNullOrEmpty(centerSource)) || !string.IsNullOrEmpty(rightSource))
            {
                if ((rect.IsEmpty || (rect.Width == 0.0)) || (rect.Height == 0.0))
                {
                    return(list);
                }
                string str  = leftSource;
                string str2 = centerSource;
                string str3 = rightSource;
                if (!string.IsNullOrEmpty(str))
                {
                    list[0] = GenerateRangeBlockPart(rLabel, str, rect, -1, context);
                }
                if (!string.IsNullOrEmpty(str2))
                {
                    list[1] = GenerateRangeBlockPart(rLabel, str2, rect, 0, context);
                }
                if (!string.IsNullOrEmpty(str3))
                {
                    list[2] = GenerateRangeBlockPart(rLabel, str3, rect, 1, context);
                }
            }
            return(list);
        }
Example #17
0
 /// <summary>
 /// Changes the size automatically.
 /// </summary>
 /// <param name="context">The context.</param>
 internal void AutoSize(GcReportContext context)
 {
     Windows.Foundation.Size preferredSize = this.GetPreferredSize(context);
     this.Width  = (int)Math.Ceiling(preferredSize.Width);
     this.Height = (int)Math.Ceiling(preferredSize.Height);
 }
Example #18
0
        /// <summary>
        /// Gets all sizes.
        /// </summary>
        /// <param name="context">The context</param>
        /// <returns></returns>
        internal Windows.Foundation.Size GetAllSize(GcReportContext context)
        {
            List <GcBlock> allBlocks = this.GetAllBlocks(context);

            return(this.GetAllSize((IEnumerable <GcBlock>)allBlocks));
        }
Example #19
0
 /// <summary>
 /// Gets the preferred size.
 /// </summary>
 /// <param name="context">The context</param>
 /// <returns></returns>
 internal virtual Windows.Foundation.Size GetPreferredSize(GcReportContext context)
 {
     return(this.GetBounds());
 }
Example #20
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);
        }
Example #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Dt.Cells.Data.ExporterState" /> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public ExporterState(GcReportContext context)
 {
     this.context = context;
 }