remember password and show password
68398808915815de2e424bc61f7814cccb31844e
3 files changed
src/WireGuardConfigGenerator/Form1.cssrc/WireGuardConfigGenerator/FormPassword.Designer.cssrc/WireGuardConfigGenerator/FormPassword.cs
diff --git a/src/WireGuardConfigGenerator/Form1.cs b/src/WireGuardConfigGenerator/Form1.cs
index 8661634..2dc66b0 100644
--- a/src/WireGuardConfigGenerator/Form1.cs
+++ b/src/WireGuardConfigGenerator/Form1.cs
@@ -2,6 +2,7 @@ namespace WireGuardConfigGenerator;
public partial class Form1 : Form
{
+ private readonly FormPassword formPassword = new ();
public Form1()
{
InitializeComponent();
@@ -16,10 +17,8 @@ public partial class Form1 : Form
private async void OpenFile_Click(object sender, EventArgs e)
{
- var f = new FormPassword();
-
- if (f.ShowDialog(this) == DialogResult.OK)
- await this.userControlTree1.LoadAsync(f.Path, f.Password);
+ if (formPassword.ShowDialog(this) == DialogResult.OK)
+ await this.userControlTree1.LoadAsync(formPassword.Path, formPassword.Password);
}
private async void Form_FormClosing(object sender, FormClosingEventArgs e)
@@ -27,17 +26,14 @@ public partial class Form1 : Form
if (!this.userControlTree1.IsDirty)
return;
- var f = new FormPassword();
-
- if (f.ShowDialog(this) == DialogResult.OK)
- await this.userControlTree1.SaveAsync(f.Path, f.Password);
+ if (formPassword.ShowDialog(this) == DialogResult.OK)
+ await this.userControlTree1.SaveAsync(formPassword.Path, formPassword.Password);
}
private async void Save_Click(object sender, EventArgs e)
{
- var f = new FormPassword();
+ if (formPassword.ShowDialog(this) == DialogResult.OK)
+ await this.userControlTree1.SaveAsync(formPassword.Path, formPassword.Password);
- if (f.ShowDialog(this) == DialogResult.OK)
- await this.userControlTree1.SaveAsync(f.Path, f.Password);
}
}
diff --git a/src/WireGuardConfigGenerator/FormPassword.Designer.cs b/src/WireGuardConfigGenerator/FormPassword.Designer.cs
index ef5932d..32c83ed 100644
--- a/src/WireGuardConfigGenerator/FormPassword.Designer.cs
+++ b/src/WireGuardConfigGenerator/FormPassword.Designer.cs
@@ -37,6 +37,7 @@
openFileDialog1 = new OpenFileDialog();
btnCancel = new Button();
lblError = new Label();
+ button2 = new Button();
SuspendLayout();
//
// label1
@@ -118,11 +119,23 @@
lblError.Size = new Size(0, 15);
lblError.TabIndex = 8;
//
+ // button2
+ //
+ button2.Location = new Point(160, 81);
+ button2.Name = "button2";
+ button2.Size = new Size(28, 23);
+ button2.TabIndex = 9;
+ button2.Text = "👀";
+ button2.UseVisualStyleBackColor = true;
+ button2.MouseDown += Password_MouseDown;
+ button2.MouseUp += Password_MouseUp;
+ //
// FormPassword
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(488, 152);
+ Controls.Add(button2);
Controls.Add(lblError);
Controls.Add(btnCancel);
Controls.Add(button1);
@@ -153,5 +166,6 @@
private OpenFileDialog openFileDialog1;
private Button btnCancel;
private Label lblError;
+ private Button button2;
}
}
\ No newline at end of file
diff --git a/src/WireGuardConfigGenerator/FormPassword.cs b/src/WireGuardConfigGenerator/FormPassword.cs
index 01aeee1..bac5dc0 100644
--- a/src/WireGuardConfigGenerator/FormPassword.cs
+++ b/src/WireGuardConfigGenerator/FormPassword.cs
@@ -56,4 +56,14 @@ public partial class FormPassword : Form
Ok_Click(sender, e);
}
}
+
+ private void Password_MouseDown(object sender, MouseEventArgs e)
+ {
+ this.txtPassword.PasswordChar = '\0';
+ }
+
+ private void Password_MouseUp(object sender, MouseEventArgs e)
+ {
+ this.txtPassword.PasswordChar = '*';
+ }
}