Пример #1
0
 /// <summary>
 /// Construct a text trailing word ellipsis collapsing properties
 /// </summary>
 /// <param name="width">width in which collapsing is constrained to</param>
 /// <param name="textRunProperties">text run properties of ellispis symbol</param>
 public TextTrailingWordEllipsis(
     double width,
     TextRunProperties textRunProperties
     )
 {
     Width  = width;
     Symbol = new TextCharacters(s_ellipsis, textRunProperties);
 }
Пример #2
0
 /// <summary>
 /// Construct a text trailing word ellipsis collapsing properties.
 /// </summary>
 /// <param name="ellipsis">Text used as collapsing symbol.</param>
 /// <param name="width">width in which collapsing is constrained to.</param>
 /// <param name="textRunProperties">text run properties of ellipsis symbol.</param>
 public TextTrailingWordEllipsis(
     ReadOnlySlice <char> ellipsis,
     double width,
     TextRunProperties textRunProperties
     )
 {
     Width  = width;
     Symbol = new TextCharacters(ellipsis, textRunProperties);
 }
Пример #3
0
        /// <summary>
        /// Fetches text runs.
        /// </summary>
        /// <param name="textSource">The text source.</param>
        /// <param name="firstTextSourceIndex">The first text source index.</param>
        /// <param name="endOfLine"></param>
        /// <param name="textRange"></param>
        /// <returns>
        /// The formatted text runs.
        /// </returns>
        private static List <TextCharacters> FetchTextRuns(ITextSource textSource, int firstTextSourceIndex,
                                                           out TextEndOfLine?endOfLine, out TextRange textRange)
        {
            var length = 0;

            endOfLine = null;

            var textRuns = new List <TextCharacters>();

            var textRunEnumerator = new TextRunEnumerator(textSource, firstTextSourceIndex);

            while (textRunEnumerator.MoveNext())
            {
                var textRun = textRunEnumerator.Current;

                if (textRun == null)
                {
                    break;
                }

                switch (textRun)
                {
                case TextCharacters textCharacters:
                {
                    if (TryGetLineBreak(textCharacters, out var runLineBreak))
                    {
                        var splitResult = new TextCharacters(textCharacters.Text.Take(runLineBreak.PositionWrap),
                                                             textCharacters.Properties);

                        textRuns.Add(splitResult);

                        length += runLineBreak.PositionWrap;

                        textRange = new TextRange(firstTextSourceIndex, length);

                        return(textRuns);
                    }

                    textRuns.Add(textCharacters);

                    break;
                }

                case TextEndOfLine textEndOfLine:
                    endOfLine = textEndOfLine;
                    break;
                }

                length += textRun.Text.Length;
            }

            textRange = new TextRange(firstTextSourceIndex, length);

            return(textRuns);
        }
        /// <summary>
        /// Construct a text trailing word ellipsis collapsing properties.
        /// </summary>
        /// <param name="ellipsis">Text used as collapsing symbol.</param>
        /// <param name="prefixLength">Length of leading prefix.</param>
        /// <param name="width">width in which collapsing is constrained to</param>
        /// <param name="textRunProperties">text run properties of ellispis symbol</param>
        public TextLeadingPrefixCharacterEllipsis(
            ReadOnlySlice <char> ellipsis,
            int prefixLength,
            double width,
            TextRunProperties textRunProperties)
        {
            if (_prefixLength < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(prefixLength));
            }

            _prefixLength = prefixLength;
            Width         = width;
            Symbol        = new TextCharacters(ellipsis, textRunProperties);
        }