Click here to Skip to main content
15,565,403 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this is my code
// this part of the code will play the sound in the recouces when the picurebox rolls over the new label
      System.Media.SoundPlayer player = new System.Media.SoundPlayer();
      private void BeatDetector_Move(object sender, EventArgs e)
      {
          //timeline timing
          if (timer1.Enabled == true)
          {




          }
          else
          {
              if (secs == 0)
              {
                  mins -= 1;
                  secs = 59;
              }
              else if (secs == 59)
              {
                  mins += 1;
                  secs = 0;
              }


              if (lastLocation.X > BeatDetector.Location.X)
              {
                  secs -= 1;
                  lastLocation.X = BeatDetector.Location.X;
              }
              if (lastLocation.X < BeatDetector.Location.X)
              {
                  secs += 1;
                  lastLocation.X = BeatDetector.Location.X;
              }
              TimeSong.Text = mins + ":" + secs + " / " + Mins.Text + ":" + Secs.Text;





          //making the label beats
          if (BeatDetector.Location.X == Createlabel().Location.X)
              {
                  if (panel1.Contains(Createlabel()))
                  {

                          // this needs to be fixed
                          bool containsLetter = false;
                          string phoneNumber = Createlabel().Text.Trim();

                          for (int i = 0; i < phoneNumber.Length; i++)
                          {
                              if (!char.IsNumber(phoneNumber[i]))
                              {

                                  int anInteger;
                                  anInteger = Convert.ToInt32(Createlabel().Text);
                                  anInteger = int.Parse(Createlabel().Text);

                                  move = anInteger;
                                  containsLetter = true;
                              }
                          }

                          if (containsLetter)
                          {
                              // do whatever you want with the error label


                              if (Createlabel().Text == "KICK2")
                              {
                                  SoundPlayer player = new SoundPlayer(Properties.Resources.KICK2);
                                  player.Play();
                              }

                          }
                  }







              }
          }


      }


and
//adds new label to panel1 to slow/faster the beatdetect movment speed
  private void Form1_KeyDown(object sender, KeyEventArgs e)
  {
           if (e.KeyCode == Keys.ControlKey)
      {
          panel1.Controls.Add(Createlabel());
      }
  }

       public Label Createlabel()
      {
          Label intervillabel = new Label();
          intervillabel.Text = numericUpDown1.Value.ToString();
          intervillabel.Location = new Point(BeatDetector.Location.X, 0);
          intervillabel.AutoSize = true;
          intervillabel.Visible = true;

          return intervillabel;

      }


my problem is that the speed doesn't change when it roles over it, here is this is the speed code

C#
// moves timer1 and timer2 and moves the betadetector
      int move = 1;
      private void timer2_Tick_1(object sender, EventArgs e)
      {
          BeatDetector.Location = new Point(BeatDetector.Location.X + move, BeatDetector.Location.Y);
      }


beatdeteor is a picturebox secs/mins is int, the picuturebox is meant to be moving faster once it hits a picture box with a larger number
Posted
Comments
R. Giskard Reventlov 5-May-12 21:42pm    
So what is your question?
[no name] 5-May-12 21:57pm    
the code don't work can you help me make it so when the beatdtector rolls over the label the speed of the beatdetector will change
[no name] 5-May-12 22:04pm    
What exactly is not working? The first thing is that you are not doing anything if the timer is enabled. Presumably that is what you want to do?
[no name] 6-May-12 2:09am    
the beat detector speed isn't changing
[no name] 6-May-12 11:33am    
As I said, it's not changing because you are not doing anything to change it. Debug your code.

1 solution

Wes Aday has it right...

C#
//timeline timing
if (timer1.Enabled == true)
{

     //This is where you need to execute logic when the timer is enabled


}
else
{
     //This is where you need to execute logic when the timer is not enabled
     //i.e. Reset and Enable Timer maybe...
}
{



maybe this will help...

C#
private void BeatDetector_Move(object sender, EventArgs e)
{
    //timeline timing
    if (timer1.Enabled == true)
    {
        if (secs == 0)
        {
            mins -= 1;
            secs = 59;
        }
        else if (secs == 59)
        {
            mins += 1;
            secs = 0;
        }

        if (lastLocation.X > BeatDetector.Location.X)
        {
            secs -= 1;
            lastLocation.X = BeatDetector.Location.X;
        }
        if (lastLocation.X < BeatDetector.Location.X)
        {
            secs += 1;
            lastLocation.X = BeatDetector.Location.X;
        }
        TimeSong.Text = mins + ":" + secs + " / " + Mins.Text + ":" + Secs.Text;

    //making the label beats
    if (BeatDetector.Location.X == Createlabel().Location.X)
        {
            if (panel1.Contains(Createlabel()))
            {

                    // this needs to be fixed
                    bool containsLetter = false;
                    string phoneNumber = Createlabel().Text.Trim();

                    for (int i = 0; i < phoneNumber.Length; i++)
                    {
                        if (!char.IsNumber(phoneNumber[i]))
                        {

                            int anInteger;
                            anInteger = Convert.ToInt32(Createlabel().Text);
                            anInteger = int.Parse(Createlabel().Text);

                            move = anInteger;
                            containsLetter = true;
                        }
                    }

                    if (containsLetter)
                    {
                        // do whatever you want with the error label


                        if (Createlabel().Text == "KICK2")
                        {
                            SoundPlayer player = new SoundPlayer(Properties.Resources.KICK2);
                            player.Play();
                        }

                    }
            }

        }
    }
    else
    {
         //Reset and enable timer maybe?... what do you want to do if
         //the timer is not enabled?
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900