示例#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);
                    }
                }
            }
        }
示例#2
0
        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);
                        }
                    }
                }
            }
        }