I have only been diving into the C# language for roughly 3 days. I have alot of background with computers but never in a programming language. I am attempting to gain a foothold in C# by playing with it to learn a little about how it works before returning to my books that seem to think I already know a language. But I ran into a snag, I have a picture called bowPic1, I added MouseLeftButtonDown="bowPic1Click", my intention was to take the integer from a text box that I have and add 2 to it, but I dont want it to happen twice if I click twice, I want the click to be limited to one time unless the MouseRightButtonDown="bowPic1Click1" is done.

They way I am trying to accomplish this is below, but I cant come up with an equation that would limit it to 1 click because I cannot obtain the number from the text box and keep it constant for the following code:

private void bowPic1Click(object sender, MouseButtonEventArgs e)
        {
            if (bowPic1.Visibility == Visibility.Visible)
            {
                int cad = int.Parse(cadTextBox.Text);
                int cad1 = cad + 2;
                if (????????????????????)
                    cadTextBox.Text = cad1.ToString();
            }
        }

I know that since I am so fresh to doing this stuff that my question hardly merits a response, but I am grasping this pretty quickly and I do enjoy it alot.

If anyone can either tell me how to take that integer from cadTextBox and keep it contant for the if statement or if there is some other way to accomplish what I am aiming for, please let me know! I very much appreciate the assistance, and look forward to reading the responses.

public int i = 0;

        private void bowPic1Click(object sender, MouseButtonEventArgs e)
        {
            if (bowPic1.Visibility == Visibility.Visible)
            {
                int cad = int.Parse(cadTextBox.Text);
                int cad1 = cad + 2;
                if (i == 0)
                {
                    i = i + 1;
                    cadTextBox.Text = cad1.ToString();
                }
            }
        }
        
        private void bowPic1Click1(object sender, MouseButtonEventArgs e)
        {
            if (bowPic1.Visibility == Visibility.Visible)
            {
                int cad = int.Parse(cadTextBox.Text);
                int cad1 = cad - 2;
                if (i == 1)
                {
                    i = i - 1;
                    cadTextBox.Text = cad1.ToString();
                }
            }
        }

WOO Nevermind all! I solved it =) I know my code is very baby compared to what most of you are doing, but remember, I am on day 3 of programming, and LOVING IT!! That problem up there took me hours to figure out (I may be stupid) but I am soo happy with the result!!! THANKS ALL!!!

Now the only thing left to do is figure out how to apply an image effect on the mouse up click.

This question has already been answered. Start a new discussion instead.