WifiIsAvailable() публичный Метод

public WifiIsAvailable ( ) : Task
Результат Task
        private async void NextButton_Clicked(object sender, RoutedEventArgs e)
        {
            var wifiAvailable = networkPresenter.WifiIsAvailable();

            SetPreferences();
            Type nextScreen;

            try
            {
                nextScreen = (await wifiAvailable) ? typeof(OOBENetwork) : typeof(MainPage);
            }
            catch (Exception)
            {
                nextScreen = typeof(MainPage);
            }

            await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                // If the next screen is the main-page, navigate there, but also launch Cortana to its Consent Page independently
                if (nextScreen == typeof(MainPage))
                {
                    await CortanaHelper.LaunchCortanaToConsentPageAsyncIfNeeded();
                }
                NavigationUtils.NavigateToScreen(nextScreen);
            });
        }
Пример #2
0
        private async void SetupWifi()
        {
            if (await networkPresenter.WifiIsAvailable())
            {
                IList <WiFiAvailableNetwork> networks;
                try
                {
                    networks = await networkPresenter.GetAvailableNetworks();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(String.Format("Error scanning: 0x{0:X}: {1}", e.HResult, e.Message));
                    NoWifiFoundText.Text       = e.Message;
                    NoWifiFoundText.Visibility = Visibility.Visible;
                    return;
                }

                if (networks.Count > 0)
                {
                    WifiListView.ItemsSource = networks;

                    NoWifiFoundText.Visibility = Visibility.Collapsed;
                    WifiListView.Visibility    = Visibility.Visible;
                    return;
                }
            }

            NoWifiFoundText.Visibility = Visibility.Visible;
            WifiListView.Visibility    = Visibility.Collapsed;
        }
Пример #3
0
        private async void SetupWifi()
        {
            networkPresenter = new NetworkPresenter();

            if (await NetworkPresenter.WifiIsAvailable())
            {
                var networks = await networkPresenter.GetAvailableNetworks();

                if (networks.Count > 0)
                {
                    WifiListView.ItemsSource = networks;
                    var connectedNetwork = networkPresenter.GetCurrentWifiNetwork();

                    if (connectedNetwork != null)
                    {
                        SwitchToItemState(connectedNetwork, WifiConnectedState, true);
                    }

                    NoWifiFoundText.Visibility = Visibility.Collapsed;
                    WifiListView.Visibility    = Visibility.Visible;

                    return;
                }
            }

            NoWifiFoundText.Visibility = Visibility.Visible;
            WifiListView.Visibility    = Visibility.Collapsed;
        }
Пример #4
0
        private async void SetupWifi()
        {
            networkPresenter = new NetworkPresenter();

            if (await NetworkPresenter.WifiIsAvailable())
            {
                var networks = await networkPresenter.GetAvailableNetworks();

                if (networks.Count > 0)
                {
                    WifiListView.ItemsSource = networks;
                    var connectedNetwork = networkPresenter.GetCurrentWifiNetwork();

                    if (connectedNetwork != null)
                    {
                        var connectedListItem = WifiListView.ContainerFromItem(connectedNetwork) as ListViewItem;
                        connectedListItem.ContentTemplate = WifiConnectedState;
                    }

                    NoWifiFoundText.Visibility = Visibility.Collapsed;
                    WifiListView.Visibility    = Visibility.Visible;

                    return;
                }
            }

            NoWifiFoundText.Visibility = Visibility.Visible;
            WifiListView.Visibility    = Visibility.Collapsed;
        }
Пример #5
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
/*#if DEBUG
 *          if (System.Diagnostics.Debugger.IsAttached)
 *          {
 *              this.DebugSettings.EnableFrameRateCounter = true;
 *          }
 #endif*/

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Set the default language
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter

                var wifiIsAvailable = await NetworkPresenter.WifiIsAvailable();

                if (ApplicationData.Current.LocalSettings.Values.ContainsKey(Constants.HasDoneOOBEKey) || !wifiIsAvailable)
                {
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                else
                {
                    rootFrame.Navigate(typeof(OOBENetwork), e.Arguments);
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
Пример #6
0
        private async Task RecreateWifiNetworkListAsync()
        {
            if (await networkPresenter.WifiIsAvailable())
            {
                EnableView(false);

                ObservableCollection <WiFiAvailableNetwork> networks;
                try
                {
                    networks = new ObservableCollection <WiFiAvailableNetwork>(await networkPresenter.GetAvailableNetworks());
                }
                catch (Exception e)
                {
                    Debug.WriteLine(String.Format("Error scanning: 0x{0:X}: {1}", e.HResult, e.Message));
                    NoWifiFoundText.Text       = e.Message;
                    NoWifiFoundText.Visibility = Visibility.Visible;
                    EnableView(true);
                    return;
                }

                if (networks.Count > 0)
                {
                    var connectedNetwork = networkPresenter.GetCurrentWifiNetwork();
                    if (connectedNetwork != null)
                    {
                        networks.Remove(connectedNetwork);
                        networks.Insert(0, connectedNetwork);
                        WifiListView.ItemsSource = networks;
                        SwitchToItemState(connectedNetwork, WifiConnectedState, true);
                    }
                    else
                    {
                        WifiListView.ItemsSource = networks;
                    }


                    NoWifiFoundText.Visibility = Visibility.Collapsed;
                    WifiListView.Visibility    = Visibility.Visible;
                    EnableView(true);
                    return;
                }
            }

            NoWifiFoundText.Visibility = Visibility.Visible;
            WifiListView.Visibility    = Visibility.Collapsed;
        }
Пример #7
0
        private async void SetupWifi()
        {
            if (await networkPresenter.WifiIsAvailable())
            {
                var networks = await networkPresenter.GetAvailableNetworks();

                if (networks.Count > 0)
                {
                    WifiListView.ItemsSource = networks;

                    NoWifiFoundText.Visibility = Visibility.Collapsed;
                    WifiListView.Visibility    = Visibility.Visible;
                    return;
                }
            }

            NoWifiFoundText.Visibility = Visibility.Visible;
            WifiListView.Visibility    = Visibility.Collapsed;
        }
Пример #8
0
        private async void NextButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var wifiAvailable = NetworkPresenter.WifiIsAvailable();

            SetPreferences();
            Type nextScreen;

            try
            {
                nextScreen = (await wifiAvailable) ? typeof(OOBENetwork) : typeof(MainPage);
            }
            catch (Exception)
            {
                nextScreen = typeof(MainPage);
            }

            await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                NavigationUtils.NavigateToScreen(nextScreen);
            });
        }
Пример #9
0
        private async void NextButton_Clicked(object sender, RoutedEventArgs e)
        {
            var networkPresenter = new NetworkPresenter();
            var wifiAvailable = networkPresenter.WifiIsAvailable();
            SetPreferences();
            Type nextScreen;

            try
            {
                nextScreen = (await wifiAvailable) ? typeof(OOBENetwork) : typeof(MainPage);
            }
            catch (Exception)
            {
                nextScreen = typeof(MainPage);
            }

            await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                NavigationUtils.NavigateToScreen(nextScreen);
            });
        }