Simen  S M

Simen S M

  • NA
  • 35
  • 32k

Make a countdown & when button is pressed label add score 1, 2 and up

Jan 1 2012 5:01 PM
Hi guys!
I'm pretty new with this WPF, and now I'm trying to make a countdowner. The option is here that you can type min and sec into to several text boxes and they show up as label (? or what should I use for countdown), and when someone press Start it counts down from the minutes and seconds that was typed in. You guys can see a picture of how far I have come:

PICTURE

For now I have those zeros as label, but I want them to count down when time (added time under Game time) is placed and when button Start is pressed.


And I also want when someone press "point team 1" the label will show number 1, 2 and up.

I want mine to look like this flash based program:

PICTURE

I can't get that style on the number either.
So can you guys help me out here?
I have added System.Timer and System.Windows.Threading under "imported namespaces" but I can't find timer or dispatchertimer in the toolbox!
I have also tried something another guy showed me:


<TextBlock x:Name="clockText" TextWrapping="Wrap" Text="0:00" VerticalAlignment="Top" Margin="8,8,0,0" FontSize="32" HorizontalAlignment="Left" Width="340"/> <Button x:Name="startBtn" Content="Start" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Margin="8,54.563,0,0" Click="startClock"/>

private void startClock(object sender, System.Windows.RoutedEventArgs e) { TimeSpan t1 = new TimeSpan(0, 0, 0, 10); TimeSpan t2 = new TimeSpan(0, 0, 0, 1); int counter = 0; DT.Tick += delegate { counter++; t1 = t1 - t2; string a = t1.ToString(); string b = a.Substring(3); this.clockText.Text = b; if (b == "00:00") { DT.Stop(); } }; DT.Interval = new TimeSpan(0, 0, 0, 1); DT.Start(); }

But when I copied that into the code (.vb) I got alot of blue lines under there and 20 errors. See picture:

PICTURE

Hope you guys can help me out here.. I really appreciate it! :)


Attachment: wpfapplication4.rar

Answers (9)