private void ShowAsyncQueueButton_OnClick(object sender, RoutedEventArgs e)
 {
     var dialog = new MessageDialog("Dialog 1 ShowAsyncQueue", "Dialog 1");
     dialog.ShowAsyncQueue();
     dialog = new MessageDialog("Dialog 2 ShowAsyncQueue", "Dialog 2");
     dialog.ShowAsyncQueue();
     dialog = new MessageDialog("Dialog 3 ShowAsyncQueue", "Dialog 3");
     dialog.ShowAsyncQueue();
 }
        private void ShowAsyncQueueButton_OnClick(object sender, RoutedEventArgs e)
        {
            var dialog = new MessageDialog("Dialog 1 ShowAsyncQueue", "Dialog 1");
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            dialog.ShowAsyncQueue();
            dialog = new MessageDialog("Dialog 2 ShowAsyncQueue", "Dialog 2");
            dialog.ShowAsyncQueue();
            dialog = new MessageDialog("Dialog 3 ShowAsyncQueue", "Dialog 3");
            dialog.ShowAsyncQueue();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }
Ejemplo n.º 3
0
 public static async Task HandleException()
 {
     var dialog = new MessageDialog("Something went wrong and app may be unstable now. Do you want to logout and try again?");
     dialog.Commands.Add(new UICommand("Yes") { Id = 0 });
     dialog.Commands.Add(new UICommand("No") { Id = 1 });
     dialog.DefaultCommandIndex = 0;
     dialog.CancelCommandIndex = 1;
     var result = await dialog.ShowAsyncQueue();
     if ((int)result.Id == 0)
     {
         GameClient.DoLogout();
         BootStrapper.Current.NavigationService.Navigate(typeof(MainPage));
     }
 }
Ejemplo n.º 4
0
 public static async Task HandleException()
 {
     var dialog = new MessageDialog(Resources.Translation.GetString("SomethingWentWrong"));
     dialog.Commands.Add(new UICommand(Resources.Translation.GetString("Yes")) { Id = 0 });
     dialog.Commands.Add(new UICommand(Resources.Translation.GetString("No")) { Id = 1 });
     dialog.DefaultCommandIndex = 0;
     dialog.CancelCommandIndex = 1;
     var result = await dialog.ShowAsyncQueue();
     if ((int)result.Id == 0)
     {
         GameClient.DoLogout();
         BootStrapper.Current.NavigationService.Navigate(typeof(MainPage));
     }
 }
        private async void ShowAsyncQueuePlusIfPossibleButton_OnClick(object sender, RoutedEventArgs e)
        {
            // This should obviously be displayed
            var dialog = new MessageDialog("await ShowAsync", "Dialog 1");
            await dialog.ShowAsync();

            // This should be displayed because we awaited the previous request to return
            dialog = new MessageDialog("await ShowAsync", "Dialog 2");
            await dialog.ShowAsync(); 

            // All other requests below are invoked without awaiting
            // the preceding ones to complete (dialogs being closed)

            // This will show because there is no dialog shown at this time
            dialog = new MessageDialog("ShowAsyncIfPossible", "Dialog 3");
#pragma warning disable 4014
            dialog.ShowAsyncIfPossible();

            // This will not show because there is a dialog shown at this time
            dialog = new MessageDialog("ShowAsyncIfPossible", "Dialog 4");
            dialog.ShowAsyncIfPossible();

            // This will show after Dialog 3 is dismissed
            dialog = new MessageDialog("ShowAsyncQueue", "Dialog 5");
            dialog.ShowAsyncQueue();

            // This will not show because there is a dialog shown at this time (Dialog 3)
            dialog = new MessageDialog("ShowAsyncIfPossible", "Dialog 6");
            dialog.ShowAsyncIfPossible();

            // This will show after Dialog 5 is dismissed
            dialog = new MessageDialog("ShowAsyncQueue", "Dialog 7");
            dialog.ShowAsyncQueue();

            // This will show after Dialog 7 is dismissed
            dialog = new MessageDialog("ShowAsyncQueue", "Dialog 8");
            dialog.ShowAsyncQueue();
#pragma warning restore 4014
        }
Ejemplo n.º 6
0
        public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
        {
            var hasPreviousSession = !string.IsNullOrEmpty(SettingsService.Instance.PtcAuthToken) ||
                                     !string.IsNullOrEmpty(SettingsService.Instance.GoogleAuthToken);
            if (hasPreviousSession)
            {
                try
                {
                    await GameClient.InitializeClient(!string.IsNullOrEmpty(SettingsService.Instance.PtcAuthToken));
                    // We have a stored token, let's go to game page 
                    NavigationService.Navigate(typeof(GameMapPage), true);
                    //await ViewModelLocator.GameManagerViewModel.InitGame(true);
                }
                catch (Exception)
                {
                    await ExceptionHandler.HandleException();
                }
            }
            else
            {
                await NavigationService.NavigateAsync(typeof(MainPage));
            }

            // Check for updates
            var latestVersionUri = await UpdateManager.IsUpdateAvailable();
            if (latestVersionUri != null)
            {                
                var dialog = new MessageDialog(
                $"An updated version is available on\n{latestVersionUri}\nDo you want to visit the link?");

                dialog.Commands.Add(new UICommand("Yes") { Id = 0 });
                dialog.Commands.Add(new UICommand("No") { Id = 1 });
                dialog.DefaultCommandIndex = 0;
                dialog.CancelCommandIndex = 1;
                
                var result = await dialog.ShowAsyncQueue();
                if ((int) result.Id != 0) return;
                await Launcher.LaunchUriAsync(new Uri(latestVersionUri));
            }
            await Task.CompletedTask;
        }
Ejemplo n.º 7
0
 async void networkListenerService_InternetConnectionChanged(object sender, Model.Events.InternetConnectionChangedEventArgs e)
 {
     await App.Dispatcher?.RunAsync(CoreDispatcherPriority.Normal, async () =>
     {
         IsInternet = e.IsConnected;
         if (!IsInternet)
         {
             if (Locator.MediaPlaybackViewModel?.IsPlaying == true && Locator.MediaPlaybackViewModel.IsStream)
             {
                 var lostStreamDialog = new MessageDialog("Connection to the server was stopped, please check your Internet connection");
                 await lostStreamDialog.ShowAsyncQueue();
             }
         }
     });
 }
 async void _mediaService_MediaFailed(object sender, EventArgs e)
 {
     if (sender is MFService)
     {
         // MediaFoundation failed to open the media, switching to VLC player
         await SetMedia(CurrentMedia, true);
     }
     else
     {
         await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
         {
             var md = new MessageDialog("Your media cannot be read.", "We're sorry");
             await md.ShowAsyncQueue();
             // ensure we call Stop so we unregister all events
             Stop();
         });
     }
 }
Ejemplo n.º 9
0
        public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
        {
            // TODO: this is really ugly!
            var hasPreviousSession = !string.IsNullOrEmpty(SettingsService.Instance.PtcAuthToken) ||
                                     !string.IsNullOrEmpty(SettingsService.Instance.GoogleAuthToken);
            if (hasPreviousSession)
            {
                try
                {
                    await GameClient.InitializeClient(!string.IsNullOrEmpty(SettingsService.Instance.PtcAuthToken));
                    // We have a stored token, let's go to game page 
                    NavigationService.Navigate(typeof(GameMapPage), true);
                }
                catch (Exception)
                {
                    await ExceptionHandler.HandleException();
                }
            }
            else
            {
                await NavigationService.NavigateAsync(typeof(MainPage));
            }

            // Check for updates
            var latestVersionUri = await UpdateManager.IsUpdateAvailable();
            if (latestVersionUri != null)
            {                
                var dialog = new MessageDialog(Utils.Resources.Translation.GetString("UpdatedVersion1") +
                $"\n{latestVersionUri}\n" + Utils.Resources.Translation.GetString("UpdatedVersion2"));

                dialog.Commands.Add(new UICommand(Utils.Resources.Translation.GetString("Yes")) { Id = 0 });
                dialog.Commands.Add(new UICommand(Utils.Resources.Translation.GetString("No")) { Id = 1 });
                dialog.DefaultCommandIndex = 0;
                dialog.CancelCommandIndex = 1;
                
                var result = await dialog.ShowAsyncQueue();
                if ((int) result.Id != 0) return;
                await Launcher.LaunchUriAsync(new Uri(latestVersionUri));
            }
            await Task.CompletedTask;
        }
        /// <summary>
        /// Je možné, že vyhodí chybu.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void locator_StatusChanged(Geolocator sender, StatusChangedEventArgs args)
        {
            
            string s;
            s = _localSettings.Containers["AppSettings"].Values["lastNearestStation"].ToString();

            //Získání stavu
            var a = sender.LocationStatus.ToString();


            switch (sender.LocationStatus)
            {
                case Windows.Devices.Geolocation.PositionStatus.Disabled:
                    CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
                    {
                        //await msgGPSDisabled();
                        MessageDialog sss = new MessageDialog(_resourceLoader.GetString("MsgGPSDisabled"),_resourceLoader.GetString("Error"));
                        await sss.ShowAsyncQueue();

                        IsGPSBusy = false;
                        IsGPS = false;

                        App.ViewModel.GPSStatus = GPSSTATUS.GPSdisabled.ToString();
                    });
                    
                    if (s != null)
                    {
                        CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            App.ViewModel.CurrentStation = App.ViewModel.GetStation(s);                        
                            
                        });
                    }
                    
                    
                    break;

                case Windows.Devices.Geolocation.PositionStatus.NoData:
                    CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
                    {
                        MessageDialog sss = new MessageDialog(_resourceLoader.GetString("MsgGPSUnavailable"), _resourceLoader.GetString("Error"));
                        await sss.ShowAsyncQueue();

                        IsGPSBusy = false;
                        IsGPS = false;
                        App.ViewModel.GPSStatus = GPSSTATUS.GPSnotactive.ToString();
                    });

                    

                    if (s != null) App.ViewModel.CurrentStation = App.ViewModel.GetStation(s);

                    break;
                case Windows.Devices.Geolocation.PositionStatus.Ready:
                    var nearestStation = true;
                    object tmpObject = null;
                    Windows.Storage.ApplicationData.Current.LocalSettings.Containers["AppSettings"].Values.TryGetValue("nearestStation", out tmpObject);            
                    bool? x = tmpObject as bool?;
                    if (x != null)
                    {
                        nearestStation = x.Value;
                    }
                    if (nearestStation)
                    {
                        CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
                                    {
                                        App.ViewModel.GPSStatus = GPSSTATUS.GPSactive.ToString();
                                    }); 
                    }
                    break;
            }
        }