Skip to content

Commit efc2f4c

Browse files
committed
Added Confidential Mode
1 parent 5d62a8f commit efc2f4c

14 files changed

Lines changed: 219 additions & 22 deletions

InternetTest/InternetTest/Components/ConnectWiFiItem.xaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@
4949
VerticalAlignment="Center"
5050
d:Text="WiFi Name"
5151
FontWeight="Bold"
52-
Text="{Binding Name}" />
52+
Text="{Binding Name}"
53+
Visibility="{Binding ConfidentialMode, Converter={StaticResource InverseBoolToVis}}" />
54+
<TextBlock
55+
Grid.Column="1"
56+
VerticalAlignment="Center"
57+
FontWeight="Bold"
58+
Text="•••••"
59+
Visibility="{Binding ConfidentialMode, Converter={StaticResource BoolToVis}}" />
5360
<StackPanel Grid.Column="2" Orientation="Horizontal">
5461
<Border
5562
Grid.Column="2"

InternetTest/InternetTest/Components/GridItem.xaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
x:Class="InternetTest.Components.GridItem"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:converters="clr-namespace:InternetTest.Converters"
56
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
67
xmlns:local="clr-namespace:InternetTest.Components"
78
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -11,13 +12,23 @@
1112
Foreground="{DynamicResource Foreground1}"
1213
mc:Ignorable="d">
1314
<StackPanel Margin="5">
15+
<StackPanel.Resources>
16+
<BooleanToVisibilityConverter x:Key="BoolToVis" />
17+
<converters:InverseBoolToVisibilityConverter x:Key="InverseBoolToVis" />
18+
</StackPanel.Resources>
1419
<TextBlock
1520
FontSize="12"
1621
Foreground="{DynamicResource DarkGray}"
1722
Text="{Binding Title}" />
1823
<TextBlock
1924
FontSize="14"
2025
FontWeight="SemiBold"
21-
Text="{Binding Value}" />
26+
Text="{Binding Value}"
27+
Visibility="{Binding ConfidentialMode, Converter={StaticResource InverseBoolToVis}}" />
28+
<TextBlock
29+
FontSize="14"
30+
FontWeight="SemiBold"
31+
Text="•••••"
32+
Visibility="{Binding ConfidentialMode, Converter={StaticResource BoolToVis}}" />
2233
</StackPanel>
2334
</UserControl>

InternetTest/InternetTest/Components/WlanProfileItem.xaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<Grid.Resources>
2525
<BooleanToVisibilityConverter x:Key="BoolToVis" />
2626
<converters:BoolToStringConverter x:Key="BoolToString" />
27+
<converters:InverseBoolToVisibilityConverter x:Key="InverseBoolToVis" />
2728
</Grid.Resources>
2829
<Grid.ColumnDefinitions>
2930
<ColumnDefinition Width="Auto" />
@@ -48,7 +49,14 @@
4849
VerticalAlignment="Center"
4950
d:Text="WiFi Name"
5051
FontWeight="Bold"
51-
Text="{Binding Name}" />
52+
Text="{Binding Name}"
53+
Visibility="{Binding ConfidentialMode, Converter={StaticResource InverseBoolToVis}}" />
54+
<TextBlock
55+
Grid.Column="1"
56+
VerticalAlignment="Center"
57+
FontWeight="Bold"
58+
Text="•••••"
59+
Visibility="{Binding ConfidentialMode, Converter={StaticResource BoolToVis}}" />
5260
<StackPanel Grid.Column="2" Orientation="Horizontal">
5361
<Button
5462
x:Name="GetQrBtn"

InternetTest/InternetTest/ViewModels/Components/ConnectWiFiItemViewModel.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ public class ConnectWiFiItemViewModel : ViewModelBase
4848
private bool _isConnected = false;
4949
public bool IsConnected { get => _isConnected; set { _isConnected = value; OnPropertyChanged(nameof(IsConnected)); } }
5050

51+
private bool _confidentialMode = false;
52+
public bool ConfidentialMode
53+
{
54+
get => _confidentialMode;
55+
set
56+
{
57+
_confidentialMode = value;
58+
OnPropertyChanged(nameof(ConfidentialMode));
59+
foreach (var item in Details)
60+
{
61+
item.ConfidentialMode = value;
62+
}
63+
}
64+
}
65+
5166
private string _password = "";
5267
public string Password { get => _password; set { _password = value; OnPropertyChanged(nameof(Password)); } }
5368

@@ -86,7 +101,7 @@ public ConnectWiFiItemViewModel(WiFiNetwork wiFiNetwork, string? currentSsid, Wi
86101

87102
Details = [
88103
new(Properties.Resources.SignalQuality, _wiFiNetwork.SignalQuality.ToString(), 0, 0),
89-
new(Properties.Resources.ProfileName, _wiFiNetwork.ProfileName ?? "", 0, 1),
104+
new(Properties.Resources.ProfileName, _wiFiNetwork.ProfileName ?? "", 0, 1, true),
90105
new(Properties.Resources.Interface, _wiFiNetwork.InterfaceDescription ?? "", 0, 2),
91106
new(Properties.Resources.BssType, _wiFiNetwork.BssType.ToString() ?? "", 1, 0),
92107
new(Properties.Resources.SecurityEnabled, _wiFiNetwork.IsSecurityEnabled ? Properties.Resources.Yes : Properties.Resources.No, 1, 1),

InternetTest/InternetTest/ViewModels/Components/GridItemViewModel.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,25 @@ public int GridRow
5353
set { _gridRow = value; OnPropertyChanged(nameof(GridRow)); }
5454
}
5555

56-
public GridItemViewModel(string title, string value, int row, int col)
56+
private bool _confidentialMode = false;
57+
public bool ConfidentialMode
58+
{
59+
get => _sensitive && _confidentialMode;
60+
set
61+
{
62+
_confidentialMode = value;
63+
OnPropertyChanged(nameof(ConfidentialMode));
64+
}
65+
}
66+
67+
private readonly bool _sensitive;
68+
69+
public GridItemViewModel(string title, string value, int row, int col, bool sensitive = false)
5770
{
5871
Title = title;
5972
Value = value;
6073
GridRow = row;
6174
GridColumn = col;
75+
_sensitive = sensitive;
6276
}
6377
}

InternetTest/InternetTest/ViewModels/Components/IpConfigItemViewModel.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ public class IpConfigItemViewModel : ViewModelBase
5151
private bool _isExpanded = false;
5252
public bool IsExpanded { get => _isExpanded; set { _isExpanded = value; OnPropertyChanged(nameof(IsExpanded)); } }
5353

54+
private bool _confidentialMode = false;
55+
public bool ConfidentialMode
56+
{
57+
get => _confidentialMode;
58+
set
59+
{
60+
_confidentialMode = value;
61+
OnPropertyChanged(nameof(ConfidentialMode));
62+
foreach (var item in Details)
63+
{
64+
item.ConfidentialMode = value;
65+
}
66+
IsExpanded = !value && IsExpanded;
67+
}
68+
}
69+
5470
private SolidColorBrush? _statusBrush;
5571
public SolidColorBrush? StatusBrush { get => _statusBrush; set { _statusBrush = value; OnPropertyChanged(nameof(StatusBrush)); } }
5672

@@ -89,12 +105,12 @@ public IpConfigItemViewModel(WindowsIpConfig ipConfig)
89105

90106
Details = [
91107
new (Properties.Resources.DNSSuffix, _ipConfig.DNSSuffix ?? Properties.Resources.Unknown, 0, 0),
92-
new (Properties.Resources.IPv4Address, _ipConfig.IPv4Address ?? Properties.Resources.Unknown, 1, 0),
93-
new (Properties.Resources.IPv6Address, _ipConfig.IPv6Address ?? Properties.Resources.Unknown, 0, 1),
94-
new (Properties.Resources.SubnetMask, _ipConfig.IPv4Mask ?? Properties.Resources.Unknown, 1, 1),
108+
new (Properties.Resources.IPv4Address, _ipConfig.IPv4Address ?? Properties.Resources.Unknown, 1, 0, true),
109+
new (Properties.Resources.IPv6Address, _ipConfig.IPv6Address ?? Properties.Resources.Unknown, 0, 1, true),
110+
new (Properties.Resources.SubnetMask, _ipConfig.IPv4Mask ?? Properties.Resources.Unknown, 1, 1, true),
95111
];
96112

97-
if (!string.IsNullOrEmpty(_ipConfig.IPv4Gateway)) Details.Add(new GridItemViewModel(Properties.Resources.GatewayIPv4, _ipConfig.IPv4Gateway, 2, 0));
98-
if (!string.IsNullOrEmpty(_ipConfig.IPv6Gateway)) Details.Add(new GridItemViewModel(Properties.Resources.GatewayIPv6, _ipConfig.IPv6Gateway, 2, 1));
113+
if (!string.IsNullOrEmpty(_ipConfig.IPv4Gateway)) Details.Add(new GridItemViewModel(Properties.Resources.GatewayIPv4, _ipConfig.IPv4Gateway, 2, 0, true));
114+
if (!string.IsNullOrEmpty(_ipConfig.IPv6Gateway)) Details.Add(new GridItemViewModel(Properties.Resources.GatewayIPv6, _ipConfig.IPv6Gateway, 2, 1, true));
99115
}
100116
}

InternetTest/InternetTest/ViewModels/Components/WlanProfileItemViewModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ public bool KeyVisible
5252
set
5353
{
5454
_keyVisible = value;
55-
Key = !value ? new string('*', _wlanProfile.MSM?.Security?.SharedKey?.KeyMaterial?.Length ?? 0) : _wlanProfile.MSM?.Security?.SharedKey?.KeyMaterial ?? Properties.Resources.Unknown;
55+
Key = !value ? new string('', _wlanProfile.MSM?.Security?.SharedKey?.KeyMaterial?.Length ?? 0) : _wlanProfile.MSM?.Security?.SharedKey?.KeyMaterial ?? Properties.Resources.Unknown;
5656
OnPropertyChanged(nameof(KeyVisible));
5757
}
5858
}
5959

6060
private bool _qrOpen = false;
6161
public bool QrOpen { get => _qrOpen; set { _qrOpen = value; OnPropertyChanged(nameof(QrOpen)); } }
6262

63+
private bool _confidentialMode = false;
64+
public bool ConfidentialMode { get => _confidentialMode; set { _confidentialMode = value; OnPropertyChanged(nameof(ConfidentialMode)); } }
65+
6366
private ImageSource? _qrCodeImage;
6467
public ImageSource? QrCodeImage { get => _qrCodeImage; set { _qrCodeImage = value; OnPropertyChanged(nameof(QrCodeImage)); } }
6568

InternetTest/InternetTest/ViewModels/HomePageViewModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public class HomePageViewModel : ViewModelBase, ISensitiveViewModel
7676
private SolidColorBrush? _statusColor;
7777
public SolidColorBrush? StatusColor { get => _statusColor; set { _statusColor = value; OnPropertyChanged(nameof(StatusColor)); } }
7878

79+
private bool _confidentialMode = false;
80+
public bool ConfidentialMode { get => _confidentialMode; set { _confidentialMode = value; OnPropertyChanged(nameof(ConfidentialMode)); } }
81+
7982
private readonly Settings _settings;
8083

8184
bool connected = true;
@@ -152,6 +155,6 @@ internal async void LoadStatusCard()
152155

153156
void ISensitiveViewModel.ToggleConfidentialMode(bool confidentialMode)
154157
{
155-
//TODO
158+
ConfidentialMode = confidentialMode;
156159
}
157160
}

InternetTest/InternetTest/ViewModels/IpConfigPageViewModel.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,32 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
*/
2424
using InternetTest.Commands;
25+
using InternetTest.Interfaces;
2526
using InternetTest.Models;
2627
using InternetTest.ViewModels.Components;
2728
using System.Net.NetworkInformation;
2829
using System.Windows.Input;
2930

3031
namespace InternetTest.ViewModels;
31-
public class IpConfigPageViewModel : ViewModelBase
32+
public class IpConfigPageViewModel : ViewModelBase, ISensitiveViewModel
3233
{
3334
private List<IpConfigItemViewModel> _ipConfigs = [];
3435
public List<IpConfigItemViewModel> IpConfigItems { get => _ipConfigs; set { _ipConfigs = value; OnPropertyChanged(nameof(IpConfigItems)); } }
3536

37+
private bool _confidentialMode = false;
38+
public bool ConfidentialMode
39+
{
40+
get => _confidentialMode; set
41+
{
42+
_confidentialMode = value;
43+
OnPropertyChanged(nameof(ConfidentialMode));
44+
foreach (var item in IpConfigItems)
45+
{
46+
item.ConfidentialMode = value;
47+
}
48+
}
49+
}
50+
3651
public ICommand RefreshCommand => new RelayCommand(o => LoadIpConfigs());
3752
public IpConfigPageViewModel()
3853
{
@@ -47,4 +62,9 @@ private void LoadIpConfigs()
4762
.Where(x => x != null)
4863
.Select(x => new IpConfigItemViewModel(x!))];
4964
}
65+
66+
void ISensitiveViewModel.ToggleConfidentialMode(bool confidentialMode)
67+
{
68+
ConfidentialMode = confidentialMode;
69+
}
5070
}

InternetTest/InternetTest/ViewModels/LocateIpPageViewModel.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
*/
2424
using InternetTest.Commands;
2525
using InternetTest.Enums;
26+
using InternetTest.Interfaces;
2627
using InternetTest.Models;
2728
using InternetTest.ViewModels.Components;
2829
using Microsoft.Win32;
@@ -33,7 +34,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3334
using System.Windows.Input;
3435

3536
namespace InternetTest.ViewModels;
36-
public class LocateIpPageViewModel : ViewModelBase
37+
public class LocateIpPageViewModel : ViewModelBase, ISensitiveViewModel
3738
{
3839
private readonly Settings _settings;
3940

@@ -46,9 +47,23 @@ public class LocateIpPageViewModel : ViewModelBase
4647
private string? _ipAddress;
4748
public string? IpAddress { get => _ipAddress; set { _ipAddress = value; OnPropertyChanged(nameof(IpAddress)); } }
4849

50+
private string _placeholderText = Properties.Resources.NothingToShow;
51+
public string PlaceholderText { get => _placeholderText; set { _placeholderText = value; OnPropertyChanged(nameof(PlaceholderText)); } }
52+
4953
private bool _empty = true;
5054
public bool Empty { get => _empty; set { _empty = value; OnPropertyChanged(nameof(Empty)); } }
5155

56+
private bool _confidentialMode = false;
57+
public bool ConfidentialMode
58+
{
59+
get => _confidentialMode; set
60+
{
61+
_confidentialMode = value;
62+
PlaceholderText = value ? Properties.Resources.DetailsNotAvailableCM : Properties.Resources.NothingToShow;
63+
OnPropertyChanged(nameof(ConfidentialMode));
64+
}
65+
}
66+
5267
private Ip? _ip;
5368

5469
public ICommand LocateIpCommand => new RelayCommand(async o => await GetIp());
@@ -125,7 +140,7 @@ private async Task GetIp()
125140
new (Properties.Resources.Proxy, (_ip.Proxy ?? false) ? Properties.Resources.Yes : Properties.Resources.No, 2, 1),
126141
];
127142

128-
Empty = false;
143+
if (!ConfidentialMode) Empty = false;
129144
}
130145

131146
private static string GetGoogleMapsPoint(double lat, double lon)
@@ -144,4 +159,10 @@ private static string GetGoogleMapsPoint(double lat, double lon)
144159

145160
return $"{deg}° {sD}' {fDir}, {deg2}° {sD2}' {sDir}".Replace("-", "");
146161
}
162+
163+
void ISensitiveViewModel.ToggleConfidentialMode(bool confidentialMode)
164+
{
165+
ConfidentialMode = confidentialMode;
166+
if (Details.Count > 0) Empty = confidentialMode;
167+
}
147168
}

0 commit comments

Comments
 (0)