예제 #1
0
        public static Inline GetNextInlineInParagraph(this TextPointer current, LogicalDirection direction)
        {
            Func <Inline, bool> predicate = x =>
            {
                TextPointer elementBoundary   = x.GetBoundary(direction);
                var         relativeDirection = elementBoundary.RelativeTo(current);
                return(relativeDirection == direction || current.IsAt(elementBoundary));
            };

            var inlines = current.Paragraph?.Inlines;

            if (inlines == null)
            {
                return(null);
            }

            var nextInline = direction == LogicalDirection.Forward
                ? inlines.FirstOrDefault(predicate)
                : inlines.LastOrDefault(predicate);

            return(nextInline);
        }