public void ProcessKeyDown(System.Windows.Forms.KeyEventArgs args) { int kc = args.KeyValue; // Does this button matter? If not, never mind. if (!buttons.ContainsKey(kc)) { return; } PianoButton b = buttons[kc]; // Is this key already pressed? Nevermind then. if (b.pressed) { return; } // Light 'em up LightUp(b.octave, b.letter, b.black); // Play sound songPlayer.PlayNote(new Note( Note.GetNoteLetterFromLetter(b.letter), b.octave, b.black, ComponentLength.FULL, 0 )); // Set this button to be pressed b.pressed = true; // Register the key press songProgress.Register(b); }
public void ProcessKeyUp(System.Windows.Forms.KeyEventArgs args) { int kc = args.KeyValue; // Pak de knop. Bestaat ie niet? Laat maar. if (!buttons.ContainsKey(kc)) { return; } PianoButton b = buttons[kc]; // Light 'em.. down LightDown(b.octave, b.letter, b.black); b.pressed = false; // Stop the sound! SoundHelper.StopNote(new Note(Note.GetNoteLetterFromLetter(b.letter), b.octave, b.black, ComponentLength.FULL, 0)); //SoundHelper.Cleanup(); }
public WindowStudentController(WindowLoginController wlc) { this.windowLeerling = new WindowStudent(this); windowLeerling.Show(); this.parent = wlc; songPlayer = new SongPlayer(this, null); songProgress = new SongProgress(songPlayer); scorePopup = new ScorePopup(); buttons = new Dictionary <int, PianoButton>(); // Voeg alle knoppen voor het 4e octaaf toe buttons[81] = new PianoButton(Piano.BASE_OCTAAF, "C"); buttons[50] = new PianoButton(Piano.BASE_OCTAAF, "C#"); buttons[87] = new PianoButton(Piano.BASE_OCTAAF, "D"); buttons[51] = new PianoButton(Piano.BASE_OCTAAF, "D#"); buttons[69] = new PianoButton(Piano.BASE_OCTAAF, "E"); buttons[82] = new PianoButton(Piano.BASE_OCTAAF, "F"); buttons[53] = new PianoButton(Piano.BASE_OCTAAF, "F#"); buttons[84] = new PianoButton(Piano.BASE_OCTAAF, "G"); buttons[54] = new PianoButton(Piano.BASE_OCTAAF, "G#"); buttons[89] = new PianoButton(Piano.BASE_OCTAAF, "A"); buttons[55] = new PianoButton(Piano.BASE_OCTAAF, "A#"); buttons[85] = new PianoButton(Piano.BASE_OCTAAF, "B"); // Voeg alle knoppen voor het 5e octaaf toe buttons[90] = new PianoButton(Piano.BASE_OCTAAF + 1, "C"); buttons[83] = new PianoButton(Piano.BASE_OCTAAF + 1, "C#"); buttons[88] = new PianoButton(Piano.BASE_OCTAAF + 1, "D"); buttons[68] = new PianoButton(Piano.BASE_OCTAAF + 1, "D#"); buttons[67] = new PianoButton(Piano.BASE_OCTAAF + 1, "E"); buttons[86] = new PianoButton(Piano.BASE_OCTAAF + 1, "F"); buttons[71] = new PianoButton(Piano.BASE_OCTAAF + 1, "F#"); buttons[66] = new PianoButton(Piano.BASE_OCTAAF + 1, "G"); buttons[72] = new PianoButton(Piano.BASE_OCTAAF + 1, "G#"); buttons[78] = new PianoButton(Piano.BASE_OCTAAF + 1, "A"); buttons[74] = new PianoButton(Piano.BASE_OCTAAF + 1, "A#"); buttons[77] = new PianoButton(Piano.BASE_OCTAAF + 1, "B"); }