Example #1
0
        //
        //   --- F U N C T I O N A L I T Y ---   //
        //
        private void BlackKey_Click(object sender, EventArgs e)
        {
            if (ModifierKeys != Keys.Alt) //if alt was held dont register note
            {
                BlackPianoKey key = (BlackPianoKey)sender;
                int           noteCode;
                Color         noteColor;
                noteCode = Convert.ToInt32(key.Tag);

                if (key.GetColor() == Color.DimGray)
                {
                    frmMaster.GetAllNotes().Add(noteCode, 1, timer.ElapsedMilliseconds);
                    noteColor = frmMaster.GetAllNotes().GetColor(noteCode);
                    key.SetColor(noteColor);
                    frmMaster.AddNote(this, noteCode);
                }
                else
                {
                    if (frmMaster.chkOverrideNotes.Checked)
                    {
                        frmMaster.GetAllNotes().AddAnother(noteCode, timer.ElapsedMilliseconds);
                    }
                    else
                    {
                        key.SetColor(Color.DimGray);
                        frmMaster.GetAllNotes().Remove(noteCode);
                        frmMaster.RemoveNote(this, noteCode);
                    }
                }
            }
        }
Example #2
0
        private void BlackKey_MouseDown(object sender, MouseEventArgs e)
        {
            BlackPianoKey key = (BlackPianoKey)sender;

            noteValue = Note.ConvertCodeToNotation(Convert.ToInt32(key.Tag));
            MidiPlayer.Play(new ProgramChange(0, 1, GeneralMidiInstruments.AcousticGrand));
            MidiPlayer.Play(new NoteOn(0, 1, noteValue, 127));
            timer.Reset();
            timer.Start();
        }