From d80121f779916c2dd8d7451b5df9148296a22630 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Tue, 19 Jan 2016 20:57:20 +0100 Subject: [PATCH] Added loading on startup --- YJMPD-UWP/Model/ApiHandler.cs | 4 +++ YJMPD-UWP/Model/GameHandler.cs | 9 +---- YJMPD-UWP/Model/NetworkHandler.cs | 2 +- YJMPD-UWP/ViewModels/MatchVM.cs | 10 ++++++ YJMPD-UWP/Views/MatchView.xaml | 60 ++++++++++++++++++------------- 5 files changed, 52 insertions(+), 33 deletions(-) diff --git a/YJMPD-UWP/Model/ApiHandler.cs b/YJMPD-UWP/Model/ApiHandler.cs index e5858fd..16632d4 100644 --- a/YJMPD-UWP/Model/ApiHandler.cs +++ b/YJMPD-UWP/Model/ApiHandler.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using YJMPD_UWP.Helpers; +using YJMPD_UWP.Views; namespace YJMPD_UWP.Model { @@ -49,7 +50,10 @@ namespace YJMPD_UWP.Model { Debug.WriteLine("Selected player taking picture"); App.Game.Selected = true; + App.Navigate(typeof(PhotoView)); } + else + App.Navigate(typeof(WaitingView)); break; default: //Do nothing diff --git a/YJMPD-UWP/Model/GameHandler.cs b/YJMPD-UWP/Model/GameHandler.cs index e3abf45..aa04d3a 100644 --- a/YJMPD-UWP/Model/GameHandler.cs +++ b/YJMPD-UWP/Model/GameHandler.cs @@ -97,14 +97,8 @@ namespace YJMPD_UWP.Model private async Task StartGame() { UpdateGameStatus(GameStatus.SEARCHING); + Search(); - - - UpdateGameStatus(GameStatus.WAITING); - - await Task.Delay(TimeSpan.FromSeconds(5)); - - UpdateGameStatus(GameStatus.STARTED); return true; } @@ -112,7 +106,6 @@ namespace YJMPD_UWP.Model private async Task StopGame() { Reset(); - //Do stuff UpdateGameStatus(GameStatus.STOPPED); return true; diff --git a/YJMPD-UWP/Model/NetworkHandler.cs b/YJMPD-UWP/Model/NetworkHandler.cs index 4991444..2b8509b 100644 --- a/YJMPD-UWP/Model/NetworkHandler.cs +++ b/YJMPD-UWP/Model/NetworkHandler.cs @@ -83,7 +83,7 @@ namespace YJMPD_UWP.Model BackgroundReader = Windows.System.Threading.ThreadPool.RunAsync(async (workItem) => { - while (true) + while (workItem.Status != AsyncStatus.Canceled) { Debug.WriteLine("Awaiting incoming data..."); string data = await App.Network.Read(); diff --git a/YJMPD-UWP/ViewModels/MatchVM.cs b/YJMPD-UWP/ViewModels/MatchVM.cs index b532b1e..fc2f31c 100644 --- a/YJMPD-UWP/ViewModels/MatchVM.cs +++ b/YJMPD-UWP/ViewModels/MatchVM.cs @@ -36,6 +36,7 @@ namespace YJMPD_UWP.ViewModels dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { NotifyPropertyChanged(nameof(MatchAvailable)); + NotifyPropertyChanged(nameof(ConnectingServer)); }); } @@ -44,6 +45,7 @@ namespace YJMPD_UWP.ViewModels dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { NotifyPropertyChanged(nameof(MatchAvailable)); + NotifyPropertyChanged(nameof(ConnectingServer)); }); } @@ -72,6 +74,14 @@ namespace YJMPD_UWP.ViewModels } } + public bool ConnectingServer + { + get + { + return !MatchAvailable; + } + } + public bool StartMatch { get diff --git a/YJMPD-UWP/Views/MatchView.xaml b/YJMPD-UWP/Views/MatchView.xaml index 09a0392..de8292b 100644 --- a/YJMPD-UWP/Views/MatchView.xaml +++ b/YJMPD-UWP/Views/MatchView.xaml @@ -11,31 +11,43 @@ - - - - - -