public void GetAccessPoints() { var accessPoints = WifiService.GetAccessPointsOrderedBySignalStrength(); foreach (var accessPoint in accessPoints) { AccessPoints.Add(new WifiAccessPoint { Name = accessPoint.Name, SignalStrength = accessPoint.SignalStrength, IsConnected = accessPoint.IsConnected, IsSecure = accessPoint.IsSecure }); } }
public void Add(IAccessPoint item) { var ap = AccessPoints.FirstOrDefault(p => string.Equals(p.Bssid, item.Bssid, StringComparison.CurrentCultureIgnoreCase)); if (ap == null) { AccessPoints.Add(item); TrackerManager.CheckAccessPoint(item); } else { ap.LastTime = item.LastTime; } }
/// <summary> /// Select access point from the access points in range. /// </summary> public void SelectAccessPointCmd() { try { bool dialogResult = _windowManager.ShowDialog(_wiFiSearchViewModel) ?? false; if (dialogResult) { AccessPoints.Add(_wiFiSearchViewModel.SelectedAccessPoint); SelectedAccessPoint = _wiFiSearchViewModel.SelectedAccessPoint; SelectedInterface = _wiFiSearchViewModel.SelectedInterface; } } catch (Exception ex) { BusyStateManager.SetMessage(SeverityType.Error, ex.Message); BusyStateManager.ClearBusy(); } }
/// <summary> /// Refresh selected access point properties. /// </summary> private async Task RefreshAccessPointAsync() { BusyStateManager.EnterBusy(); BusyStateManager.SetMessage(SeverityType.Info, $"Refreshing the status of access point [{SelectedAccessPoint.Ssid}]."); IEnumerable <AccessPoint> accessPoints = await _mainController.GetWiFiAccessPointsAsync(); AccessPoint accessPoint = accessPoints.Where(x => x.Id == SelectedAccessPoint.Id && x.Ssid == SelectedAccessPoint.Ssid && x.ProfileName == SelectedAccessPoint.Ssid).FirstOrDefault(); /* If access point not found, repeat search without specifying profile name. */ if (accessPoint == default(AccessPoint)) { accessPoint = accessPoints.Where(x => x.Id == SelectedAccessPoint.Id && x.Ssid == SelectedAccessPoint.Ssid).FirstOrDefault(); } /* Update access point in view. */ if (accessPoint != default(AccessPoint)) { AccessPoints.Clear(); AccessPoints.Add(accessPoint); SelectedAccessPoint = accessPoint; } /* Update SelectedInterface status, (isConnected). */ IEnumerable <Interface> interfaces = await _mainController.GetWiFiInterfacesAsync(); Interface wiFiInterface = interfaces.Where(x => x.Id == SelectedInterface.Id).FirstOrDefault(); if (wiFiInterface != default(Interface)) { SelectedInterface = wiFiInterface; } BusyStateManager.SetMessage(SeverityType.None); BusyStateManager.ExitBusy(); }