private async Task <IEnumerable <WiFiSignal> > GetWiFiSignalsData() { await this._wiFiScanner.ScanForNetworks(); return(await Task.Run(() => { var signals = new List <WiFiSignal>(); foreach (var availableNetwork in _wiFiScanner.WiFiAdapter.NetworkReport.AvailableNetworks) { WiFiSignal wifiSignal = new WiFiSignal { BeaconInterval = availableNetwork.BeaconInterval.TotalSeconds.ToString(), BSSID = availableNetwork.Bssid, ChannelCenterFrequencyInKilohertz = availableNetwork.ChannelCenterFrequencyInKilohertz, Encryption = availableNetwork.SecuritySettings.NetworkEncryptionType.ToString(), IsWiFiDirect = availableNetwork.IsWiFiDirect, NetworkKind = availableNetwork.NetworkKind.ToString(), PhyKind = availableNetwork.PhyKind.ToString(), SignalStrength = (short)availableNetwork.NetworkRssiInDecibelMilliwatts, SSID = availableNetwork.Ssid, Uptime = availableNetwork.Uptime.TotalHours.ToString() }; signals.Add(wifiSignal); } return signals; })); }
private static void Check(WiFiSignal signal, TextBlock tbSignalStrength, TextBlock tbEncryption) { CurrentColorSchemeWifiInfo colorScheme = CurrentColorSchemeWifiInfo.GetInstance(); if (signal.SignalStrength <= colorScheme.BadSignal) { tbSignalStrength.Foreground = colorScheme.BadSignalForeground; tbSignalStrength.Text = colorScheme.BadSignalSymbol; } else if (signal.SignalStrength > colorScheme.BadSignal && signal.SignalStrength <= colorScheme.NormalSignal) { tbSignalStrength.Foreground = colorScheme.NormalSignalForeground; tbSignalStrength.Text = colorScheme.NormalSignalSymbol; } else { tbSignalStrength.Foreground = colorScheme.GoodSignalForeground; tbSignalStrength.Text = colorScheme.GoodSignalSymbol; } if (signal.Encryption != "None") { tbEncryption.Foreground = colorScheme.BadSignalForeground; } else { tbEncryption.Foreground = colorScheme.GoodSignalForeground; } }