private SpecialNotePointer AddSpecialNote(ScoreBar scoreBar, int row, NoteType type, Note dataTemplate, bool updateBarText)
        {
            if (!Note.IsTypeSpecial(type))
            {
                throw new ArgumentOutOfRangeException(nameof(type));
            }
            var existingNote = scoreBar.Bar.Notes.SingleOrDefault(n => n.Type == type && n.IndexInGrid == row);

            if (existingNote != null)
            {
                if (dataTemplate == null)
                {
                    // Manual editing, not from a ReloadScore() call.
                    return(SpecialScoreNotes.First(sn => sn.Note.Equals(existingNote)));
                }
            }
            var specialNotePointer = new SpecialNotePointer();

            EditableSpecialScoreNotes.Add(specialNotePointer);
            SpecialNoteLayer.Children.Add(specialNotePointer);
            var  bar = scoreBar.Bar;
            Note note;

            if (dataTemplate == null)
            {
                note             = bar.AddNote();
                note.IndexInGrid = row;
                note.SetSpecialType(type);
                note.ExtraParams = new NoteExtraParams {
                    Note = note
                };
            }
            else
            {
                // We assume that this *is* a special note. After all this method is private.
                note = dataTemplate;
            }
            specialNotePointer.Note = note;
            var barHeight = ScoreBars[0].Height;
            var baseY     = -MinimumScrollOffset + bar.Index * barHeight;
            var extraY    = barHeight * row / bar.TotalGridCount;

            specialNotePointer.Y = baseY + extraY;
            Project.IsChanged    = true;
            if (updateBarText)
            {
                UpdateBarTexts();
            }
            return(specialNotePointer);
        }
        private bool RemoveSpecialNote(SpecialNotePointer specialNotePointer, bool updateBarText)
        {
            var exists = SpecialScoreNotes.Contains(specialNotePointer);

            if (!exists)
            {
                return(false);
            }
            var note = specialNotePointer.Note;

            note.Bar.RemoveNote(note);
            SpecialNoteLayer.Children.Remove(specialNotePointer);
            Project.IsChanged = true;
            var b = EditableSpecialScoreNotes.Remove(specialNotePointer);

            if (updateBarText)
            {
                UpdateBarTexts();
            }
            return(b);
        }
 public bool RemoveSpecialNote(SpecialNotePointer specialNotePointer)
 {
     return(RemoveSpecialNote(specialNotePointer, true));
 }