private void SaveNoteButton_Click(object sender, EventArgs e) { NoteParseCode code = Note.Parse(FreqBox.Text, DurBox.Text, out Note note); if (code != NoteParseCode.OK) { ShowParseError(code); return; } memory.Save(note); memoryBox.Items.Add($"Frequency {note.frequency}, duration {note.duration}"); }
private void ShowParseError(NoteParseCode code) { if (code == NoteParseCode.NaN) { MessageBox.Show("Enter the number!"); } else if (code == NoteParseCode.InvalidFreq) { MessageBox.Show("Frequency must be more than 37 and less than 32767!"); } else if (code == NoteParseCode.InvalidDuration) { MessageBox.Show("Duration must be more than 0!"); } }
private void AddNoteButton_Click(object sender, EventArgs e) { int index = notesBox.Items.Count; if (insertCheckBox.Checked && notesBox.SelectedIndex != -1) { index = notesBox.SelectedIndex + 1; } NoteParseCode code = Note.Parse(FreqBox.Text, DurBox.Text, out Note note); if (code != NoteParseCode.OK) { ShowParseError(code); return; } player.AddNote(note, index, out bool isPause); AddToList(index, isPause); }