示例#1
0
        public DeleteScoreWithNoteOperation(
            Model model, Score score, int count)
        {
            Score     prev      = model.ScoreBook.Prev(score);
            ScoreBook scoreList = new ScoreBook();
            Score     itrScore  = score;

            for (int i = 0; i < count && itrScore != null; ++i)
            {
                scoreList.Add(itrScore);
                itrScore = model.ScoreBook.Next(itrScore);
            }
            var notesForDelete = model.NoteBook.GetNotesFromTickRange(
                scoreList.First().StartTick,
                scoreList.Last().EndTick);
            var longNotesForDelete = model.NoteBook.GetLongNotesFromTickRange(
                scoreList.First().StartTick,
                scoreList.Last().EndTick);
            int deleteScoreTickSize =
                scoreList.Last().EndTick - scoreList.First().StartTick + 1;
            List <Operation> operations = new List <Operation>();

            notesForDelete.ForEach(x =>
            {
                operations.Add(new DeleteNoteOperation(
                                   model,
                                   x));
            });
            longNotesForDelete.ForEach(x =>
            {
                operations.Add(new DeleteLongNoteOperation(
                                   model,
                                   x));
            });
            Invoke += () =>
            {
                model.LaneBook.DeleteScore(model.ScoreBook, scoreList.First(), count);
                operations.ForEach(x => x.Invoke());
                model.NoteBook.RelocateNoteTickAfterScoreTick(
                    scoreList.Last().EndTick + 1, -deleteScoreTickSize);
                model.LaneBook.OnUpdateNoteLocation();
            };
            Undo += () =>
            {
                model.LaneBook.InsertScoreForwardWithNote(
                    model.NoteBook,
                    model.ScoreBook,
                    prev,
                    scoreList);
                operations.ForEach(x => x.Undo());
            };
        }
示例#2
0
        public DeleteScoreOperation(
            Model model, Score score, int count)
        {
            Score     prev      = model.ScoreBook.Prev(score);
            ScoreBook scoreList = new ScoreBook();
            Score     itrScore  = score;

            for (int i = 0; i < count; ++i)
            {
                scoreList.Add(itrScore);
                itrScore = model.ScoreBook.Next(itrScore);
            }
            Invoke += () =>
            {
                model.DeleteScore(scoreList.First(), count);
            };
            Undo += () =>
            {
                model.LaneBook.InsertScoreForward(
                    model.ScoreBook,
                    prev,
                    scoreList);
            };
        }