PhotoVM.cs 929 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Diagnostics;
  3. using Windows.UI.Xaml;
  4. using Windows.UI.Xaml.Media;
  5. using Windows.UI.Xaml.Media.Imaging;
  6. namespace YJMPD_UWP.ViewModels
  7. {
  8. public class PhotoVM : TemplateVM
  9. {
  10. DispatcherTimer timer;
  11. int secondsleft = 60;
  12. public PhotoVM() : base("Photo")
  13. {
  14. timer = new DispatcherTimer();
  15. timer.Interval = TimeSpan.FromSeconds(1);
  16. timer.Tick += Timer_Tick;
  17. timer.Start();
  18. }
  19. private void Timer_Tick(object sender, object e)
  20. {
  21. NotifyPropertyChanged(nameof(TimeOut));
  22. secondsleft--;
  23. if(secondsleft <= 0)
  24. {
  25. App.Game.Stop();
  26. }
  27. }
  28. public string TimeOut
  29. {
  30. get
  31. {
  32. return "Take a photo within " + secondsleft + " seconds";
  33. }
  34. }
  35. }
  36. }