Click here to Skip to main content
15,884,773 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How would I record last mouse click ?
I have a program where I have images called red_balloon and green_balloon.
I give the user points depending if they click the balloons in the right order, red_balloon then green_balloon.
If the order is not correct they loose a point.
So I need a way to record last click, is there a simple way of doing this.

Here is my code so far..

**Code XAML**

HTML
<Image Height="53" HorizontalAlignment="Left" Margin="0,0,0,0" x:Name="red_balloon" Stretch="Fill" VerticalAlignment="Top" Width="48" Source="red.png" MouseLeftButtonDown="redballoon_click" Canvas.Left="194" Canvas.Top="161" RenderTransformOrigin="0.938,0.536" />

<Image Height="53" HorizontalAlignment="Left" Margin="0,0,0,0" x:Name="green_balloon" Stretch="Fill" VerticalAlignment="Top" Width="48" Source="green.png" MouseLeftButtonDown="redballoon_click" Canvas.Left="194" Canvas.Top="161" RenderTransformOrigin="0.938,0.536" />


**Code c#**

C#
private void greenballoon_click(object sender, MouseButtonEventArgs e)
            {
                if (last_click =="red_balloon") // need a way to identify the last click was red_balloon
                 { 
                     PopBalloonCount++;
                 }
                else 
                 { 
                     PopBalloonCount--;
                 }
                score.Content = "Your Score" + " " + Convert.ToString(PopBalloonCount);
            }
Posted

1 solution

You could use hittest to get the appropriate shape.

I did so here:
WPF-Drawing Canvas Control[^]
 
Share this answer
 

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



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