diff --git a/Source/NETworkManager.Converters/WiFiAuthenticationTypeToHumanReadableStringConverter.cs b/Source/NETworkManager.Converters/WiFiAuthenticationTypeToHumanReadableStringConverter.cs deleted file mode 100644 index 06868a4a98..0000000000 --- a/Source/NETworkManager.Converters/WiFiAuthenticationTypeToHumanReadableStringConverter.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Globalization; -using System.Windows.Data; -using Windows.Networking.Connectivity; -using NETworkManager.Models.Network; - -namespace NETworkManager.Converters; - -public sealed class WiFiAuthenticationTypeToHumanReadableStringConverter : IValueConverter -{ - /* Translate the name of the accent */ - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return value is not NetworkAuthenticationType type - ? "-/-" - : $"{WiFi.GetHumanReadableNetworkAuthenticationType(type)}"; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } -} \ No newline at end of file diff --git a/Source/NETworkManager.Converters/WiFiChannelCenterFrequencyToChannelStringConverter.cs b/Source/NETworkManager.Converters/WiFiChannelCenterFrequencyToChannelStringConverter.cs deleted file mode 100644 index a061d751dd..0000000000 --- a/Source/NETworkManager.Converters/WiFiChannelCenterFrequencyToChannelStringConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Globalization; -using System.Windows.Data; - -namespace NETworkManager.Converters; - -public sealed class WiFiChannelCenterFrequencyToChannelStringConverter : IValueConverter -{ - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return value is not int channel ? "-/-" : $"{channel}"; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } -} \ No newline at end of file diff --git a/Source/NETworkManager.Converters/WiFiPhyKindToStringConverter.cs b/Source/NETworkManager.Converters/WiFiPhyKindToStringConverter.cs deleted file mode 100644 index 6e0eef97bf..0000000000 --- a/Source/NETworkManager.Converters/WiFiPhyKindToStringConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Globalization; -using System.Windows.Data; -using Windows.Devices.WiFi; -using NETworkManager.Models.Network; - -namespace NETworkManager.Converters; - -public sealed class WiFiPhyKindToStringConverter : IValueConverter -{ - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return value is not WiFiPhyKind phyKind ? "-/-" : $"{WiFi.GetHumanReadablePhyKind(phyKind)}"; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } -} \ No newline at end of file diff --git a/Source/NETworkManager.Models/Network/WiFi.cs b/Source/NETworkManager.Models/Network/WiFi.cs index 3c5af19d2d..0066ee502a 100644 --- a/Source/NETworkManager.Models/Network/WiFi.cs +++ b/Source/NETworkManager.Models/Network/WiFi.cs @@ -6,6 +6,7 @@ using Windows.Devices.WiFi; using Windows.Networking.Connectivity; using Windows.Security.Credentials; +using NETworkManager.Models.Lookup; namespace NETworkManager.Models.Network; @@ -81,6 +82,9 @@ public static async Task GetNetworksAsync(WiFiAdapter adapt Channel = GetChannelFromChannelFrequency(channelFrequencyInGigahertz), IsHidden = string.IsNullOrEmpty(availableNetwork.Ssid), IsConnected = availableNetwork.Bssid.Equals(bssid, StringComparison.OrdinalIgnoreCase), + NetworkAuthenticationType = GetHumanReadableNetworkAuthenticationType(availableNetwork.SecuritySettings.NetworkAuthenticationType), + Vendor = (await OUILookup.LookupByMacAddressAsync(availableNetwork.Bssid)).FirstOrDefault()?.Vendor ?? "-/-", + PhyKind = GetHumanReadablePhyKind(availableNetwork.PhyKind) }; wifiNetworkInfos.Add(wifiNetworkInfo); diff --git a/Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs b/Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs index 20c61a38fd..6c94b8ffa5 100644 --- a/Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs +++ b/Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs @@ -25,10 +25,10 @@ public WiFiNetworkInfo() /// /// Radio that is used like 2.4 GHz, 5 GHz, etc. /// - public WiFiRadio Radio { get; set; } + public WiFiRadio Radio { get; init; } /// - /// The channel center frequency in Gigahertz. + /// The channel center frequency in Gigahertz like 2.4 GHz, 5 GHz, etc. /// public double ChannelCenterFrequencyInGigahertz { get; set; } @@ -47,5 +47,19 @@ public WiFiNetworkInfo() /// public bool IsConnected { get; set; } + /// + /// Human-readable network authentication type. + /// + public string NetworkAuthenticationType { get; set; } + + /// + /// Vendor of the Wi-Fi network like Cisco, Netgear, etc. + /// + public string Vendor { get; set; } + + /// + /// Human-readable phy kind. + /// + public string PhyKind { get; set; } #endregion } \ No newline at end of file diff --git a/Source/NETworkManager/ViewModels/WiFiViewModel.cs b/Source/NETworkManager/ViewModels/WiFiViewModel.cs index c7e0ea52e8..93aad6ce3c 100644 --- a/Source/NETworkManager/ViewModels/WiFiViewModel.cs +++ b/Source/NETworkManager/ViewModels/WiFiViewModel.cs @@ -84,7 +84,7 @@ public bool IsAdaptersLoading } } - private List _adapters = new(); + private List _adapters = []; public List Adapters { @@ -487,13 +487,14 @@ public WiFiViewModel(IDialogCoordinator instance) if (string.IsNullOrEmpty(Search)) return true; - // Search by: SSID, Security, Channel, BSSID (MAC address), Vendor, Phy kind + // Search by: SSID, Security, Frequency , Channel, BSSID (MAC address), Vendor, Phy kind return info.AvailableNetwork.Ssid.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 || - WiFi.GetHumanReadableNetworkAuthenticationType(info.AvailableNetwork.SecuritySettings.NetworkAuthenticationType).IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 || + info.NetworkAuthenticationType.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 || + $"{info.ChannelCenterFrequencyInGigahertz}".IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 || $"{info.Channel}".IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 || info.AvailableNetwork.Bssid.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 || - OUILookup.LookupByMacAddress(info.AvailableNetwork.Bssid).FirstOrDefault()?.Vendor.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 || - WiFi.GetHumanReadablePhyKind(info.AvailableNetwork.PhyKind).IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1; + info.Vendor.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 || + info.PhyKind.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1; }; // Load network adapters diff --git a/Source/NETworkManager/Views/WiFiView.xaml b/Source/NETworkManager/Views/WiFiView.xaml index c7c228893e..6a4d21ffdb 100644 --- a/Source/NETworkManager/Views/WiFiView.xaml +++ b/Source/NETworkManager/Views/WiFiView.xaml @@ -27,18 +27,12 @@ - - - - @@ -306,7 +300,7 @@ Style="{StaticResource ResourceKey=CopyMenuItem}" /> + Binding="{Binding Path=(network:WiFiNetworkInfo.NetworkAuthenticationType)}" + SortMemberPath="NetworkAuthenticationType" /> + SortMemberPath="ChannelCenterFrequencyInGigahertz" /> + Binding="{Binding Path=(network:WiFiNetworkInfo.Channel)}" + SortMemberPath="Channel" /> + Binding="{Binding Path=(network:WiFiNetworkInfo.Vendor)}" + SortMemberPath="Vendor" /> + Binding="{Binding Path=(network:WiFiNetworkInfo.PhyKind)}" + SortMemberPath="PhyKind" />