Exemplo n.º 1
0
        private void AppendToLine(TextToken token, double textWidth)
        {
            string text = token.Text;

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            _block = _block ?? new TextTokenBlock
            {
                TextAlign    = _lastOpenTag.TextProperties.TextAlign,
                MarginLeft   = _marginLeft,
                MarginRight  = _marginRight,
                FirstTokenID = _firstTokenID,
                TextIndent   = _textIndent
            };

            _block.LastTokenID = token.ID;
            _block.UpdateHeight(GetTextHeight(text));
            if (_separator)
            {
                TextVisualProperties properties = _lastOpenTag.TextProperties.Clone();
                var inlineItem = _block.Inlines.OfType <TextElement>().LastOrDefault();
                if (inlineItem != null && string.IsNullOrEmpty(inlineItem.LinkID))
                {
                    properties.LinkID = string.Empty;
                }
                _block.AddText(" ", properties, _fontSize, GetTextSize(" ", properties));
            }
            _block.AddText(text, _lastOpenTag.TextProperties, _fontSize, GetTextSize(text, _lastOpenTag.TextProperties), token.Part, token.ID);
            _textWidth += textWidth;
        }
Exemplo n.º 2
0
        private void CreateLine(TextToken token)
        {
            CreateEmptyLine(token);

            string text = token.Text;

            _block.UpdateHeight(GetTextHeight(text));
            _textWidth = GetTextWidth(text, false, _lastOpenTag.TextProperties);
            _block.AddText(
                text,
                _lastOpenTag.TextProperties,
                _fontSize,
                GetTextSize(text, _lastOpenTag.TextProperties),
                token.Part,
                token.ID);
        }