thieumao

[WP] Countdown Timer

Apr 23rd, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Threading;
  7. using System.Windows.Controls;
  8. using System.Windows.Navigation;
  9. using Microsoft.Phone.Controls;
  10. using Microsoft.Phone.Shell;
  11. using TimerRun.Resources;
  12.  
  13. namespace TimerRun
  14. {
  15.     public partial class MainPage : PhoneApplicationPage
  16.     {
  17.  
  18.         int time = 10;
  19.         DispatcherTimer dispatch;
  20.  
  21.         public MainPage()
  22.         {
  23.             InitializeComponent();
  24.  
  25.             dispatch = new DispatcherTimer();
  26.         }
  27.  
  28.         private void Grid_Loaded_1(object sender, RoutedEventArgs e)
  29.         {
  30.             if (!dispatch.IsEnabled)
  31.             {
  32.                 dispatch.Tick += dispatch_Tick;
  33.                 dispatch.Interval = new TimeSpan(0,0,1);
  34.                 dispatch.Start();
  35.             }
  36.         }
  37.  
  38.         void dispatch_Tick(object sender, object e)
  39.         {
  40.             time--;
  41.             if (time < 0)
  42.             {
  43.                 time = 10;
  44.             }
  45.             displayZone.Text = "" + time;
  46.         }
  47.  
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment