private void TrimScoreNotes(ScoreBar willBeDeleted, bool modifiesModel) { // Reposition after calling this function. var bar = willBeDeleted.Bar; Func <ScoreNote, bool> matchFunc = scoreNote => scoreNote.Note.Bar == bar; var processing = ScoreNotes.Where(matchFunc).ToArray(); foreach (var scoreNote in processing) { RemoveScoreNote(scoreNote, modifiesModel, false); } }
private void RemoveScoreNote(ScoreNote scoreNote, bool modifiesModel, bool repositionLines) { if (!ScoreNotes.Contains(scoreNote)) { throw new ArgumentException("Invalid ScoreNote.", nameof(scoreNote)); } scoreNote.MouseDown -= ScoreNote_MouseDown; scoreNote.MouseUp -= ScoreNote_MouseUp; scoreNote.MouseDoubleClick -= ScoreNote_MouseDoubleClick; scoreNote.MouseEnter -= ScoreNote_MouseEnter; scoreNote.MouseLeave -= ScoreNote_MouseLeave; scoreNote.ContextMenu = null; EditableScoreNotes.Remove(scoreNote); LineLayer.NoteRelations.RemoveAll(scoreNote); if (modifiesModel) { var note = scoreNote.Note; if (Score.Bars.Contains(note.Bar)) { // Remove note from sync group // See Note.RemoveSync() if (note.HasPrevSync && note.HasNextSync) { var prevNote = note.PrevSyncTarget; var nextNote = note.NextSyncTarget; var prevScoreNote = FindScoreNote(prevNote); var nextScoreNote = FindScoreNote(nextNote); LineLayer.NoteRelations.Add(prevScoreNote, nextScoreNote, NoteRelation.Sync); } note.RemoveSync(); // The Reset() call is necessary. note.Reset(); note.Bar.RemoveNote(note); } } NoteLayer.Children.Remove(scoreNote); // TODO: Query if there is a need to do that. if (repositionLines) { RepositionLineLayer(); } if (modifiesModel) { Project.IsChanged = true; } }
public IEnumerable <ScoreNote> GetSelectedScoreNotes() { return(ScoreNotes.Where(scoreNote => scoreNote.IsSelected)); }
public ScoreNote GetSelectedScoreNote() { return(ScoreNotes.FirstOrDefault(scoreNote => scoreNote.IsSelected)); }
public int GetSelectedScoreNoteCount() { return(ScoreNotes.Count(scoreNote => scoreNote.IsSelected)); }