GetCurrentWifiNetwork() public method

public GetCurrentWifiNetwork ( ) : WiFiAvailableNetwork
return WiFiAvailableNetwork
示例#1
0
        private async void SetupWifi()
        {
            if (await networkPresenter.WifiIsAvailable())
            {
                var networks = await networkPresenter.GetAvailableNetworks();

                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;

                    return;
                }
            }

            NoWifiFoundText.Visibility = Visibility.Visible;
            WifiListView.Visibility    = Visibility.Collapsed;
        }
示例#2
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;
        }
        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;
        }
示例#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)
                    {
                        SwitchToItemState(connectedNetwork, WifiConnectedState, true);
                    }

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

                    return;
                }
            }

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