From af9008b51aad8a4ebc9a024370d1595fc86deef9 Mon Sep 17 00:00:00 2001 From: Krzysztof Wieclaw Date: Wed, 8 Apr 2020 12:49:50 +0200 Subject: [PATCH] Add reveal button --- Oobe/OobeWifi/Controls/Wifi/AddNewNetworkPupup.cs | 45 +++++++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/Oobe/OobeWifi/Controls/Wifi/AddNewNetworkPupup.cs b/Oobe/OobeWifi/Controls/Wifi/AddNewNetworkPupup.cs index 4161cc9..cc09175 100644 --- a/Oobe/OobeWifi/Controls/Wifi/AddNewNetworkPupup.cs +++ b/Oobe/OobeWifi/Controls/Wifi/AddNewNetworkPupup.cs @@ -30,6 +30,7 @@ namespace Oobe.Wifi.Controls.Wifi TextField usernameTextField; TextLabel passwordLabel; PasswordEntry passwordEntry; + Button revealButton; Button cancelButton; Button addButton; TextLabel failureLabel; @@ -71,7 +72,7 @@ namespace Oobe.Wifi.Controls.Wifi TextField CreateTextField(Position2D position = null) { - position = position ?? new Position2D(); + position ??= new Position2D(); return new TextField { Position = position, @@ -87,7 +88,7 @@ namespace Oobe.Wifi.Controls.Wifi PasswordEntry CreatePasswordEntry(Position2D position = null) { - position = position ?? new Position2D(); + position ??= new Position2D(); return new PasswordEntry { Position = position, @@ -97,8 +98,25 @@ namespace Oobe.Wifi.Controls.Wifi FontStyle = new PropertyMap().AddRegularFontStyle(), TextColor = largeTextColor, HorizontalAlignment = HorizontalAlignment.Begin, - VerticalAlignment = VerticalAlignment.Center + VerticalAlignment = VerticalAlignment.Center, + Revealed = false + }; + } + + Button CreateRevealButton(Position2D position = null) + { + position ??= new Position2D(); + var button = new Button(ButtonStyles.Reveal) + { + Size = new Size(22, 13), + Position = position, + }; + button.ClickEvent += (s, e) => + { + this.passwordEntry.Revealed = !this.passwordEntry.Revealed; + button.IsSelected = !button.IsSelected; }; + return button; } void InitializeStaticElements() @@ -278,6 +296,12 @@ namespace Oobe.Wifi.Controls.Wifi passwordEntry = null; } + if(!(revealButton is null)) + { + revealButton.Unparent(); + revealButton = null; + } + currentViewMode = NewNetworkViewMode.NoPassword; } @@ -313,8 +337,15 @@ namespace Oobe.Wifi.Controls.Wifi this.Add(passwordEntry); } + if (revealButton is null) + { + revealButton = CreateRevealButton(); + this.Add(revealButton); + } + passwordLabel.Position = new Position2D(104, 208); passwordEntry.Position = new Position2D(121, 225); + revealButton.Position = new Position2D(704, 214); currentViewMode = NewNetworkViewMode.PasswordOnly; } @@ -351,10 +382,17 @@ namespace Oobe.Wifi.Controls.Wifi this.Add(passwordEntry); } + if (revealButton is null) + { + revealButton = CreateRevealButton(); + this.Add(revealButton); + } + usernameLabel.Position2D = new Position2D(104, 208); usernameTextField.Position2D = new Position2D(121, 225); passwordLabel.Position2D = new Position2D(104, 272); passwordEntry.Position2D = new Position2D(121, 289); + revealButton.Position = new Position2D(704, 278); currentViewMode = NewNetworkViewMode.UserPassword; } @@ -380,7 +418,6 @@ namespace Oobe.Wifi.Controls.Wifi } } - void ShowFailureSsidLabel() { failureLabel.Show(); -- 2.7.4