示例#1
0
        protected override DocumentFragment GetResultFragment()
        {
            int totalPageCount              = 1;
            int totalPageInCurrentSection   = 1;
            int currentPageInCurrentSection = 1;

            if (this.EvaluationContext != null)
            {
                totalPageCount = this.GetTotalPageCount();

                LayoutBox box = this.EvaluationContext.AssociatedLayoutBoxInMainDocument ?? this.FieldStart.FirstLayoutBox;

                currentPageInCurrentSection = this.GetCurrentPageFromSectionPages(box);
                totalPageInCurrentSection   = this.GetPageCountInSection(box);
            }

            return(DocumentFragment.CreateFromInline(new Span(
                                                         string.Format("Total pages in the document: {0}. Pages in current section: {1} / {2}",
                                                                       totalPageCount, currentPageInCurrentSection, totalPageInCurrentSection))));
        }
示例#2
0
        protected override DocumentFragment GetResultFragment()
        {
            int totalPagesCount             = 1;
            int totalPagesInCurrentSection  = 1;
            int currentPageInCurrentSection = 1;

            if (this.EvaluationContext != null)
            {
                totalPagesCount = this.GetTotalPageCount();

                LayoutBox box = this.EvaluationContext.AssociatedLayoutBoxInMainDocument ?? this.FieldStart.FirstLayoutBox;
                currentPageInCurrentSection = this.GetCurrentPageFromSectionPages(box);
                totalPagesInCurrentSection  = this.GetPageCountInSection(box);
            }

            string totalPagesCountWithFormatting             = this.GetNumberWithFormatting(totalPagesCount);
            string totalPagesInCurrentSectionWithFormatting  = this.GetNumberWithFormatting(currentPageInCurrentSection);
            string currentPageInCurrentSectionWithFormatting = this.GetNumberWithFormatting(totalPagesInCurrentSection);

            string textToInsert = !string.IsNullOrEmpty(this.DocumentName)
                ? string.Format("Total pages in the document ({0}): {1}. Pages in current section: {2} / {3}",
                                this.DocumentName,
                                totalPagesCountWithFormatting,
                                totalPagesInCurrentSectionWithFormatting,
                                currentPageInCurrentSectionWithFormatting)
                : string.Format("Total pages in the document: {0}. Pages in current section: {1} / {2}",
                                totalPagesCountWithFormatting,
                                totalPagesInCurrentSectionWithFormatting,
                                currentPageInCurrentSectionWithFormatting);

            Span spanToInsert = new Span(textToInsert);

            Span currentSpan = this.EvaluationContext.Document.CaretPosition.GetCurrentSpan();

            if (currentSpan != null)
            {
                spanToInsert.CopyPropertiesFrom(currentSpan);
            }

            return(DocumentFragment.CreateFromInline(spanToInsert));
        }
 protected override DocumentFragment GetResultFragment()
 {
     return(DocumentFragment.CreateFromInline(new Span(this.MyProperty)));
 }