Pārlūkot izejas kodu

Nice error messages

Kenneth van Ewijk 10 gadi atpakaļ
vecāks
revīzija
337f0c308f
2 mainītis faili ar 44 papildinājumiem un 5 dzēšanām
  1. 42 3
      YJMPD-UWP/ViewModels/MatchVM.cs
  2. 2 2
      YJMPD-UWP/Views/MatchView.xaml

+ 42 - 3
YJMPD-UWP/ViewModels/MatchVM.cs

@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.Diagnostics;
 using YJMPD_UWP.Model.Object;
 
 namespace YJMPD_UWP.ViewModels
@@ -36,7 +37,8 @@ namespace YJMPD_UWP.ViewModels
             dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 NotifyPropertyChanged(nameof(MatchAvailable));
-                NotifyPropertyChanged(nameof(ConnectingServer));
+                NotifyPropertyChanged(nameof(ServerAvailable));
+                NotifyPropertyChanged(nameof(ServerMessage));
             });
         }
 
@@ -45,7 +47,8 @@ namespace YJMPD_UWP.ViewModels
             dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 NotifyPropertyChanged(nameof(MatchAvailable));
-                NotifyPropertyChanged(nameof(ConnectingServer));
+                NotifyPropertyChanged(nameof(ServerAvailable));
+                NotifyPropertyChanged(nameof(ServerMessage));
             });
         }
         
@@ -77,7 +80,7 @@ namespace YJMPD_UWP.ViewModels
             }
         }
 
-        public bool ConnectingServer
+        public bool ServerAvailable
         {
             get
             {
@@ -85,6 +88,42 @@ namespace YJMPD_UWP.ViewModels
             }
         }
 
+        public string ServerMessage
+        {
+            get
+            {
+                string str = "";
+
+                switch (App.Network.Status)
+                {
+                    case Model.NetworkHandler.NetworkStatus.DISCONNECTED:
+                        str = "Disconnected";
+                        break;
+                    case Model.NetworkHandler.NetworkStatus.CONNECTING:
+                        str = "Connecting to server...";
+                        break;
+                }
+
+                switch(App.Geo.Status)
+                {
+                    case Windows.Devices.Geolocation.PositionStatus.Disabled:
+                    case Windows.Devices.Geolocation.PositionStatus.NotAvailable:
+                    case Windows.Devices.Geolocation.PositionStatus.NoData:
+                        str = "GPS not available";
+                        break;
+                    case Windows.Devices.Geolocation.PositionStatus.NotInitialized:
+                    case Windows.Devices.Geolocation.PositionStatus.Initializing:
+                        str = "Waiting on GPS...";
+                        break;
+                }
+
+                if (str == "")
+                    str = "Connected";
+
+                return str;
+            }
+        }
+
         public bool StartMatch
         {
             get

+ 2 - 2
YJMPD-UWP/Views/MatchView.xaml

@@ -45,9 +45,9 @@
             </StackPanel>
         </ScrollViewer>
 
-        <StackPanel Orientation="Horizontal" Grid.Row="1" Visibility="{Binding ConnectingServer, Converter={StaticResource BoolToVisConverter}}" Padding="20" Background="Gray">
+        <StackPanel Orientation="Horizontal" Grid.Row="1" Visibility="{Binding ServerAvailable, Converter={StaticResource BoolToVisConverter}}" Padding="20" Background="Gray">
             <ProgressRing Width="20" Height="20" IsActive="True" Margin="0,0,10,0" Foreground="White"/>
-            <TextBlock Text="Waiting on server..." Foreground="White" />
+            <TextBlock Text="{Binding ServerMessage}" Foreground="White" />
         </StackPanel>
     </Grid>
 </Page>