Skip to content

Commit

Permalink
Feature: WiFi - Improve search / remove converters (#2940)
Browse files Browse the repository at this point in the history
* Fix: Improve search / remove converters

* Docs: #2940

* Docs: #2940
  • Loading branch information
BornToBeRoot authored Nov 28, 2024
1 parent f016f8b commit 6823097
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 89 deletions.

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions Source/NETworkManager.Converters/WiFiPhyKindToStringConverter.cs

This file was deleted.

4 changes: 4 additions & 0 deletions Source/NETworkManager.Models/Network/WiFi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Windows.Devices.WiFi;
using Windows.Networking.Connectivity;
using Windows.Security.Credentials;
using NETworkManager.Models.Lookup;

namespace NETworkManager.Models.Network;

Expand Down Expand Up @@ -81,6 +82,9 @@ public static async Task<WiFiNetworkScanInfo> 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);
Expand Down
18 changes: 16 additions & 2 deletions Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public WiFiNetworkInfo()
/// <summary>
/// Radio that is used like 2.4 GHz, 5 GHz, etc.
/// </summary>
public WiFiRadio Radio { get; set; }
public WiFiRadio Radio { get; init; }

/// <summary>
/// The channel center frequency in Gigahertz.
/// The channel center frequency in Gigahertz like 2.4 GHz, 5 GHz, etc.
/// </summary>
public double ChannelCenterFrequencyInGigahertz { get; set; }

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

/// <summary>
/// Human-readable network authentication type.
/// </summary>
public string NetworkAuthenticationType { get; set; }

/// <summary>
/// Vendor of the Wi-Fi network like Cisco, Netgear, etc.
/// </summary>
public string Vendor { get; set; }

/// <summary>
/// Human-readable phy kind.
/// </summary>
public string PhyKind { get; set; }
#endregion
}
11 changes: 6 additions & 5 deletions Source/NETworkManager/ViewModels/WiFiViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public bool IsAdaptersLoading
}
}

private List<WiFiAdapterInfo> _adapters = new();
private List<WiFiAdapterInfo> _adapters = [];

public List<WiFiAdapterInfo> Adapters
{
Expand Down Expand Up @@ -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
Expand Down
32 changes: 13 additions & 19 deletions Source/NETworkManager/Views/WiFiView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,12 @@
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
<converters:IntNotZeroToVisibilityCollapsedConverter x:Key="IntNotZeroToVisibilityCollapsedConverter" />
<converters:IntZeroToVisibilityCollapsedConverter x:Key="IntZeroToVisibilityCollapsedConverter" />
<converters:MACAddressToVendorConverter x:Key="MACAddressToVendorConverter" />
<converters:TimeSpanToMillisecondConverter x:Key="TimeSpanToMillisecondConverter" />
<converters:TimeSpanToStringConverter x:Key="TimeSpanToStringConverter" />
<converters:WiFiAuthenticationTypeToHumanReadableStringConverter
x:Key="WiFiAuthenticationTypeToHumanReadableStringConverter" />
<converters:WiFiChannelCenterFrequencyToChannelStringConverter
x:Key="WiFiChannelCenterFrequencyToChannelStringConverter" />
<converters:WiFiChannelCenterFrequencyToFrequencyStringConverter
x:Key="WiFiChannelCenterFrequencyToFrequencyStringConverter" />
<converters:WiFiNetworkRssiInDecibelMilliwattsToSignalStrengthStringConverter
x:Key="WiFiNetworkRssiInDecibelMilliwattsToSignalStrengthStringConverter" />
<converters:WiFiPhyKindToStringConverter x:Key="WiFiPhyKindToStringConverter" />
</UserControl.Resources>
<Grid>
<Grid>
Expand Down Expand Up @@ -306,15 +300,15 @@
Style="{StaticResource ResourceKey=CopyMenuItem}" />
<MenuItem Header="{x:Static Member=localization:Strings.Security}"
Command="{Binding Path=CopyDataToClipboardCommand}"
CommandParameter="{Binding Path=SelectedNetwork.AvailableNetwork.SecuritySettings.NetworkAuthenticationType, Converter={StaticResource ResourceKey=WiFiAuthenticationTypeToHumanReadableStringConverter}}"
CommandParameter="{Binding Path=SelectedNetwork.NetworkAuthenticationType}"
Style="{StaticResource ResourceKey=CopyMenuItem}" />
<MenuItem Header="{x:Static Member=localization:Strings.Frequency}"
Command="{Binding Path=CopyDataToClipboardCommand}"
CommandParameter="{Binding Path=SelectedNetwork.ChannelCenterFrequencyInGigahertz, Converter={StaticResource ResourceKey=WiFiChannelCenterFrequencyToFrequencyStringConverter}}"
Style="{StaticResource ResourceKey=CopyMenuItem}" />
<MenuItem Header="{x:Static Member=localization:Strings.Channel}"
Command="{Binding Path=CopyDataToClipboardCommand}"
CommandParameter="{Binding Path=SelectedNetwork.Channel, Converter={StaticResource ResourceKey=WiFiChannelCenterFrequencyToChannelStringConverter}}"
CommandParameter="{Binding Path=SelectedNetwork.Channel}"
Style="{StaticResource ResourceKey=CopyMenuItem}" />
<MenuItem
Header="{x:Static Member=localization:Strings.SignalStrength}"
Expand All @@ -337,11 +331,11 @@
Style="{StaticResource ResourceKey=CopyMenuItem}" />
<MenuItem Header="{x:Static Member=localization:Strings.Vendor}"
Command="{Binding Path=CopyDataToClipboardCommand}"
CommandParameter="{Binding Path=SelectedNetwork.AvailableNetwork.Bssid, Converter={StaticResource ResourceKey=MACAddressToVendorConverter}}"
CommandParameter="{Binding Path=SelectedNetwork.Vendor}"
Style="{StaticResource ResourceKey=CopyMenuItem}" />
<MenuItem Header="{x:Static Member=localization:Strings.PhyKind}"
Command="{Binding Path=CopyDataToClipboardCommand}"
CommandParameter="{Binding Path=SelectedNetwork.AvailableNetwork.PhyKind, Converter={StaticResource ResourceKey=WiFiPhyKindToStringConverter}}"
CommandParameter="{Binding Path=SelectedNetwork.PhyKind}"
Style="{StaticResource ResourceKey=CopyMenuItem}" />
<MenuItem
Header="{x:Static Member=localization:Strings.NetworkKind}"
Expand Down Expand Up @@ -569,15 +563,15 @@
SortMemberPath="IsConnected" />
<DataGridTextColumn
Header="{x:Static Member=localization:Strings.Security}"
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).SecuritySettings.NetworkAuthenticationType, Converter={StaticResource ResourceKey=WiFiAuthenticationTypeToHumanReadableStringConverter}}"
SortMemberPath="AvailableNetwork.SecuritySettings.NetworkAuthenticationType" />
Binding="{Binding Path=(network:WiFiNetworkInfo.NetworkAuthenticationType)}"
SortMemberPath="NetworkAuthenticationType" />
<DataGridTextColumn
Header="{x:Static Member=localization:Strings.Frequency}"
Binding="{Binding Path=(network:WiFiNetworkInfo.ChannelCenterFrequencyInGigahertz), Converter={StaticResource ResourceKey=WiFiChannelCenterFrequencyToFrequencyStringConverter}}"
SortMemberPath="AvailableNetwork.ChannelCenterFrequencyInKilohertz" />
SortMemberPath="ChannelCenterFrequencyInGigahertz" />
<DataGridTextColumn Header="{x:Static Member=localization:Strings.Channel}"
Binding="{Binding Path=(network:WiFiNetworkInfo.Channel), Converter={StaticResource ResourceKey=WiFiChannelCenterFrequencyToChannelStringConverter}}"
SortMemberPath="AvailableNetwork.ChannelCenterFrequencyInKilohertz" />
Binding="{Binding Path=(network:WiFiNetworkInfo.Channel)}"
SortMemberPath="Channel" />
<DataGridTextColumn
Header="{x:Static Member=localization:Strings.SignalStrength}"
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).NetworkRssiInDecibelMilliwatts, Converter={StaticResource ResourceKey=WiFiNetworkRssiInDecibelMilliwattsToSignalStrengthStringConverter}}"
Expand All @@ -594,11 +588,11 @@
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).Bssid}"
SortMemberPath="AvailableNetwork.Bssid" />
<DataGridTextColumn Header="{x:Static Member=localization:Strings.Vendor}"
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).Bssid, Converter={StaticResource ResourceKey=MACAddressToVendorConverter}}"
SortMemberPath="AvailableNetwork.Bssid" />
Binding="{Binding Path=(network:WiFiNetworkInfo.Vendor)}"
SortMemberPath="Vendor" />
<DataGridTextColumn Header="{x:Static Member=localization:Strings.PhyKind}"
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).PhyKind, Converter={StaticResource ResourceKey=WiFiPhyKindToStringConverter}}"
SortMemberPath="AvailableNetwork.PhyKind" />
Binding="{Binding Path=(network:WiFiNetworkInfo.PhyKind)}"
SortMemberPath="PhyKind" />
<DataGridTextColumn
Header="{x:Static Member=localization:Strings.NetworkKind}"
Binding="{Binding Path=(network:WiFiNetworkInfo.AvailableNetwork).NetworkKind}"
Expand Down
2 changes: 1 addition & 1 deletion Website/docs/application/wifi.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Right-click on a wireless network opens a context menu with the following option
- **Disconnect**: Disconnect from the selected wireless network.
- **Export...**: Opens a dialog to export the selected or all wireless network(s) to a file.

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.
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.

:::note

Expand Down
5 changes: 4 additions & 1 deletion Website/docs/changelog/next-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Release date: **xx.xx.2024**

## Improvements

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

## Bugfixes

- 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)
Expand All @@ -37,6 +40,6 @@ Release date: **xx.xx.2024**

## Dependencies, Refactoring & Documentation

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

0 comments on commit 6823097

Please sign in to comment.