public RtfControlContentRange GetNextRange(float deltaHeight, string rtf)
        {
            var newInfo    = new RtfContentInfo(rtf, Info.Area, Info.TotalSize);
            var newContent = new RtfControlContentRange(_owner, newInfo);

            newContent.StartVertRange += deltaHeight;
            newContent.EndVertRange   += deltaHeight;

            return(newContent);
        }
Exemple #2
0
        public LayoutResult Measure(LayoutContext ctx)
        {
            var content = ctx.ContentRange as RtfControlContentRange;

            if (_computedSize.Width == 0)
            {
                _computedSize.Width = ctx.AvailableSize.Width;
            }

            if (_computedSize.Height == 0)
            {
                _computedSize.Height = ctx.AvailableSize.Height;
            }

            if (ctx.VerticalLayout)
            {
                if (content == null)
                {
                    var fitHeight = Math.Min(ctx.AvailableSize.Height, _computedSize.Height);
                    var range     = new Range(0, fitHeight, 0, -1);
                    var rtf       = GetNextRtf(range.Bottom);
                    var info      = new RtfContentInfo(rtf, range, _computedSize);

                    content = new RtfControlContentRange(_control, info);
                    _computedSize.Height = fitHeight;
                }
                else
                {
                    var restHeight = content.Info.TotalSize.Height - content.EndVertRange;
                    var fitHeight  = Math.Min(ctx.AvailableSize.Height, restHeight);
                    var rtf        = GetNextRtf(content.EndVertRange + fitHeight);

                    content = content.GetNextRange(fitHeight, rtf);
                    _computedSize.Height = fitHeight;
                }

                _status |= LayoutStatus.ContinueVertically | LayoutStatus.SomeContent;

                if (content.isLastPage)
                {
                    return(new LayoutResult(content, LayoutStatus.SomeContent | LayoutStatus.Complete, _computedSize));
                }
            }

            return(new LayoutResult(content, _status, _computedSize));
        }