Пример #1
0
        private void DoIndentedText(string text, string heading)
        {
            if (text.Length > 0)
            {
                text = HandleText(text);

                GuideFrame left = LeftHeader(heading);

                GuideFrame right       = GetTextFrame(Mode.SingleColumn, FrameType.Text, true);
                Bounds     rightBounds = right.bounds;

                rightBounds.top   = left.bounds.top + 1;
                rightBounds.left += INDENTED + 1;
                right.ApplyBounds();
                right.AddPara(text, "text", true);

                right.ResizeToFit();

                if (right.OverflowsPage())
                {
                    if (right.page.contentBounds.bottom - right.bounds.top > 20)
                    {
                        GuidePage newPage = this.GetNextPage(right.page, true);

                        GuideFrame newFrame = right.SplitFrame(newPage);

                        newFrame.bounds.left = newFrame.page.contentBounds.left + INDENTED + 2;
                        //newFrame.TransformBoundsForNewPage(newPage);
                        newFrame.bounds.top = right.page.contentBounds.top;
                        newFrame.ApplyBounds();
                        newFrame.ResizeToFit();
                    }
                    else
                    {
                        //MoveFrameToNext(left, leftBounds, false);
                        left.MoveFrameToNext(false);

                        right.MoveToPage(currentPage);
                        right.bounds.top = left.bounds.top + 1;
                        right.ApplyBounds();
                        right.ResizeToFit();
                    }
                }
                else
                {
                    currentPage.nextTopMin = Math.Max(left.bounds.bottom + left.bottomOffset, right.bounds.bottom + left.bottomOffset);
                }
            }
        }
Пример #2
0
        public void MoveFrameToNext(bool split)
        {
            GuidePage beforePage = guide.currentPage;

            GuidePage newPage = beforePage;
            bool      fits    = false;

            while (!fits)
            {
                newPage = guide.GetNextPage(newPage, true);
                fits    = split || (newPage.contentBounds.bottom - newPage.GetNextTop() + 1) >= this.bounds.height;

                if (newPage.frames.Count == 0 && this.bounds.height > newPage.contentBounds.height)
                {
                    Log("!! Warning: frame larger than page size");
                    fits = true;
                }
            }

            if (split)
            {
                SplitFrame(newPage);
            }
            else
            {
                // move whole TF onto next page

                bool backfill = type == FrameType.Image &&
                                mode == Mode.SingleColumn &&
                                page.contentBounds.bottom - bounds.top > 25;

                GuideFrame prev  = page.GetPreviousFrame(this);
                GuideFrame prev2 = null;
                if (prev != null && !backfill)
                {
                    prev2 = page.GetPreviousFrame(prev);

                    if (prev.IsHeading())
                    {
                        if (prev2 != null && prev2.IsHeading())
                        {
                            prev2.MoveToPage(newPage);
                            prev.MoveToPage(newPage);
                        }
                        else
                        {
                            prev.MoveToPage(newPage);
                        }
                        backfill = false;
                    }
                    else if (prev2 != null &&
                             prev2.IsHeading() &&
                             (page.contentBounds.bottom - prev2.bounds.bottom < 20 || prev.bounds.height < 10))
                    {
                        prev2.MoveToPage(newPage);
                        prev.MoveToPage(newPage);
                        backfill = false;
                    }
                }

                MoveToPage(newPage);

                if (backfill)
                {
                    guide.currentPage = beforePage;
                }
                else
                {
                    guide.currentPage = newPage;
                }
            }
        }