فهرست منبع

Implement basic functionality and improved design

Kenneth van Ewijk 10 سال پیش
والد
کامیت
260ed9ae78

+ 3 - 0
YJMPD-UWP/App.xaml.cs

@@ -9,6 +9,7 @@ using Windows.UI.ViewManagement;
 using Windows.UI.Xaml;
 using Windows.UI.Xaml.Controls;
 using Windows.UI.Xaml.Navigation;
+using YJMPD_UWP.Helpers;
 
 namespace YJMPD_UWP
 {
@@ -114,11 +115,13 @@ namespace YJMPD_UWP
 
         public static bool Navigate(Type type)
         {
+            App.Geo.TryConnectIfNull();
             return ContentFrame.Navigate(type);
         }
 
         public static bool Navigate(Type type, object param)
         {
+            App.Geo.TryConnectIfNull();
             return ContentFrame.Navigate(type, param);
         }
 

+ 20 - 0
YJMPD-UWP/Helpers/EventArgs/GamePlayersUpdatedEventArgs.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace YJMPD_UWP.Helpers.EventArgs
+{
+    public class GamePlayersUpdatedEventArgs : System.EventArgs
+    {
+        public string Username { get; private set; }
+        public double Points { get; private set; }
+
+        public GamePlayersUpdatedEventArgs(string username, double points)
+        {
+            Username = username;
+            Points = points;
+        }
+    }
+}

+ 36 - 1
YJMPD-UWP/Helpers/Settings.cs

@@ -1,5 +1,8 @@
-using Windows.Foundation.Collections;
+using System;
+using System.Diagnostics;
+using Windows.Foundation.Collections;
 using Windows.Storage;
+using YJMPD_UWP.Model.Object;
 
 namespace YJMPD_UWP.Helpers
 {
@@ -11,6 +14,38 @@ namespace YJMPD_UWP.Helpers
         {
             //Define default settings here
             Values["hostname"] = "imegumii.space";
+
+            if (Values["username"] == null)
+                Values["username"] = "Anon_" + Util.Random(5, Util.RandomType.ALPHANUMERIC);
+
+            if (Values["statistics"] == null)
+                Values["statistics"] = Util.Serialize(new Statistics());
+
+
+            st = Util.Deserialize<Statistics>(Values["statistics"] as string);
+        }
+
+
+        private static Statistics st;
+        public static Statistics Statistics
+        {
+            get
+            {
+                return st;
+            }
+        }
+
+
+        public static string Username
+        {
+            get
+            {
+                return Values["username"] as string;
+            }
+            set
+            {
+                Values["username"] = value;
+            }
         }
     }
 }

+ 47 - 128
YJMPD-UWP/Helpers/Util.cs

@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
@@ -16,8 +17,41 @@ namespace YJMPD_UWP.Helpers
     {
         public enum DialogType { YESNO, OKCANCEL }
 
+        public enum RandomType { ALPHA, NUMERIC, ALPHANUMERIC }
+        private static string AlphaSource = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+        private static string NumericSource = "0123456789";
+
         public static double Now { get { return (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; } }
 
+        public static string Random(int length, RandomType type)
+        {
+            string str = "";
+
+            string source = "";
+            switch(type)
+            {
+                case RandomType.ALPHA:
+                    source = AlphaSource;
+                    break;
+                case RandomType.NUMERIC:
+                    source = NumericSource;
+                    break;
+                default:
+                case RandomType.ALPHANUMERIC:
+                    source = AlphaSource + NumericSource;
+                    break;
+            }
+
+            Random rand = new Random();
+
+            for(int i = 0; i<length; i++)
+            {
+                str += source.ElementAt(rand.Next(0,source.Length-1));
+            }
+
+            return str;
+        }
+
         public static string MillisecondsToTime(double millis)
         {
             DateTime time = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
@@ -25,6 +59,18 @@ namespace YJMPD_UWP.Helpers
             return timestr;
         }
 
+        public static string Serialize<E>(E o)
+        {
+            return JsonConvert.SerializeObject(o);
+        }
+
+        public static E Deserialize<E>(string s)
+        {
+            return JsonConvert.DeserializeObject<E>(s);
+        }
+
+        //GPS
+
         public static async Task<Geopoint> FindLocation(string location, Geopoint reference)
         {
             MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync(location, reference);
@@ -85,56 +131,6 @@ namespace YJMPD_UWP.Helpers
             return address;
         }
 
-        public static MapPolyline GetRouteLine(MapRoute m, Color color, int zindex, int thickness = 5)
-        {
-            var line = new MapPolyline
-            {
-                StrokeThickness = thickness,
-                StrokeColor = color,
-                StrokeDashed = false,
-                ZIndex = zindex
-            };
-
-            if (m != null)
-                line.Path = new Geopath(m.Path.Positions);
-
-            return line;
-        }
-
-        public static MapPolyline GetRouteLine(List<BasicGeoposition> positions, Color color, int zindex, int thickness = 5)
-        {
-            var line = new MapPolyline
-            {
-                StrokeThickness = thickness,
-                StrokeColor = color,
-                StrokeDashed = false,
-                ZIndex = zindex
-            };
-
-            line.Path = new Geopath(positions);
-
-            return line;
-        }
-
-        public static MapPolyline GetRouteLine(BasicGeoposition p1, BasicGeoposition p2, Color color, int zindex, int thickness = 5)
-        {
-            var line = new MapPolyline
-            {
-                StrokeThickness = thickness,
-                StrokeColor = color,
-                StrokeDashed = false,
-                ZIndex = zindex
-            };
-
-            List<BasicGeoposition> plist = new List<BasicGeoposition>();
-            plist.Add(p1);
-            plist.Add(p2);
-
-            line.Path = new Geopath(plist);
-
-            return line;
-        }
-
         public static void ShowToastNotification(string title, string text)
         {
             ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
@@ -179,82 +175,5 @@ namespace YJMPD_UWP.Helpers
             else
                 return false;
         }
-
-        public static string TranslatedManeuver(MapRouteManeuver maneuver, int distance)
-        {
-            string response = "";
-            bool onstreet = false;
-            bool meters = true;
-
-            distance = (int)Math.Round(distance / 5.0) * 5;
-
-            switch (maneuver.Kind)
-            {
-                default:
-                    response = "RouteSeeMap";
-                    meters = false;
-                    break;
-                case MapRouteManeuverKind.End:
-                    response = "RouteEnd";
-                    break;
-                case MapRouteManeuverKind.GoStraight:
-                    response = "RouteGoStraight";
-                    onstreet = true;
-                    break;
-                case MapRouteManeuverKind.None:
-                    response = "RouteNone";
-                    meters = false;
-                    break;
-                case MapRouteManeuverKind.Start:
-                    response = "RouteStart";
-                    meters = false;
-                    break;
-                case MapRouteManeuverKind.TurnHardLeft:
-                case MapRouteManeuverKind.TurnLeft:
-                    response = "RouteLeft";
-                    onstreet = true;
-                    break;
-                case MapRouteManeuverKind.TurnHardRight:
-                case MapRouteManeuverKind.TurnRight:
-                    response = "RouteRight";
-                    onstreet = true;
-                    break;
-                case MapRouteManeuverKind.TrafficCircleLeft:
-                    response = "RouteTrafficCircleLeft";
-                    onstreet = true;
-                    break;
-                case MapRouteManeuverKind.TrafficCircleRight:
-                    response = "RouteTrafficCircleRight";
-                    onstreet = true;
-                    break;
-                case MapRouteManeuverKind.TurnKeepLeft:
-                case MapRouteManeuverKind.TurnLightLeft:
-                    response = "RouteKeepLeft";
-                    break;
-                case MapRouteManeuverKind.TurnKeepRight:
-                case MapRouteManeuverKind.TurnLightRight:
-                    response = "RouteKeepRight";
-                    break;
-                case MapRouteManeuverKind.UTurnLeft:
-                case MapRouteManeuverKind.UTurnRight:
-                    response = "RouteUTurn";
-                    break;
-            }
-
-            if (maneuver.StreetName == "")
-                onstreet = false;
-
-            if (distance < 10)
-                meters = false;
-
-
-            if (onstreet)
-                response += " " + "RouteOn" + " " + maneuver.StreetName;
-
-            if (meters)
-                response = "RouteIn" + " " + distance + "m" + " " + response.ToLower();
-
-            return response;
-        }
     }
 }

+ 9 - 15
YJMPD-UWP/MainPage.xaml

@@ -33,7 +33,7 @@
         <Style x:Key="GameInfoPanel" TargetType="StackPanel">
             <Setter Property="Orientation" Value="Horizontal" />
             <Setter Property="VerticalAlignment" Value="Center" />
-            <Setter Property="Margin" Value="10,0,10,0" />
+            <Setter Property="Margin" Value="10,5,10,0" />
         </Style>
 
         <Style x:Key="GameInfoIcon" TargetType="TextBlock">
@@ -70,17 +70,11 @@
 
                     <Viewbox Stretch="Uniform" StretchDirection="DownOnly" HorizontalAlignment="Stretch" RelativePanel.AlignTopWithPanel="True">
                         <ListBox SelectionMode="Single" Name="NavList" SelectionChanged="NavList_SelectionChanged" Tapped="NavList_Tapped">
-                            
+
                             <ListBoxItem Name="NavListHome" ManipulationMode="TranslateX" ManipulationCompleted="Pane_ManipulationCompleted">
                                 <StackPanel Style="{StaticResource NavStackPanel}">
                                     <TextBlock Style="{StaticResource NavIcon}" Text="&#xE80F;"/>
-                                    <TextBlock Style="{StaticResource NavText}" Text="Home"/>
-                                </StackPanel>
-                            </ListBoxItem>
-                            <ListBoxItem Name="NavListAccount" ManipulationMode="TranslateX" ManipulationCompleted="Pane_ManipulationCompleted">
-                                <StackPanel Style="{StaticResource NavStackPanel}">
-                                    <TextBlock Style="{StaticResource NavIcon}" Text="&#xE8B8;"/>
-                                    <TextBlock Style="{StaticResource NavText}" Text="Account"/>
+                                    <TextBlock Style="{StaticResource NavText}" Text="Match"/>
                                 </StackPanel>
                             </ListBoxItem>
                             <ListBoxItem Name="NavListStatistics" ManipulationMode="TranslateX" ManipulationCompleted="Pane_ManipulationCompleted">
@@ -105,11 +99,11 @@
                         </ListBox>
                     </Viewbox>
                     
-                    <StackPanel RelativePanel.AlignBottomWithPanel="True" RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignRightWithPanel="True" Background="Transparent">
+                    <StackPanel RelativePanel.AlignBottomWithPanel="True" RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignRightWithPanel="True" Background="Gray">
                         
-                        <StackPanel Visibility="{Binding GameVisible, Converter={StaticResource BoolToVisConverter}}">
+                        <StackPanel Visibility="{Binding GameVisible, Converter={StaticResource BoolToVisConverter}}" HorizontalAlignment="Stretch">
                             <StackPanel Style="{StaticResource GameInfoPanel}">
-                                <TextBlock Margin="5,0,0,0" FontSize="16" FontWeight="Bold" Text="Currently game"/>
+                                <TextBlock Margin="5,0,0,0" FontSize="16" FontWeight="Bold" Text="Current game"/>
                             </StackPanel>
 
                             <StackPanel Style="{StaticResource GameInfoPanel}">
@@ -119,11 +113,11 @@
 
                             <StackPanel Style="{StaticResource GameInfoPanel}">
                                 <TextBlock Style="{StaticResource GameInfoIcon}" Text="&#xE716;"/>
-                                <TextBlock Style="{StaticResource GameInfoText}" Text="{Binding People}"/>
+                                <TextBlock Style="{StaticResource GameInfoText}" Text="{Binding Players}"/>
                             </StackPanel>
 
-                            <StackPanel Style="{StaticResource GameInfoPanel}">
-                                <Button Content="Back to Game" Background="DarkGreen" Foreground="White" Tapped="BackToGame_Tapped" HorizontalAlignment="Stretch"/>
+                            <StackPanel Style="{StaticResource GameInfoPanel}" HorizontalAlignment="Stretch">
+                                <Button Content="Back to Game" Tapped="BackToGame_Tapped" Style="{StaticResource Green}"/>
                             </StackPanel>
                         </StackPanel>
                         

+ 3 - 10
YJMPD-UWP/MainPage.xaml.cs

@@ -96,18 +96,14 @@ namespace YJMPD_UWP
                 case "matchview":
                     NavList.SelectedIndex = 0;
                     break;
-                case "accountview":
-                    NavList.SelectedIndex = 1;
-                    break;
                 case "statisticsview":
-                    NavList.SelectedIndex = 2;
+                    NavList.SelectedIndex = 1;
                     break;
                 case "aboutview":
-                    NavList.SelectedIndex = 3;
+                    NavList.SelectedIndex = 2;
                     break;
                 case "settingsview":
-                    Debug.WriteLine("Yes " + pagename);
-                    NavList.SelectedIndex = 4;
+                    NavList.SelectedIndex = 3;
                     break;
                 default:
                     PageTitle.Text = "YJMPD-UWP";
@@ -127,9 +123,6 @@ namespace YJMPD_UWP
             if (NavListHome.IsSelected)
                 Frame.Navigate(typeof(MatchView));
             else
-            if (NavListAccount.IsSelected)
-                Frame.Navigate(typeof(AccountView));
-            else
             if (NavListStatistics.IsSelected)
                 Frame.Navigate(typeof(StatisticsView));
             else

+ 3 - 3
YJMPD-UWP/Model/CompassHandler.cs

@@ -11,7 +11,7 @@ namespace YJMPD_UWP.Model
         public event OnHeadingUpdateHandler OnHeadingUpdate;
 
         public delegate void OnHeadingUpdateSlowHandler(object sender, HeadingUpdatedEventArgs e);
-        public event OnHeadingUpdateSlowHandler OnSlowHeadingUpdated;
+        public event OnHeadingUpdateSlowHandler OnSlowHeadingUpdate;
 
         private Compass comp;
 
@@ -63,9 +63,9 @@ namespace YJMPD_UWP.Model
                 lastreadingtime = Util.Now;
 
                 //Make sure someone is listening
-                if (OnSlowHeadingUpdated == null) return;
+                if (OnSlowHeadingUpdate == null) return;
 
-                OnSlowHeadingUpdated(this, new HeadingUpdatedEventArgs(r));
+                OnSlowHeadingUpdate(this, new HeadingUpdatedEventArgs(r));
             }
         }
     }

+ 26 - 14
YJMPD-UWP/Model/GameHandler.cs

@@ -1,4 +1,5 @@
-using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Threading.Tasks;
 using YJMPD_UWP.Helpers.EventArgs;
 
 namespace YJMPD_UWP.Model
@@ -8,9 +9,14 @@ namespace YJMPD_UWP.Model
         public delegate void OnStatusUpdateHandler(object sender, GameStatusUpdatedEventArgs e);
         public event OnStatusUpdateHandler OnStatusUpdate;
 
-        public enum GameStatus { STOPPING, STOPPED, SEARCHING, WAITING, ENDED, STARTING, STARTED }
+        public delegate void OnPlayersUpdateHandler(object sender, GamePlayersUpdatedEventArgs e);
+        public event OnPlayersUpdateHandler OnPlayersUpdate;
+
+        public enum GameStatus { STARTED, SEARCHING, WAITING, ENDED, STOPPED }
         public GameStatus Status { get; private set; }
 
+        public Dictionary<string, double> Players { get; private set; }
+
         private void UpdateGameStatus(GameStatus status)
         {
             Status = status;
@@ -19,13 +25,29 @@ namespace YJMPD_UWP.Model
 
             OnStatusUpdate(this, new GameStatusUpdatedEventArgs(status));
         }
+        private void UpdateGamePlayers(string username, double points)
+        {
+            if (OnPlayersUpdate == null) return;
+
+            OnPlayersUpdate(this, new GamePlayersUpdatedEventArgs(username, points));
+        }
 
         public GameHandler()
         {
+            Players = new Dictionary<string, double>();
             Status = GameStatus.STOPPED;
         }
 
-
+        public void AddPlayer(string username, double points)
+        {
+            Players.Add(username, points);
+            UpdateGamePlayers(username, points);
+        }
+        public void UpdatePlayer(string username, double points)
+        {
+            Players.Remove(username);
+            AddPlayer(username, points);
+        }
 
 
         //Searching
@@ -39,16 +61,8 @@ namespace YJMPD_UWP.Model
         {
             UpdateGameStatus(GameStatus.SEARCHING);
 
-            bool foundgame;
-
-            foundgame = await App.Network.SearchGame();
-
-            //Do stuff
+            await App.Network.SearchGame();
 
-            if (foundgame)
-                await Start();
-            else
-                await Stop();
             return true;
         }
 
@@ -66,7 +80,6 @@ namespace YJMPD_UWP.Model
 
         private async Task<bool> StartGame()
         {
-            UpdateGameStatus(GameStatus.STARTING);
 
             //Do stuff
 
@@ -76,7 +89,6 @@ namespace YJMPD_UWP.Model
 
         private async Task<bool> StopGame()
         {
-            UpdateGameStatus(GameStatus.STOPPING);
 
             //Do stuff
 

+ 6 - 3
YJMPD-UWP/Model/NetworkHandler.cs

@@ -11,7 +11,7 @@ namespace YJMPD_UWP.Model
     public class NetworkHandler
     {
         public delegate void OnStatusUpdatedHandler(object sender, NetworkStatusUpdatedEventArgs e);
-        public OnStatusUpdatedHandler OnStatusUpdated;
+        public event OnStatusUpdatedHandler OnStatusUpdate;
 
         public enum NetworkStatus { DISCONNECTED, CONNECTING, CONNECTED }
         public NetworkStatus Status { get; private set; }
@@ -24,9 +24,9 @@ namespace YJMPD_UWP.Model
         {
             Status = status;
 
-            if (OnStatusUpdated == null) return;
+            if (OnStatusUpdate == null) return;
 
-            OnStatusUpdated(this, new NetworkStatusUpdatedEventArgs(status));
+            OnStatusUpdate(this, new NetworkStatusUpdatedEventArgs(status));
         }
 
         public NetworkHandler()
@@ -90,6 +90,9 @@ namespace YJMPD_UWP.Model
         {
             UpdateNetworkStatus(NetworkStatus.CONNECTING);
 
+            UpdateNetworkStatus(NetworkStatus.CONNECTED);
+            return false;
+
             client = new StreamSocket();
 
             StreamSocketControl controller = client.Control;

+ 31 - 0
YJMPD-UWP/Model/Object/Statistics.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace YJMPD_UWP.Model.Object
+{
+    public class Statistics
+    {
+        
+        public Statistics()
+        {
+            Points = new List<double>();
+            Distance = 0;
+            Matches = 0;
+            Leader = 0;
+        }
+
+        public List<double> Points { get; set; }
+        public double Distance { get; set; }
+        public int Matches { get; set; }
+        public int Leader { get; set; }
+
+        public void AddPoints(double points)
+        {
+            Points.Add(points);
+        }
+
+    }
+}

+ 13 - 0
YJMPD-UWP/Model/PhotoHandler.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace YJMPD_UWP.Model
+{
+    public class PhotoHandler
+    {
+
+    }
+}

+ 23 - 7
YJMPD-UWP/Themes/DefaultStyles.xaml

@@ -3,13 +3,12 @@
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:local="using:YJMPD_UWP.Themes">
 
-    <Style TargetType="SymbolIcon" x:Key="InfoIcon">
-        <Setter Property="Foreground" Value="Gray" />
+    <Style TargetType="TextBlock">
+        <Setter Property="FontSize" Value="14" />
     </Style>
-    <Style TargetType="TextBlock" x:Key="InfoText">
-        <Setter Property="Foreground" Value="Gray" />
-        <Setter Property="FontSize" Value="16" />
-        <Setter Property="Margin" Value="5,0,0,0" />
+
+    <Style TargetType="StackPanel" x:Key="Base">
+        <Setter Property="Margin" Value="10" />
     </Style>
 
     <Style TargetType="TextBlock" x:Key="Header">
@@ -17,5 +16,22 @@
         <Setter Property="FontWeight" Value="Bold" />
         <Setter Property="Margin" Value="0,0,0,3" />
     </Style>
-    
+
+    <Style TargetType="TextBlock" x:Key="Subtext">
+        <Setter Property="Foreground" Value="Gray" />
+        <Setter Property="FontSize" Value="14" />
+    </Style>
+
+    <Style TargetType="Button" x:Key="Green">
+        <Setter Property="Background" Value="DarkGreen" />
+        <Setter Property="Foreground" Value="White" />
+        <Setter Property="HorizontalAlignment" Value="Stretch" />
+    </Style>
+
+    <Style TargetType="Button" x:Key="Red">
+        <Setter Property="Background" Value="DarkRed" />
+        <Setter Property="Foreground" Value="White" />
+        <Setter Property="HorizontalAlignment" Value="Stretch" />
+    </Style>
+
 </ResourceDictionary>

+ 0 - 10
YJMPD-UWP/ViewModels/AccountVM.cs

@@ -1,10 +0,0 @@
-namespace YJMPD_UWP.ViewModels
-{
-    public class AccountVM : TemplateVM
-    {
-        public AccountVM() : base("Account")
-        {
-
-        }
-    }
-}

+ 23 - 5
YJMPD-UWP/ViewModels/MainPageVM.cs

@@ -6,22 +6,40 @@ namespace YJMPD_UWP.ViewModels
     {
         public MainPageVM() : base("Loading")
         {
-            
+            App.Game.OnStatusUpdate += Game_OnStatusUpdate;
+            App.Game.OnPlayersUpdate += Game_OnPlayersUpdate;
+        }
+
+        private void Game_OnPlayersUpdate(object sender, Helpers.EventArgs.GamePlayersUpdatedEventArgs e)
+        {
+            dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
+            {
+                NotifyPropertyChanged(nameof(Players));
+            });
+        }
+
+        private void Game_OnStatusUpdate(object sender, Helpers.EventArgs.GameStatusUpdatedEventArgs e)
+        {
+            dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
+            {
+                NotifyPropertyChanged(nameof(GameState));
+                NotifyPropertyChanged(nameof(GameVisible));
+            });
         }
 
         public string GameState
         {
             get
             {
-                return "N/A";
+                return App.Game.Status.ToString();
             }
         }
 
-        public string People
+        public string Players
         {
             get
             {
-                return "0/0";
+                return App.Game.Players.Count + " players";
             }
         }
 
@@ -29,7 +47,7 @@ namespace YJMPD_UWP.ViewModels
         {
             get
             {
-                return true;
+                return App.Game.Status != Model.GameHandler.GameStatus.STOPPED;
             }
         }
 

+ 52 - 0
YJMPD-UWP/ViewModels/MatchVM.cs

@@ -4,7 +4,59 @@
     {
         public MatchVM() : base("Match")
         {
+            App.Geo.OnStatusUpdate += Geo_OnStatusUpdate;
+            App.Network.OnStatusUpdate += Network_OnStatusUpdate;
+            App.Game.OnStatusUpdate += Game_OnStatusUpdate;
+        }
 
+        private void Game_OnStatusUpdate(object sender, Helpers.EventArgs.GameStatusUpdatedEventArgs e)
+        {
+            dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
+            {
+                NotifyPropertyChanged(nameof(StartMatch));
+                NotifyPropertyChanged(nameof(StopMatch));
+            });
+        }
+
+        private void Network_OnStatusUpdate(object sender, Helpers.EventArgs.NetworkStatusUpdatedEventArgs e)
+        {
+            dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
+            {
+                NotifyPropertyChanged(nameof(MatchAvailable));
+            });
+        }
+
+        private void Geo_OnStatusUpdate(object sender, Helpers.EventArgs.PositionStatusUpdatedEventArgs e)
+        {
+            dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
+            {
+                NotifyPropertyChanged(nameof(MatchAvailable));
+            });
+        }
+        
+
+        public bool MatchAvailable
+        {
+            get
+            {
+                return App.Geo.Status == Windows.Devices.Geolocation.PositionStatus.Ready && App.Network.Status == Model.NetworkHandler.NetworkStatus.CONNECTED;
+            }
+        }
+
+        public bool StartMatch
+        {
+            get
+            {
+                return App.Game.Status == Model.GameHandler.GameStatus.STOPPED;
+            }
+        }
+
+        public bool StopMatch
+        {
+            get
+            {
+                return !StartMatch;
+            }
         }
     }
 }

+ 15 - 1
YJMPD-UWP/ViewModels/SettingsVM.cs

@@ -1,4 +1,6 @@
-namespace YJMPD_UWP.ViewModels
+using YJMPD_UWP.Helpers;
+
+namespace YJMPD_UWP.ViewModels
 {
     public class SettingsVM : TemplateVM
     {
@@ -6,5 +8,17 @@
         {
 
         }
+
+        public string Username
+        {
+            get
+            {
+                return Settings.Username;
+            }
+            set
+            {
+                Settings.Username = value;
+            }
+        }
     }
 }

+ 80 - 1
YJMPD-UWP/ViewModels/StatisticsVM.cs

@@ -1,10 +1,89 @@
-namespace YJMPD_UWP.ViewModels
+using System.Linq;
+using YJMPD_UWP.Helpers;
+using YJMPD_UWP.Model.Object;
+
+namespace YJMPD_UWP.ViewModels
 {
     public class StatisticsVM : TemplateVM
     {
+        Statistics st;
+
         public StatisticsVM() : base("Statistics")
         {
+            st = Settings.Statistics;
+        }
 
+        public string Information
+        {
+            get
+            {
+                return "This page holds all the statistics for " + Settings.Username;
+            }
+        }
+
+        public string Distance
+        {
+            get
+            {
+                return st.Distance + "km";
+            }
+        }
+
+        public string LeaderCount
+        {
+            get
+            {
+                return st.Leader + "";
+            }
+        }
+
+        public string MatchesCount
+        {
+            get
+            {
+                return st.Matches + "";
+            }
+        }
+
+        public string PointsTotal
+        {
+            get
+            {
+                return st.Points.Sum() + "";
+            }
+        }
+
+        public string PointsAverage
+        {
+            get
+            {
+                if (st.Points.Count < 1)
+                    return "0";
+                else
+                    return (st.Points.Sum() / st.Matches) + "";
+            }
+        }
+
+        public string PointsMax
+        {
+            get
+            {
+                if (st.Points.Count < 1)
+                    return "0";
+                else
+                    return st.Points.Max() + "";
+            }
+        }
+
+        public string PointsMin
+        {
+            get
+            {
+                if (st.Points.Count < 1)
+                    return "0";
+                else
+                    return st.Points.Min() + "";
+            }
         }
     }
 }

+ 5 - 3
YJMPD-UWP/Views/AboutView.xaml

@@ -7,7 +7,9 @@
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     mc:Ignorable="d">
 
-    <Grid>
-        
-    </Grid>
+    <ScrollViewer>
+        <StackPanel Style="{StaticResource Base}" >
+
+        </StackPanel>
+    </ScrollViewer>
 </Page>

+ 0 - 13
YJMPD-UWP/Views/AccountView.xaml

@@ -1,13 +0,0 @@
-<Page
-    x:Class="YJMPD_UWP.Views.AccountView"
-    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-    xmlns:local="using:YJMPD_UWP.Views"
-    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-    mc:Ignorable="d">
-
-    <Grid>
-
-    </Grid>
-</Page>

+ 0 - 17
YJMPD-UWP/Views/AccountView.xaml.cs

@@ -1,17 +0,0 @@
-using Windows.UI.Xaml.Controls;
-using YJMPD_UWP.ViewModels;
-
-namespace YJMPD_UWP.Views
-{
-    public sealed partial class AccountView : Page
-    {
-        AccountVM accountvm;
-
-        public AccountView()
-        {
-            accountvm = new AccountVM();
-            this.DataContext = accountvm;
-            this.InitializeComponent();
-        }
-    }
-}

+ 14 - 3
YJMPD-UWP/Views/MatchView.xaml

@@ -3,11 +3,22 @@
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:local="using:YJMPD_UWP.Views"
+    xmlns:convert="using:YJMPD_UWP.Helpers.Converter"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     mc:Ignorable="d">
 
-    <Grid>
-
-    </Grid>
+    <Page.Resources>
+        <convert:BoolToVisibilityConverter x:Key="BoolToVisConverter" />
+    </Page.Resources>
+    
+    <ScrollViewer>
+        <StackPanel Style="{StaticResource Base}" >
+            <StackPanel>
+                <TextBlock Text="Start a match" Style="{StaticResource Header}" />
+                <Button Content="Start" Style="{StaticResource Green}" Tapped="StartMatchButton_Tapped" IsEnabled="{Binding MatchAvailable}" Visibility="{Binding StartMatch, Converter={StaticResource BoolToVisConverter}}" />
+                <Button Content="Stop" Style="{StaticResource Red}" Tapped="StopMatchButton_Tapped" Visibility="{Binding StopMatch, Converter={StaticResource BoolToVisConverter}}" />
+            </StackPanel>
+        </StackPanel>
+    </ScrollViewer>
 </Page>

+ 10 - 0
YJMPD-UWP/Views/MatchView.xaml.cs

@@ -13,5 +13,15 @@ namespace YJMPD_UWP.Views
             this.DataContext = matchvm;
             this.InitializeComponent();
         }
+
+        private void StartMatchButton_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
+        {
+            App.Game.Start();
+        }
+
+        private void StopMatchButton_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
+        {
+            App.Game.Stop();
+        }
     }
 }

+ 8 - 3
YJMPD-UWP/Views/SettingsView.xaml

@@ -7,7 +7,12 @@
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     mc:Ignorable="d">
 
-    <Grid>
-        
-    </Grid>
+    <ScrollViewer>
+        <StackPanel Style="{StaticResource Base}" >
+            <StackPanel>
+                <TextBlock Text="Username" Style="{StaticResource Header}" />
+                <TextBox Text="{Binding Username, Mode=TwoWay}" />
+            </StackPanel>
+        </StackPanel>
+    </ScrollViewer>
 </Page>

+ 44 - 2
YJMPD-UWP/Views/StatisticsView.xaml

@@ -7,7 +7,49 @@
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     mc:Ignorable="d">
 
-    <Grid>
+    <ScrollViewer>
+        <StackPanel Style="{StaticResource Base}" >
 
-    </Grid>
+            <StackPanel Margin="0,10,0,0">
+                <TextBlock Text="{Binding Information}" Style="{StaticResource Subtext}" />
+            </StackPanel>
+
+            <StackPanel Margin="0,10,0,0">
+                <TextBlock Text="Total Distance Walked" Style="{StaticResource Header}" />
+                <TextBlock Text="{Binding Distance}" />
+            </StackPanel>
+
+            <StackPanel Margin="0,10,0,0">
+                <TextBlock Text="Total Matches" Style="{StaticResource Header}" />
+                <TextBlock Text="{Binding MatchesCount}" />
+            </StackPanel>
+
+            <StackPanel Margin="0,10,0,0">
+                <TextBlock Text="Times Leader" Style="{StaticResource Header}" />
+                <TextBlock Text="{Binding LeaderCount}" />
+            </StackPanel>
+
+            <StackPanel Margin="0,10,0,0">
+                <TextBlock Text="Points" Style="{StaticResource Header}" />
+                <RelativePanel>
+                    <TextBlock Text="Total:" Style="{StaticResource Subtext}" RelativePanel.AlignLeftWithPanel="True"/>
+                    <TextBlock Text="{Binding PointsTotal}" RelativePanel.AlignRightWithPanel="True"/>
+                </RelativePanel>
+                <RelativePanel>
+                    <TextBlock Text="Avg:" Style="{StaticResource Subtext}" RelativePanel.AlignLeftWithPanel="True"/>
+                    <TextBlock Text="{Binding PointsAverage}" RelativePanel.AlignRightWithPanel="True"/>
+                </RelativePanel>
+                <RelativePanel>
+                    <TextBlock Text="Max:" Style="{StaticResource Subtext}" RelativePanel.AlignLeftWithPanel="True"/>
+                    <TextBlock Text="{Binding PointsMax}" RelativePanel.AlignRightWithPanel="True"/>
+                </RelativePanel>
+                <RelativePanel>
+                    <TextBlock Text="Min:" Style="{StaticResource Subtext}" RelativePanel.AlignLeftWithPanel="True"/>
+                    <TextBlock Text="{Binding PointsMin}" RelativePanel.AlignRightWithPanel="True"/>
+                </RelativePanel>
+                
+            </StackPanel>
+
+        </StackPanel>
+    </ScrollViewer>
 </Page>

+ 4 - 9
YJMPD-UWP/YJMPD-UWP.csproj

@@ -45,7 +45,7 @@
     <DebugSymbols>true</DebugSymbols>
     <OutputPath>bin\ARM\Debug\</OutputPath>
     <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
-    <NoWarn>;2008</NoWarn>
+    <NoWarn>;2008;4014</NoWarn>
     <DebugType>full</DebugType>
     <PlatformTarget>ARM</PlatformTarget>
     <UseVSHostingProcess>false</UseVSHostingProcess>
@@ -96,6 +96,7 @@
       <DependentUpon>App.xaml</DependentUpon>
     </Compile>
     <Compile Include="Helpers\Converter\BoolToVisibilityConverter.cs" />
+    <Compile Include="Helpers\EventArgs\GamePlayersUpdatedEventArgs.cs" />
     <Compile Include="Helpers\EventArgs\GameStatusUpdatedEventArgs.cs" />
     <Compile Include="Helpers\EventArgs\HeadingUpdatedEventArgs.cs" />
     <Compile Include="Helpers\EventArgs\NetworkStatusUpdatedEventArgs.cs" />
@@ -111,9 +112,10 @@
     <Compile Include="Model\GameHandler.cs" />
     <Compile Include="Model\GeoHandler.cs" />
     <Compile Include="Model\NetworkHandler.cs" />
+    <Compile Include="Model\Object\Statistics.cs" />
+    <Compile Include="Model\PhotoHandler.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="ViewModels\AboutVM.cs" />
-    <Compile Include="ViewModels\AccountVM.cs" />
     <Compile Include="ViewModels\MainPageVM.cs" />
     <Compile Include="ViewModels\MatchVM.cs" />
     <Compile Include="ViewModels\SettingsVM.cs" />
@@ -122,9 +124,6 @@
     <Compile Include="Views\AboutView.xaml.cs">
       <DependentUpon>AboutView.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Views\AccountView.xaml.cs">
-      <DependentUpon>AccountView.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Views\MatchView.xaml.cs">
       <DependentUpon>MatchView.xaml</DependentUpon>
     </Compile>
@@ -176,10 +175,6 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Views\AccountView.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="Views\MatchView.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>