Example #1
0
        private async void TestButtonClick(object sender, RoutedEventArgs e)
        {
            if (!AreInformationValid())
            {
                return;
            }

            IsLoading = true;

            try
            {
                var result = await _connection.TestConnectionAsync();

                var    resourceLoader = ResourceLoader.GetForCurrentView();
                string message        = result ? resourceLoader.GetString("/settings/TestGood") : resourceLoader.GetString("/settings/TestBad");
                var    dialog         = new MessageDialog(message, resourceLoader.GetString("/settings/ConnectivityTest.Content"));
                await dialog.ShowAsync();

                App.Context.Save();
            }
            finally
            {
                IsLoading = false;
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                var statusbar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
                statusbar.BackgroundColor = new Windows.UI.Color()
                {
                    R = 76, G = 155, B = 214
                };
                statusbar.BackgroundOpacity = 1;
                statusbar.ForegroundColor   = Windows.UI.Colors.White;
            }

            _connection = App.Context.Connections.FirstOrDefault(c => c.Id.Equals(e.Parameter?.ToString(), StringComparison.OrdinalIgnoreCase));

            NavMenuList.SelectedIndex = 0;
            navlist[0].IsSelected     = true;
            AppFrame.Navigate(navlist[0].DestPage, navlist[0].Arguments);

            if (_connection != null)
            {
                if (Frame.CanGoBack)
                {
                    Frame.GoBack();
                }
                return;
            }

            //if (_connection.Kodi.IsMocked)
            //{
            //    ButtonMovies.Visibility = Visibility.Collapsed;
            //    ButtonMusic.Visibility = Visibility.Collapsed;
            //    ButtonAddons.Visibility = Visibility.Collapsed;
            //    ButtonPlaylists.Visibility = Visibility.Collapsed;
            //}
            //else
            //{
            //    ButtonMovies.Visibility = Visibility.Visible;
            //    ButtonMusic.Visibility = Visibility.Visible;
            //    ButtonAddons.Visibility = Visibility.Visible;
            //    ButtonPlaylists.Visibility = Visibility.Visible;
            //}

            App.Context.SetDefaultConnection(_connection);
            App.Context.Save();

            await _connection.TestConnectionAsync();
        }