Skip to content

Commit 390043a

Browse files
committed
View improved, Network authentication type added
1 parent 6cacef2 commit 390043a

9 files changed

Lines changed: 216 additions & 20 deletions

File tree

‎Source/NETworkManager/App.xaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<ResourceDictionary Source="/Resources/Styles/TextBlockStyles.xaml" />
4545
<ResourceDictionary Source="/Resources/Styles/TextBoxStyles.xaml" />
4646
<ResourceDictionary Source="/Resources/Styles/ToogleSwitchStyles.xaml" />
47+
<ResourceDictionary Source="/Resources/Styles/ToggleButtonStyles.xaml" />
4748
<ResourceDictionary Source="/Resources/Styles/ToolTipStyles.xaml" />
4849
<ResourceDictionary Source="/Resources/Styles/WindowStyles.xaml" />
4950
<!-- Dependent styles -->
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using NETworkManager.Models.Network;
2+
using System;
3+
using System.Globalization;
4+
using System.Windows.Data;
5+
using Windows.Networking.Connectivity;
6+
7+
namespace NETworkManager.Converters
8+
{
9+
public sealed class NetworkAuthenticationTypeToHumanReadableStringConverter : IValueConverter
10+
{
11+
/* Translate the name of the accent */
12+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13+
{
14+
if (!(value is NetworkAuthenticationType type))
15+
return "-/-";
16+
17+
return $"{WiFi.GetHumanReadableNetworkAuthenticationType(type)}";
18+
}
19+
20+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
21+
{
22+
throw new NotImplementedException();
23+
}
24+
}
25+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows.Data;
4+
5+
namespace NETworkManager.Converters
6+
{
7+
public sealed class TimeSpanToMillisecondConverter : IValueConverter
8+
{
9+
/* Translate the name of the accent */
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11+
{
12+
if (!(value is TimeSpan timeSpan))
13+
return "-/-";
14+
15+
16+
return $"{timeSpan.TotalMilliseconds} ms";
17+
}
18+
19+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20+
{
21+
throw new NotImplementedException();
22+
}
23+
}
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows.Data;
4+
5+
namespace NETworkManager.Converters
6+
{
7+
public sealed class TimeSpanToStringConverter : IValueConverter
8+
{
9+
/* Translate the name of the accent */
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11+
{
12+
if (!(value is TimeSpan timeSpan))
13+
return "-/-";
14+
15+
return $"{Math.Floor(timeSpan.TotalDays)}d {timeSpan.Hours}h {timeSpan.Minutes}m {timeSpan.Seconds}s";
16+
}
17+
18+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
19+
{
20+
throw new NotImplementedException();
21+
}
22+
}
23+
}

‎Source/NETworkManager/Models/Network/WiFi.cs‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Threading.Tasks;
55
using Windows.Devices.WiFi;
6+
using Windows.Networking.Connectivity;
67

78
//https://docs.microsoft.com/en-us/uwp/api/windows.devices.wifi.wifiadapter.requestaccessasync
89
//var access = await WiFiAdapter.RequestAccessAsync();
@@ -52,7 +53,8 @@ public static async Task<IEnumerable<WiFiNetworkInfo>> GetNetworksAsync(WiFiAdap
5253
NetworkRssiInDecibelMilliwatts = network.NetworkRssiInDecibelMilliwatts,
5354
PhyKind = network.PhyKind,
5455
NetworkKind = network.NetworkKind,
55-
Security = network.SecuritySettings,
56+
AuthenticationType = network.SecuritySettings.NetworkAuthenticationType,
57+
EncryptionType = network.SecuritySettings.NetworkEncryptionType,
5658
BeaconInterval = network.BeaconInterval,
5759
Uptime = network.Uptime
5860
});
@@ -174,5 +176,47 @@ public static double ConvertChannelFrequencyToGigahertz(int kilohertz)
174176
{
175177
return Convert.ToDouble(kilohertz) / 1000 / 1000;
176178
}
179+
180+
public static string GetHumanReadableNetworkAuthenticationType(NetworkAuthenticationType networkAuthenticationType)
181+
{
182+
string type = "-/-";
183+
184+
switch (networkAuthenticationType)
185+
{
186+
case NetworkAuthenticationType.Ihv:
187+
type = "-/-";
188+
break;
189+
case NetworkAuthenticationType.None:
190+
type = "-/-";
191+
break;
192+
case NetworkAuthenticationType.Open80211:
193+
type = "Open";
194+
break;
195+
case NetworkAuthenticationType.Rsna:
196+
type = "-/-";
197+
break;
198+
case NetworkAuthenticationType.RsnaPsk:
199+
type = "WPA2 PSK";
200+
break;
201+
case NetworkAuthenticationType.SharedKey80211:
202+
type = "-/-";
203+
break;
204+
case NetworkAuthenticationType.Unknown:
205+
type = "Unkown";
206+
break;
207+
case NetworkAuthenticationType.Wpa:
208+
type = "-/-";
209+
break;
210+
case NetworkAuthenticationType.WpaNone:
211+
type = "-/-";
212+
break;
213+
case NetworkAuthenticationType.WpaPsk:
214+
type = "WPA PSK";
215+
break;
216+
217+
}
218+
219+
return type;
220+
}
177221
}
178222
}

‎Source/NETworkManager/Models/Network/WiFiNetworkInfo.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
2727
public double NetworkRssiInDecibelMilliwatts { get; set; }
2828
public WiFiPhyKind PhyKind { get; set; }
2929
public WiFiNetworkKind NetworkKind { get; set; }
30-
public NetworkSecuritySettings Security { get; set; }
30+
public NetworkAuthenticationType AuthenticationType { get; set; }
31+
public NetworkEncryptionType EncryptionType { get; set; }
3132
public TimeSpan BeaconInterval { get; set; }
3233
public TimeSpan Uptime { get; set; }
3334
#endregion

‎Source/NETworkManager/NETworkManager.csproj‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@
205205
<Compile Include="Controls\PuTTYControl.xaml.cs">
206206
<DependentUpon>PuTTYControl.xaml</DependentUpon>
207207
</Compile>
208+
<Compile Include="Converters\NetworkAuthenticationTypeToHumanReadableStringConverter.cs" />
209+
<Compile Include="Converters\TimeSpanToStringConverter.cs" />
210+
<Compile Include="Converters\TimeSpanToMillisecondConverter.cs" />
208211
<Compile Include="Converters\BooleanToVisibilityHiddenConverter.cs" />
209212
<Compile Include="Converters\WiFiChannelFrequencyConverter.cs" />
210213
<Compile Include="Converters\ConnectionStateToRectangleStyleConverter.cs" />
@@ -593,6 +596,10 @@
593596
<Generator>MSBuild:Compile</Generator>
594597
<SubType>Designer</SubType>
595598
</Page>
599+
<Page Include="Resources\Styles\ToggleButtonStyles.xaml">
600+
<Generator>MSBuild:Compile</Generator>
601+
<SubType>Designer</SubType>
602+
</Page>
596603
<Page Include="Resources\Styles\DropDownButtonStyles.xaml">
597604
<Generator>MSBuild:Compile</Generator>
598605
<SubType>Designer</SubType>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
<Style x:Key="CleanToggleButton" TargetType="{x:Type ToggleButton}" >
4+
<Setter Property="Background" Value="Transparent" />
5+
<Setter Property="Template">
6+
<Setter.Value>
7+
<ControlTemplate TargetType="ToggleButton">
8+
<Grid Background="{TemplateBinding Background}">
9+
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
10+
</Grid>
11+
</ControlTemplate>
12+
</Setter.Value>
13+
</Setter>
14+
</Style>
15+
</ResourceDictionary>

0 commit comments

Comments
 (0)