Example #1
0
        private void button1_MouseUp(object sender, MouseEventArgs e)
        {
            stopWatch.Stop();
            count = stopWatch.ElapsedMilliseconds;
            foreach (Muskey mk in this.panel1.Controls)
            {
                if (sender == mk)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        //timer1.Stop();
                        //timer1.Enabled = false;
                        string bNoteShape = null;//note this is the name of the file.
                        int    duration   = 0;
                        //work on this and create the noteshape.

                        if (returnTicker(count) <= 1)
                        {
                            bNoteShape = "SemiQuaver";
                            duration   = 1;
                        }
                        else if (returnTicker(count) == 2)
                        {
                            bNoteShape = "Quaver";
                            duration   = 2;
                        }
                        else if (returnTicker(count) >= 3 && returnTicker(count) <= 5)
                        {
                            bNoteShape = "Crotchet";
                            duration   = 4;
                        }
                        else if (returnTicker(count) >= 6 && returnTicker(count) <= 10)
                        {
                            bNoteShape = "Minim";
                            duration   = 10;
                        }
                        else if (returnTicker(count) >= 11 && returnTicker(count) <= 15)
                        {
                            bNoteShape = "DottedMinim";
                            duration   = 14;
                        }
                        else
                        {
                            bNoteShape = "SemiBreve";
                            duration   = 18;
                        }


                        MusicNote mn = new MusicNote(mk.notePitch, duration, bNoteShape);
                        mn.Location = new Point(xLoc, yLoc);
                        MusicNoteObejectsCollection.Add(mn);
                        this.panel2.Controls.Add(mn);
                        xLoc = xLoc + 15;
                    }
                }
            }


            //throw new NotImplementedException();
        }
Example #2
0
 private void button3_Click(object sender, EventArgs e) //Load
 {
     MusicNoteObjectsCollection.Clear();
     this.panel2.Controls.Clear();
     CurrentNotes.Items.Clear();
     iXloc = 40;
     using (OpenFileDialog loadsong = new OpenFileDialog()
     {
         ValidateNames = true, Multiselect = false
     })
     {
         string line = "";
         if (loadsong.ShowDialog() == DialogResult.OK)
         {
             StreamReader sr = new StreamReader(loadsong.FileName);
             while (line != null)
             {
                 line = sr.ReadLine();
                 if (line != null)
                 {
                     string[]  entries = line.Split(',');
                     MusicNote song    = new MusicNote(Int32.Parse(entries[0]), Int32.Parse(entries[1]), entries[2], bool.Parse(entries[3]), bool.Parse(entries[4]));
                     MusicNoteObjectsCollection.Add(song);
                     song.Location = new Point(Int32.Parse(entries[5]), Int32.Parse(entries[6]));
                     this.panel2.Controls.Add(song);
                     AddtoList(Int32.Parse(entries[0]));
                 }
             }
         }
     }
 }
Example #3
0
        private void button1_MouseUp(object sender, MouseEventArgs e)
        {
            stopWatch.Stop();
            count = stopWatch.ElapsedMilliseconds;
            foreach (Muskey mk in this.panel1.Controls)
            {
                if (sender == mk)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        //timer1.Stop();
                        //timer1.Enabled = false;
                        string bNoteShape = null;//note this is the name of the file.
                        int    duration   = 0;
                        //sp.Stop();
                        bool flip    = false;
                        bool isBlack = false;

                        //work on this and create the noteshape.

                        if (returnTicker(count) <= 1)
                        {
                            bNoteShape = "SemiQuaver";
                            duration   = 1;
                        }
                        else if (returnTicker(count) == 2)
                        {
                            bNoteShape = "Quaver";
                            duration   = 2;
                        }
                        else if (returnTicker(count) >= 3 && returnTicker(count) <= 5)
                        {
                            bNoteShape = "Crotchet";
                            duration   = 4;
                        }
                        else if (returnTicker(count) >= 6 && returnTicker(count) <= 10)
                        {
                            bNoteShape = "minim";
                            duration   = 10;
                        }
                        else if (returnTicker(count) >= 11 && returnTicker(count) <= 15)
                        {
                            bNoteShape = "DotMinim";
                            duration   = 14;
                        }
                        else
                        {
                            bNoteShape = "SemiBreve";
                            duration   = 18;
                        }

                        #region Assigning note
                        int z = mk.notePitch;

                        //to check black: 2,4,7,9,11,14,16,19,21,23
                        if (z == 2 || z == 4 || z == 7 || z == 9 || z == 11 || z == 14 || z == 16 || z == 19 || z == 21 || z == 23)
                        {
                            isBlack = true;
                        }


                        //assigning location
                        if (z == 1)
                        {
                            iYloc = 120; flip = false;
                        }
                        if (z == 2)
                        {
                            iYloc = 115; flip = false;
                        }
                        if (z == 3)
                        {
                            iYloc = 110; flip = false;
                        }
                        if (z == 4)
                        {
                            iYloc = 105; flip = false;
                        }
                        if (z == 5)
                        {
                            iYloc = 100; flip = false;
                        }
                        if (z == 6)
                        {
                            iYloc = 95; flip = false;
                        }
                        if (z == 7)
                        {
                            iYloc = 90; flip = false;
                        }
                        if (z == 8)
                        {
                            iYloc = 85; flip = false;
                        }
                        if (z == 9)
                        {
                            iYloc = 80; flip = false;
                        }
                        if (z == 10)
                        {
                            iYloc = 75; flip = false;
                        }
                        if (z == 11)
                        {
                            iYloc = 70; flip = false;
                        }
                        if (z == 12)
                        {
                            iYloc = 65; flip = false;
                        }
                        if (z == 13)
                        {
                            iYloc = 60; flip = true;
                        }
                        if (z == 14)
                        {
                            iYloc = 55; flip = true;
                        }
                        if (z == 15)
                        {
                            iYloc = 50; flip = true;
                        }
                        if (z == 16)
                        {
                            iYloc = 45; flip = true;
                        }
                        if (z == 17)
                        {
                            iYloc = 40; flip = true;
                        }
                        if (z == 18)
                        {
                            iYloc = 35; flip = true;
                        }
                        if (z == 19)
                        {
                            iYloc = 30; flip = true;
                        }
                        if (z == 20)
                        {
                            iYloc = 25; flip = true;
                        }
                        if (z == 21)
                        {
                            iYloc = 20; flip = true;
                        }
                        if (z == 22)
                        {
                            iYloc = 15; flip = true;
                        }
                        if (z == 23)
                        {
                            iYloc = 10; flip = true;
                        }
                        if (z == 24)
                        {
                            iYloc = 5; flip = true;
                        }
                        if (z == 25)
                        {
                            iYloc = 0; flip = true;
                        }
                        #endregion

                        MusicNote mn = new MusicNote(mk.notePitch, duration, bNoteShape, flip, isBlack);
                        MusicNoteObjectsCollection.Add(mn);
                        mn.Location = new Point(iXloc, iYloc);
                        this.panel2.Controls.Add(mn);
                        iXloc += 25;
                    }
                }
            }
            //throw new NotImplementedException();
        }