private async void TgSwitch_Toggled(object sender, RoutedEventArgs e) { tgSwitch.IsEnabled = false; if (tgSwitch.IsOn && (tetheringManager.TetheringOperationalState == TetheringOperationalState.Off)) { bool fNewConfig = false; ConfGui_Enable(false); NetworkOperatorTetheringAccessPointConfiguration apConfig = tetheringManager.GetCurrentAccessPointConfiguration(); if (txtSSID.Text != apConfig.Ssid) { apConfig.Ssid = txtSSID.Text; fNewConfig = true; } if (txtPass.Password != apConfig.Passphrase) { apConfig.Passphrase = txtPass.Password; fNewConfig = true; } if (fNewConfig) { await tetheringManager.ConfigureAccessPointAsync(apConfig); } var result = await tetheringManager.StartTetheringAsync(); if (result.Status != TetheringOperationStatus.Success) { // txtStatus.Text = "Can't start!"; } } else if (!tgSwitch.IsOn && (tetheringManager.TetheringOperationalState == TetheringOperationalState.On)) { var result = await tetheringManager.StopTetheringAsync(); if (result.Status == TetheringOperationStatus.Success) { SetupTethering(); } else { // txtStatus.Text = "Can't stop!"; } } }
private async void Apply_Click(object sender, RoutedEventArgs e) { try { // read the new configuration from the UI NetworkOperatorTetheringAccessPointConfiguration newConfiguration = new NetworkOperatorTetheringAccessPointConfiguration(); newConfiguration.Ssid = NetworkName.Text; newConfiguration.Passphrase = Password.Text; await tetheringManager.ConfigureAccessPointAsync(newConfiguration); rootPage.NotifyUser("Operation completed.", NotifyType.StatusMessage); } catch (Exception ex) { rootPage.NotifyUser("Unexpected exception occured: " + ex.ToString(), NotifyType.ErrorMessage); return; } }
private async Task <bool> StartNetworkOperatorTetheringManager(WlanSetting setting) { var Config = _tetheringManager.GetCurrentAccessPointConfiguration(); _setting = setting; Config.Ssid = setting.Name; Config.Passphrase = setting.Password; await _tetheringManager.ConfigureAccessPointAsync(Config); var result = await _tetheringManager.StartTetheringAsync(); if (result.Status == TetheringOperationStatus.Success) { return(true); } else { return(false); } }