public override TextCaretPosition MoveDown(TextCaretPosition currentPosition)
        {
            var lyric = Lyrics.GetNextMatch(currentPosition.Lyric, lyricMovable);
            if (lyric == null)
                return null;

            var index = Math.Clamp(currentPosition.Index, GetMinIndex(lyric.Text), GetMaxIndex(lyric.Text));

            return new TextCaretPosition(lyric, index);
        }
        public override TimeTagIndexCaretPosition MoveDown(TimeTagIndexCaretPosition currentPosition)
        {
            var lyric = Lyrics.GetNextMatch(currentPosition.Lyric, l => !string.IsNullOrEmpty(l.Text));

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

            var lyricTextLength = lyric.Text?.Length ?? 0;
            var index           = Math.Clamp(currentPosition.Index.Index, 0, lyricTextLength - 1);
            var state           = currentPosition.Index.State;

            return(new TimeTagIndexCaretPosition(lyric, new TextIndex(index, state)));
        }
        public override TimeTagCaretPosition MoveDown(TimeTagCaretPosition currentPosition)
        {
            var currentTimeTag = currentPosition.TimeTag;

            // need to check is lyric in time-tag is valid.
            var currentLyric = timeTagInLyric(currentTimeTag);

            if (currentLyric != currentPosition.Lyric)
            {
                throw new ArgumentException(nameof(currentPosition.Lyric));
            }

            var downTimeTag = Lyrics.GetNextMatch(currentLyric, l => l.TimeTags?.Any() ?? false)
                              ?.TimeTags?.FirstOrDefault(x => x.Index >= currentTimeTag.Index && timeTagMovable(x));

            return(timeTagToPosition(downTimeTag));
        }
Example #4
0
 private Lyric getNextLyricWithTextTag(Lyric current, ITextTag textTag)
 => Lyrics.GetNextMatch(current, x => getRelatedTypeTextTag(x, textTag)?.Any() ?? false);