Skip to content

Commit 6823097

Browse files
authored
Feature: WiFi - Improve search / remove converters (#2940)
* Fix: Improve search / remove converters * Docs: #2940 * Docs: #2940
1 parent f016f8b commit 6823097

File tree

9 files changed

+44
-89
lines changed

9 files changed

+44
-89
lines changed

Source/NETworkManager.Converters/WiFiAuthenticationTypeToHumanReadableStringConverter.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

Source/NETworkManager.Converters/WiFiChannelCenterFrequencyToChannelStringConverter.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

Source/NETworkManager.Converters/WiFiPhyKindToStringConverter.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

Source/NETworkManager.Models/Network/WiFi.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Windows.Devices.WiFi;
77
using Windows.Networking.Connectivity;
88
using Windows.Security.Credentials;
9+
using NETworkManager.Models.Lookup;
910

1011
namespace NETworkManager.Models.Network;
1112

@@ -81,6 +82,9 @@ public static async Task<WiFiNetworkScanInfo> GetNetworksAsync(WiFiAdapter adapt
8182
Channel = GetChannelFromChannelFrequency(channelFrequencyInGigahertz),
8283
IsHidden = string.IsNullOrEmpty(availableNetwork.Ssid),
8384
IsConnected = availableNetwork.Bssid.Equals(bssid, StringComparison.OrdinalIgnoreCase),
85+
NetworkAuthenticationType = GetHumanReadableNetworkAuthenticationType(availableNetwork.SecuritySettings.NetworkAuthenticationType),
86+
Vendor = (await OUILookup.LookupByMacAddressAsync(availableNetwork.Bssid)).FirstOrDefault()?.Vendor ?? "-/-",
87+
PhyKind = GetHumanReadablePhyKind(availableNetwork.PhyKind)
8488
};
8589

8690
wifiNetworkInfos.Add(wifiNetworkInfo);

Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public WiFiNetworkInfo()
2525
/// <summary>
2626
/// Radio that is used like 2.4 GHz, 5 GHz, etc.
2727
/// </summary>
28-
public WiFiRadio Radio { get; set; }
28+
public WiFiRadio Radio { get; init; }
2929

3030
/// <summary>
31-
/// The channel center frequency in Gigahertz.
31+
/// The channel center frequency in Gigahertz like 2.4 GHz, 5 GHz, etc.
3232
/// </summary>
3333
public double ChannelCenterFrequencyInGigahertz { get; set; }
3434

@@ -47,5 +47,19 @@ public WiFiNetworkInfo()
4747
/// </summary>
4848
public bool IsConnected { get; set; }
4949

50+
/// <summary>
51+
/// Human-readable network authentication type.
52+
/// </summary>
53+
public string NetworkAuthenticationType { get; set; }
54+
55+
/// <summary>
56+
/// Vendor of the Wi-Fi network like Cisco, Netgear, etc.
57+
/// </summary>
58+
public string Vendor { get; set; }
59+
60+
/// <summary>
61+
/// Human-readable phy kind.
62+
/// </summary>
63+
public string PhyKind { get; set; }
5064
#endregion
5165
}

Source/NETworkManager/ViewModels/WiFiViewModel.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public bool IsAdaptersLoading
8484
}
8585
}
8686

87-
private List<WiFiAdapterInfo> _adapters = new();
87+
private List<WiFiAdapterInfo> _adapters = [];
8888

8989
public List<WiFiAdapterInfo> Adapters
9090
{
@@ -487,13 +487,14 @@ public WiFiViewModel(IDialogCoordinator instance)
487487
if (string.IsNullOrEmpty(Search))
488488
return true;
489489

490-
// Search by: SSID, Security, Channel, BSSID (MAC address), Vendor, Phy kind
490+
// Search by: SSID, Security, Frequency , Channel, BSSID (MAC address), Vendor, Phy kind
491491
return info.AvailableNetwork.Ssid.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 ||
492-
WiFi.GetHumanReadableNetworkAuthenticationType(info.AvailableNetwork.SecuritySettings.NetworkAuthenticationType).IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 ||
492+
info.NetworkAuthenticationType.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 ||
493+
$"{info.ChannelCenterFrequencyInGigahertz}".IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 ||
493494
$"{info.Channel}".IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 ||
494495
info.AvailableNetwork.Bssid.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 ||
495-
OUILookup.LookupByMacAddress(info.AvailableNetwork.Bssid).FirstOrDefault()?.Vendor.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 ||
496-
WiFi.GetHumanReadablePhyKind(info.AvailableNetwork.PhyKind).IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1;
496+
info.Vendor.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1 ||
497+
info.PhyKind.IndexOf(Search, StringComparison.OrdinalIgnoreCase) > -1;
497498
};
498499

499500
// Load network adapters

Source/NETworkManager/Views/WiFiView.xaml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@
2727
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
2828
<converters:IntNotZeroToVisibilityCollapsedConverter x:Key="IntNotZeroToVisibilityCollapsedConverter" />
2929
<converters:IntZeroToVisibilityCollapsedConverter x:Key="IntZeroToVisibilityCollapsedConverter" />
30-
<converters:MACAddressToVendorConverter x:Key="MACAddressToVendorConverter" />
3130
<converters:TimeSpanToMillisecondConverter x:Key="TimeSpanToMillisecondConverter" />
3231
<converters:TimeSpanToStringConverter x:Key="TimeSpanToStringConverter" />
33-
<converters:WiFiAuthenticationTypeToHumanReadableStringConverter
34-
x:Key="WiFiAuthenticationTypeToHumanReadableStringConverter" />
35-
<converters:WiFiChannelCenterFrequencyToChannelStringConverter
36-
x:Key="WiFiChannelCenterFrequencyToChannelStringConverter" />
3732
<converters:WiFiChannelCenterFrequencyToFrequencyStringConverter
3833
x:Key="WiFiChannelCenterFrequencyToFrequencyStringConverter" />
3934
<converters:WiFiNetworkRssiInDecibelMilliwattsToSignalStrengthStringConverter
4035
x:Key="WiFiNetworkRssiInDecibelMilliwattsToSignalStrengthStringConverter" />
41-
<converters:WiFiPhyKindToStringConverter x:Key="WiFiPhyKindToStringConverter" />
4236
</UserControl.Resources>
4337
<Grid>
4438
<Grid>
@@ -306,15 +300,15 @@
306300
Style="{StaticResource ResourceKey=CopyMenuItem}" />
307301
<MenuItem Header="{x:Static Member=localization:Strings.Security}"
308302
Command="{Binding Path=CopyDataToClipboardCommand}"
309-
CommandParameter="{Binding Path=SelectedNetwork.AvailableNetwork.SecuritySettings.NetworkAuthenticationType, Converter={StaticResource ResourceKey=WiFiAuthenticationTypeToHumanReadableStringConverter}}"
303+
CommandParameter="{Binding Path=SelectedNetwork.NetworkAuthenticationType}"
310304
Style="{StaticResource ResourceKey=CopyMenuItem}" />
311305
<MenuItem Header="{x:Static Member=localization:Strings.Frequency}"
312306
Command="{Binding Path=CopyDataToClipboardCommand}"
313307
CommandParameter="{Binding Path=SelectedNetwork.ChannelCenterFrequencyInGigahertz, Converter={StaticResource ResourceKey=WiFiChannelCenterFrequencyToFrequencyStringConverter}}"
314308
Style="{StaticResource ResourceKey=CopyMenuItem}" />
315309
<MenuItem Header="{x:Static Member=localization:Strings.Channel}"
316310
Command="{Binding Path=CopyDataToClipboardCommand}"
317-
CommandParameter="{Binding Path=SelectedNetwork.Channel, Converter={StaticResource ResourceKey=WiFiChannelCenterFrequencyToChannelStringConverter}}"
311+
CommandParameter="{Binding Path=SelectedNetwork.Channel}"
318312
Style="{StaticResource ResourceKey=CopyMenuItem}" />
319313
<MenuItem
320314
Header="{x:Static Member=localization:Strings.SignalStrength}"
@@ -337,11 +331,11 @@
337331
Style="{StaticResource ResourceKey=CopyMenuItem}" />
338332
<MenuItem Header="{x:Static Member=localization:Strings.Vendor}"
339333
Command="{Binding Path=CopyDataToClipboardCommand}"
340-
CommandParameter="{Binding Path=SelectedNetwork.AvailableNetwork.Bssid, Converter={StaticResource ResourceKey=MACAddressToVendorConverter}}"
334+
CommandParameter="{Binding Path=SelectedNetwork.Vendor}"
341335
Style="{StaticResource ResourceKey=CopyMenuItem}" />
342336
<MenuItem Header="{x:Static Member=localization:Strings.PhyKind}"
343337
Command="{Binding Path=CopyDataToClipboardCommand}"
344-
CommandParameter="{Binding Path=SelectedNetwork.AvailableNetwork.PhyKind, Converter={StaticResource ResourceKey=WiFiPhyKindToStringConverter}}"
338+
CommandParameter="{Binding Path=SelectedNetwork.PhyKind}"
345339
Style="{StaticResource ResourceKey=CopyMenuItem}" />
346340
<MenuItem
347341
Header="{x:Static Member=localization:Strings.NetworkKind}"
@@ -569,15 +563,15 @@
569563
SortMemberPath="IsConnected" />
570564
<DataGridTextColumn
571565
Header="{x:Static Member=localization:Strings.Security}"
572-
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).SecuritySettings.NetworkAuthenticationType, Converter={StaticResource ResourceKey=WiFiAuthenticationTypeToHumanReadableStringConverter}}"
573-
SortMemberPath="AvailableNetwork.SecuritySettings.NetworkAuthenticationType" />
566+
Binding="{Binding Path=(network:WiFiNetworkInfo.NetworkAuthenticationType)}"
567+
SortMemberPath="NetworkAuthenticationType" />
574568
<DataGridTextColumn
575569
Header="{x:Static Member=localization:Strings.Frequency}"
576570
Binding="{Binding Path=(network:WiFiNetworkInfo.ChannelCenterFrequencyInGigahertz), Converter={StaticResource ResourceKey=WiFiChannelCenterFrequencyToFrequencyStringConverter}}"
577-
SortMemberPath="AvailableNetwork.ChannelCenterFrequencyInKilohertz" />
571+
SortMemberPath="ChannelCenterFrequencyInGigahertz" />
578572
<DataGridTextColumn Header="{x:Static Member=localization:Strings.Channel}"
579-
Binding="{Binding Path=(network:WiFiNetworkInfo.Channel), Converter={StaticResource ResourceKey=WiFiChannelCenterFrequencyToChannelStringConverter}}"
580-
SortMemberPath="AvailableNetwork.ChannelCenterFrequencyInKilohertz" />
573+
Binding="{Binding Path=(network:WiFiNetworkInfo.Channel)}"
574+
SortMemberPath="Channel" />
581575
<DataGridTextColumn
582576
Header="{x:Static Member=localization:Strings.SignalStrength}"
583577
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).NetworkRssiInDecibelMilliwatts, Converter={StaticResource ResourceKey=WiFiNetworkRssiInDecibelMilliwattsToSignalStrengthStringConverter}}"
@@ -594,11 +588,11 @@
594588
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).Bssid}"
595589
SortMemberPath="AvailableNetwork.Bssid" />
596590
<DataGridTextColumn Header="{x:Static Member=localization:Strings.Vendor}"
597-
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).Bssid, Converter={StaticResource ResourceKey=MACAddressToVendorConverter}}"
598-
SortMemberPath="AvailableNetwork.Bssid" />
591+
Binding="{Binding Path=(network:WiFiNetworkInfo.Vendor)}"
592+
SortMemberPath="Vendor" />
599593
<DataGridTextColumn Header="{x:Static Member=localization:Strings.PhyKind}"
600-
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).PhyKind, Converter={StaticResource ResourceKey=WiFiPhyKindToStringConverter}}"
601-
SortMemberPath="AvailableNetwork.PhyKind" />
594+
Binding="{Binding Path=(network:WiFiNetworkInfo.PhyKind)}"
595+
SortMemberPath="PhyKind" />
602596
<DataGridTextColumn
603597
Header="{x:Static Member=localization:Strings.NetworkKind}"
604598
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).NetworkKind}"

Website/docs/application/wifi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Right-click on a wireless network opens a context menu with the following option
1818
- **Disconnect**: Disconnect from the selected wireless network.
1919
- **Export...**: Opens a dialog to export the selected or all wireless network(s) to a file.
2020

21-
In the search field, you can filter the wireless networks by `SSID`, `Security`, `Channel`, `BSSID (MAC Address)`, `Vendor` and `Phy kind`. The search is case insensitive.
21+
In the search field, you can filter the wireless networks by `SSID`, `Security`, `Frequency`, `Channel`, `BSSID (MAC Address)`, `Vendor` and `Phy kind`. The search is case insensitive.
2222

2323
:::note
2424

Website/docs/changelog/next-release.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Release date: **xx.xx.2024**
2828

2929
## Improvements
3030

31+
- **WiFi**
32+
- Improve search, cleanup/remove some converters to make the code more readable and faster. [#2940](https://github.com/BornToBeRoot/NETworkManager/pull/2940)
33+
3134
## Bugfixes
3235

3336
- Changed the Welcome dialog from `MahApps.Metro.Controls.Dialogs` to `MahApps.Metro.SimpleChildWindow`, so the main window can be dragged and resized on the first start. [#2914](https://github.com/BornToBeRoot/NETworkManager/pull/2914)
@@ -37,6 +40,6 @@ Release date: **xx.xx.2024**
3740

3841
## Dependencies, Refactoring & Documentation
3942

40-
- Code cleanup & refactoring
43+
- Code cleanup & refactoring [#2940](https://github.com/BornToBeRoot/NETworkManager/pull/2940)
4144
- Language files updated via [#transifex](https://github.com/BornToBeRoot/NETworkManager/pulls?q=author%3Aapp%2Ftransifex-integration)
4245
- Dependencies updated via [#dependabot](https://github.com/BornToBeRoot/NETworkManager/pulls?q=author%3Aapp%2Fdependabot)

0 commit comments

Comments
 (0)