public void SetFretType(int noteNumber) { List <ChartObject> selected = new List <ChartObject>(); List <SongEditCommand> songEditCommands = new List <SongEditCommand>(); foreach (ChartObject chartObject in editor.currentSelectedObjects) { if (chartObject.classID == (int)SongObject.ID.Note && chartObject.song != null) // check null in case note was already deleted when overwritten by changing a note before it { Note note = chartObject as Note; if (note.rawNote != noteNumber) { Note newNote = new Note(note); newNote.rawNote = noteNumber; songEditCommands.Add(new SongEditModifyValidated(note, newNote)); selected.Add(newNote); } } else { selected.Add(chartObject); } } editor.commandStack.Push(new BatchedSongEditCommand(songEditCommands)); List <ChartObject> actuallySelected = new List <ChartObject>(); foreach (ChartObject chartObject in selected) { if (chartObject.classID == (int)SongObject.ID.Note && chartObject.song != null) // check null in case note was already deleted when overwritten by changing a note before it { Note note = chartObject as Note; int insertionIndex = SongObjectHelper.FindObjectPosition(note, editor.currentChart.notes); Debug.Assert(insertionIndex != SongObjectHelper.NOTFOUND, "Song event failed to be inserted?"); actuallySelected.Add(editor.currentChart.notes[insertionIndex]); } else { actuallySelected.Add(chartObject); } } editor.SetCurrentSelectedObjects(actuallySelected); }