The problem is:
By the time you get to the second if statement, you have changed the Text of the button, hence both statements are being run...
Here is a quick test:
if (button1.Text == "Pause")
{
label1.Text = label1.Text + " saw pause ";
button1.Text = "Resume";
}
if (button1.Text == "Resume")
{
label1.Text = label1.Text + " saw resume ";
button1.Text = "Pause";
}
returns: label1 saw pause saw resume.
There are two ways to fix this:
You could insert a 'return;' statement within each if statement:
private void button3_Click(object sender, EventArgs e)
{
if (button3.Text == "Pause")
{
CommandString = "pause mp3file";
mciSendString(CommandString, null, 0, 0);
Status = true;
button3.Text = "Resume";
return;
}
if (button3.Text == "Resume")
{
CommandString = "resume mp3file";
mciSendString(CommandString, null, 0, 0);
button3.Text = "Pause";
return;
}
}
Or secondly, you could capture the value of the button text once:
private void button3_Click(object sender, EventArgs e)
{
String value = button3.Text;
if (value == "Pause")
{
CommandString = "pause mp3file";
mciSendString(CommandString, null, 0, 0);
Status = true;
button3.Text = "Resume";
}
if (value == "Resume")
{
CommandString = "resume mp3file";
mciSendString(CommandString, null, 0, 0);
buton3.Text = "Pause"; // As mentioned before, this is required too.
}
}
Hope that helps.
Steve