예제 #1
0
        private void wifi_listView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((wifi_checkBox.IsChecked == true) && (wifi_listView.SelectedItem != null))
            {
                wifiConnect selectedItem = (wifiConnect)wifi_listView.SelectedItem;

                if (selectedItem != null)
                {
                    Wifi wifi = new Wifi();

                    IEnumerable <AccessPoint> accessPoints = wifi.GetAccessPoints();

                    // for each access point from list
                    foreach (AccessPoint ap in accessPoints)
                    {
                        if (ap.Name.StartsWith(selectedItem.AccesPoint))
                        {
                            //verify connection to desired SSID
                            wifi_password_label.Content  = ("connected:" + ap.Name + System.Environment.NewLine);
                            wifi_password_label.Content += ("password needed: " + ap.IsConnected + System.Environment.NewLine);
                            wifi_password_label.Content += ("profile" + ap.HasProfile + System.Environment.NewLine);
                        }
                    }
                }
            }
        }
예제 #2
0
        private void wifi_connect_button_Click(object sender, RoutedEventArgs e)
        {
            Wifi wifi = new Wifi();

            // get list of access points
            IEnumerable <AccessPoint> accessPoints = wifi.GetAccessPoints();

            // for each access point from list
            foreach (AccessPoint ap in accessPoints)
            {
                if (ap.IsConnected)
                {
                    wifiConnect selectedItem = (wifiConnect)wifi_listView.SelectedItem;
                    wifi_password_label.Content = "Already connected to " + selectedItem.AccesPoint;
                    return;
                }
                else
                {
                    wifiConnect selectedAp = (wifiConnect)wifi_listView.SelectedItem;

                    if (ap.Name.StartsWith(selectedAp.AccesPoint))
                    {
                        wifi_password_label.Content = ("Trying to connect..\r\n");
                        //AuthRequest authRequest = new AuthRequest(ap);
                        //authRequest.Password = "******";
                        ConnectToWifi(ap, wifi_passwordBox.Password);
                    }
                }
            }
        }