private void toggle_del_note(string note_id) {
var toggle_note = notes_sorted_by_line_index_.FirstOrDefault(x => x.note_id == note_id);
if (toggle_note == null) {
Debug.Assert(false);
return;
}
dirty_ = true;
string line_id = notes_sorted_by_line_index_.First(x => x.note_id == note_id).line_id;
int same_line_count = notes_sorted_by_line_index_.Count(x => x.line_id == line_id);
// at least the line + a note on that line
Debug.Assert(same_line_count >= 2);
bool is_single = same_line_count <= 2;
if (is_single) {
// in this case - either pressed on the Note itself, or on the header -> should still delete both lines
foreach (var n in notes_sorted_by_line_index_)
if (n.line_id == line_id)
n.deleted = !n.deleted;
}
else {
// in this case, pressed on a line header - toggle all its sub-children
bool deleted = !toggle_note.deleted;
toggle_note.deleted = deleted;
foreach (var n in toggle_note.descendants())
n.deleted = deleted;
}
readd_everything();
}