private void Guitar_StringMouseDown(object sender, GuitarFret.GuitarEventArgs e) { GuitarFret fret = (GuitarFret)sender; noteValue = Note.ConvertCodeToNotation(fret.GetCode(e.StringNumber)); timer.Reset(); MidiPlayer.Play(new ProgramChange(0, 1, GeneralMidiInstruments.CleanElectricGuitar)); MidiPlayer.Play(new NoteOn(0, 1, noteValue, 127)); timer.Start(); }
private void Guitar_StringMouseUp(object sender, GuitarFret.GuitarEventArgs e) { GuitarFret fret = (GuitarFret)sender; try { MidiPlayer.Play(new NoteOff(0, 1, noteValue, 127)); timer.Stop(); } catch { throw; } }
private void FretClicked(object sender, GuitarFret.GuitarEventArgs e) { if (!e.AltClicked) ////if alt was held dont register note { GuitarFret fret = (GuitarFret)sender; int noteCode; Color noteColor; noteCode = fret.GetCode(e.StringNumber); //--------------------------------------------------------------------------------------------------------- //--------------------Fret Not Clicked Yet----------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------- if (fret.GetColor(e.StringNumber) == Color.Gainsboro) { frmMaster.GetAllNotes().Add(noteCode, e.StringNumber, timer.ElapsedMilliseconds); noteColor = frmMaster.GetAllNotes().GetColor(noteCode); fret.SetColor(noteColor, e.StringNumber); frmMaster.AddNote(this, noteCode); //if shift key was held then dye all other same frets if (e.ShiftClicked) { foreach (Control f in pnlGuitar.Controls) { if (f is GuitarFret) { int stringNumber; for (stringNumber = 1; stringNumber <= 6; stringNumber++) { if (((GuitarFret)f).GetCode(stringNumber) == noteCode) { ((GuitarFret)f).SetColor(noteColor, stringNumber); } } } } } } //------------------------------------------------------------------------------------------------------------------------- //-------------------------Fret Already Clicked---------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------- else { //SHIFT+CLICK = Remove frets with same code if (e.ShiftClicked) { foreach (Control f in pnlGuitar.Controls) { if (f is GuitarFret) { int stringNumber; for (stringNumber = 1; stringNumber <= 6; stringNumber++) { if ((((GuitarFret)f).GetCode(stringNumber) == noteCode) && (stringNumber != e.StringNumber)) { ((GuitarFret)f).SetColor(Color.Transparent, stringNumber); } } } } } //CTRL+CLICK = remove clicked fret (if there are frets with same code) else if (e.CtrlClicked) { bool otherFrets; otherFrets = false; foreach (Control f in pnlGuitar.Controls) { //other frets = no need to continue searching, exit loop if (otherFrets) { break; } //check if there are other frets with same code that are clicked if (f is GuitarFret) { int stringNumber; for (stringNumber = 1; stringNumber <= 6; stringNumber++) { if ((((GuitarFret)f).GetCode(stringNumber) == noteCode) && (stringNumber != e.StringNumber) && (((GuitarFret)f).GetColor(stringNumber) != Color.Transparent)) { otherFrets = true; } } } } if (otherFrets) { fret.SetColor(Color.Gainsboro, e.StringNumber); } } //CLICK = Remove all frets with same code from array and uncolor them //OR if checkbox is true override the note else { if (frmMaster.chkOverrideNotes.Checked) { frmMaster.GetAllNotes().AddAnother(noteCode, timer.ElapsedMilliseconds); noteColor = frmMaster.GetAllNotes().GetColor(noteCode); //if shift key was held then dye all other same frets if (e.ShiftClicked) { foreach (Control f in pnlGuitar.Controls) { if (f is GuitarFret) { int stringNumber; for (stringNumber = 1; stringNumber <= 6; stringNumber++) { if (((GuitarFret)f).GetCode(stringNumber) == noteCode) { ((GuitarFret)f).SetColor(noteColor, stringNumber); } } } } } } else { frmMaster.GetAllNotes().Remove(noteCode); frmMaster.RemoveNote(this, noteCode); foreach (Control f in pnlGuitar.Controls) { if (f is GuitarFret) { int stringNumber; for (stringNumber = 1; stringNumber <= 6; stringNumber++) { if (((GuitarFret)f).GetCode(stringNumber) == noteCode) { ((GuitarFret)f).SetColor(Color.Transparent, stringNumber); } } } } fret.SetColor(Color.Gainsboro, e.StringNumber); } } } } }