Question

I have objects that a user can click, once clicked there presented with a messagebox, once the messagebox after this would like the object to be removed to.

Is there a simple way of doing this ?

My code

private void redballoon_click(object sender, MouseButtonEventArgs e)
{
    string red_balloon_question = System.Windows.Browser.HtmlPage.Window.Prompt("Question 5X2");

    if (red_balloon_question == "10")
    {
        MessageBox.Show("Well done that is correct, you gain 1 point", "Correct Answer", MessageBoxButton.OK);
        PopBalloonCount++;             
    }
    else
    {
        MessageBox.Show("Incorrect, you loose 1 point", "Wrong Answer", MessageBoxButton.OK);
        PopBalloonCount--;
    }

    score.Content = "Your Score" + " " + Convert.ToString(PopBalloonCount);
    this.lastBalloonClickColor = "red_balloon"; // register the last click
} 

XMAL Code

MouseLeftButtonDown="redballoon_click"

so once the message box is gone I would like the red_balloon to be removed, dose anyone know how to do this?

Was it helpful?

Solution

You shuld try this code:

private void redballoon_click(object sender, MouseButtonEventArgs e)
{
    //react only when baloon is clicked by left mouse button
    if (e.LeftButton != MouseButtonState.Pressed)
        return;

    string red_balloon_question = System.Windows.Browser.HtmlPage.Window.Prompt("Question 5X2");

    if (red_balloon_question == "10")
    {
        MessageBox.Show("Well done that is correct, you gain 1 point", "Correct Answer", MessageBoxButton.OK);
        PopBalloonCount++;             
    }
    else
    {
        MessageBox.Show("Incorrect, you loose 1 point", "Wrong Answer", MessageBoxButton.OK);
        PopBalloonCount--;
    }

    score.Content = "Your Score" + " " + Convert.ToString(PopBalloonCount);
    this.lastBalloonClickColor = "red_balloon"; // register the last click

    //hide baloon
    redballoon.Visibility = Visibility.Hidden;
    //or
    redballoon.Opacity = 0.0;
} 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top