Example #1
0
        public void CreateLyric(int?nextToOrder = null)
        {
            var maxOrder = OrderUtils.GetMaxOrderNumber(Lyrics.ToArray());
            var order    = nextToOrder ?? maxOrder;

            if (order < 0 && order > maxOrder + 1)
            {
                throw new ArgumentOutOfRangeException(nameof(order));
            }

            changeHandler?.BeginChange();

            // Shifting order that order is larger than current lyric.
            OrderUtils.ShiftingOrder(Lyrics.Where(x => x.Order > order).ToArray(), 1);

            // Add new lyric to target order.
            var createLyric = new Lyric
            {
                Text  = "New lyric",
                Order = order + 1,
            };

            beatmap.Add(createLyric);

            changeHandler?.EndChange();
        }
Example #2
0
        public void CombineWithPreviousLyric(Lyric lyric)
        {
            var previousLyric = Lyrics.GetPrevious(lyric);

            if (previousLyric == null)
            {
                throw new ArgumentNullException(nameof(previousLyric));
            }

            changeHandler?.BeginChange();

            // Shifting order that order is larger than current lyric.
            var lyricOrder = previousLyric.Order;

            OrderUtils.ShiftingOrder(Lyrics.Where(x => x.Order > lyricOrder).ToArray(), -1);

            var newLyric = LyricsUtils.CombineLyric(previousLyric, lyric);

            newLyric.Order = lyricOrder;

            // Add created lyric and remove old two.
            beatmap.Add(newLyric);
            beatmap.Remove(previousLyric);
            beatmap.Remove(lyric);

            changeHandler?.EndChange();
        }
Example #3
0
        public void DeleteLyric(Lyric lyric)
        {
            changeHandler?.BeginChange();

            // Shifting order that order is larger than current lyric.
            OrderUtils.ShiftingOrder(Lyrics.Where(x => x.Order > lyric.Order).ToArray(), -1);
            beatmap.Remove(lyric);

            changeHandler?.EndChange();
        }
Example #4
0
        [TestCase(new[] { 4, 3, 2, 1 }, 1, new[] { 5, 4, 3, 2 })] // Not care order in objects and just doing shifting job.
        public void TestShiftingOrder(int[] orders, int shifting, int[] newOrder)
        {
            var objects = orders?.Select(x => new TestOrderObject {
                Order = x
            }).ToArray();

            OrderUtils.ShiftingOrder(objects, shifting);

            // convert order result.
            var result = objects?.Select(x => x.Order).ToArray();

            Assert.AreEqual(result, newOrder);
        }
Example #5
0
        public bool DeleteLyricText(Lyric lyric, int index)
        {
            if (index <= 0)
            {
                return(false);
            }

            changeHandler?.BeginChange();

            LyricUtils.RemoveText(lyric, index - 1);

            if (string.IsNullOrEmpty(lyric.Text))
            {
                OrderUtils.ShiftingOrder(Lyrics.Where(x => x.Order > lyric.Order).ToArray(), -1);
                beatmap.Remove(lyric);
            }

            changeHandler?.EndChange();

            return(true);
        }
Example #6
0
        public void SplitLyric(Lyric lyric, int index)
        {
            changeHandler?.BeginChange();

            // Shifting order that order is larger than current lyric.
            var lyricOrder = lyric.Order;

            OrderUtils.ShiftingOrder(Lyrics.Where(x => x.Order > lyricOrder).ToArray(), 1);

            // Split lyric
            var(firstLyric, secondLyric) = LyricsUtils.SplitLyric(lyric, index);
            firstLyric.Order             = lyric.Order;
            secondLyric.Order            = lyric.Order + 1;

            // Add those tho lyric and remove old one.
            beatmap.Add(secondLyric);
            beatmap.Add(firstLyric);
            beatmap.Remove(lyric);

            changeHandler?.EndChange();
        }
Example #7
0
 public void DeleteSinger(Singer singer)
 {
     // Shifting order that order is larger than current singer
     OrderUtils.ShiftingOrder(Singers.Where(x => x.Order > singer.Order).ToArray(), -1);
     Singers.Remove(singer);
 }