public override TextCaretPosition MoveUp(TextCaretPosition currentPosition)
        {
            var lyric = Lyrics.GetPreviousMatch(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 MoveUp(TimeTagIndexCaretPosition currentPosition)
        {
            var lyric = Lyrics.GetPreviousMatch(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 MoveUp(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 upTimeTag = Lyrics.GetPreviousMatch(currentLyric, l => l.TimeTags?.Any() ?? false)
                            ?.TimeTags.FirstOrDefault(x => x.Index >= currentTimeTag.Index && timeTagMovable(x));

            return(timeTagToPosition(upTimeTag));
        }
Ejemplo n.º 4
0
 private Lyric getPreviousLyricWithTextTag(Lyric current, ITextTag textTag)
 => Lyrics.GetPreviousMatch(current, x => getRelatedTypeTextTag(x, textTag)?.Any() ?? false);