示例#1
0
        /// <inheritdoc />
        public override TextSpan <CultureSpecificCharacterBufferRange> GetPrecedingText(int textSourceCharacterIndexLimit)
        {
            Debug.WriteLine($"{nameof(GetPrecedingText)}: {textSourceCharacterIndexLimit}");
            var span = Spans.FirstOrDefault(z => z.Value.StartIndex + z.Value.Length == textSourceCharacterIndexLimit);

            if (span != null)
            {
                return(new TextSpan <CultureSpecificCharacterBufferRange>(span.Length, new CultureSpecificCharacterBufferRange(CultureInfo.CurrentUICulture, new CharacterBufferRange(TextBuffer, span.Value.StartIndex, span.Length))));
            }

            span = Spans.LastOrDefault(z => z.Value.StartIndex < textSourceCharacterIndexLimit);
            var offset = (span.Value.StartIndex + span.Value.Length);

            return(new TextSpan <CultureSpecificCharacterBufferRange>(offset - textSourceCharacterIndexLimit, new CultureSpecificCharacterBufferRange(CultureInfo.CurrentUICulture, new CharacterBufferRange(TextBuffer, offset, offset - textSourceCharacterIndexLimit))));
        }
示例#2
0
        /// <inheritdoc />
        public override TextRun GetTextRun(int textSourceCharacterIndex)
        {
            Debug.WriteLine($"{nameof(GetTextRun)}: {textSourceCharacterIndex}");

            var span = Spans.FirstOrDefault(z => z.Value.StartIndex + z.Value.Length > textSourceCharacterIndex);

            if (span == null)
            {
                return(OnEnd(textSourceCharacterIndex));
            }
            // var textRunProperties = new Modifier(span.Length,p);
            if (OnGenericCharacters(textSourceCharacterIndex, out var customTextCharacters1, span.Value.StartIndex))
            {
                return(customTextCharacters1);
            }

            // var typeface = CurrentRendering.Typeface;
            var v = span.Value;
            // var typeface1 = new Typeface(typeface.FontFamily,v.FontStyle,typeface.Weight, typeface.Stretch);
            // var fontRendering = FontRendering.CreateInstance(CurrentRendering.FontSize, CurrentRendering.TextAlignment, CurrentRendering.TextDecorations, CurrentRendering.TextColor, typeface1);
            var textRunProperties   = v.TextRunProperties ?? BasicProps();
            var paragraphProperties = v.ParagraphProperties;

            if (v.EndOfParagraph)
            {
                return(EndOfParagraph(v));
            }
            if (v.StartParagraph)
            {
                return(new TextModifier1(v.Length, textRunProperties));
            }
            if (v.EmbeddedObject != null)
            {
                return(v.EmbeddedObject);
            }

            var count = span.Length - (textSourceCharacterIndex - v.StartIndex);

            if (count == 0)
            {
            }
            return(new TextCharacters(TextBuffer !, textSourceCharacterIndex,
                                      count, textRunProperties));
        }