public override TimeTagIndexCaretPosition MoveLeft(TimeTagIndexCaretPosition currentPosition)
        {
            // get previous caret and make a check is need to change line.
            var lyric         = currentPosition.Lyric;
            var previousIndex = GetPreviousIndex(currentPosition.Index);

            if (TextIndexUtils.OutOfRange(previousIndex, lyric?.Text))
            {
                return(MoveUp(new TimeTagIndexCaretPosition(currentPosition.Lyric, new TextIndex(int.MaxValue, TextIndex.IndexState.End))));
            }

            return(new TimeTagIndexCaretPosition(currentPosition.Lyric, previousIndex));
        }
        public override TimeTagIndexCaretPosition MoveRight(TimeTagIndexCaretPosition currentPosition)
        {
            // get next caret and make a check is need to change line.
            var lyric     = currentPosition.Lyric;
            var nextIndex = GetNextIndex(currentPosition.Index);

            if (TextIndexUtils.OutOfRange(nextIndex, lyric?.Text))
            {
                return(MoveDown(new TimeTagIndexCaretPosition(currentPosition.Lyric, new TextIndex(int.MinValue))));
            }

            return(new TimeTagIndexCaretPosition(currentPosition.Lyric, nextIndex));
        }
        public override bool PositionMovable(TimeTagIndexCaretPosition position)
        {
            if (position.Lyric == null)
            {
                return(false);
            }

            if (TextIndexUtils.OutOfRange(position.Index, position.Lyric.Text))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        public void TestOutOfRange(int index, TextIndex.IndexState state, string lyric, bool outOfRange)
        {
            var textIndex = new TextIndex(index, state);

            Assert.AreEqual(TextIndexUtils.OutOfRange(textIndex, lyric), outOfRange);
        }