dirty reset when save and enter on password form

alphons <alphons@heijden.com> 31 Aug 2025, 22:59
fa0e53f08969b9171a82f7fda05b0b3a2884468b
3 files changed
  • src/WireGuardConfigGenerator/DataModel/Root.cs
  • src/WireGuardConfigGenerator/FormPassword.Designer.cs
  • src/WireGuardConfigGenerator/FormPassword.cs
diff --git a/src/WireGuardConfigGenerator/DataModel/Root.cs b/src/WireGuardConfigGenerator/DataModel/Root.cs
index 25b348e..d7f2ac2 100644
--- a/src/WireGuardConfigGenerator/DataModel/Root.cs
+++ b/src/WireGuardConfigGenerator/DataModel/Root.cs
@@ -14,9 +14,13 @@ public class Root
[JsonIgnore]
public bool IsDirty => HashLoaded != CryptoUtils.GeHash(this);
- public async Task SaveAsync(string path, string password) =>
+ public async Task SaveAsync(string path, string password)
+ {
await CryptoUtils.CompressAndEncryptToFileAsync(this, path, password);
+ HashLoaded = CryptoUtils.GeHash(this);
+ }
+
public async Task LoadAsync(string path, string password)
{
if (File.Exists(path))
@@ -26,7 +30,7 @@ public class Root
{
Groups = root.Groups;
- HashLoaded = CryptoUtils.GeHash(root);
+ HashLoaded = CryptoUtils.GeHash(this);
}
}
}
diff --git a/src/WireGuardConfigGenerator/FormPassword.Designer.cs b/src/WireGuardConfigGenerator/FormPassword.Designer.cs
index b6872ad..ef5932d 100644
--- a/src/WireGuardConfigGenerator/FormPassword.Designer.cs
+++ b/src/WireGuardConfigGenerator/FormPassword.Designer.cs
@@ -56,6 +56,7 @@
txtPassword.Size = new Size(142, 23);
txtPassword.TabIndex = 1;
txtPassword.TextChanged += Password_TextChanged;
+ txtPassword.KeyDown += txtPassword_KeyDown;
//
// btnOk
//
diff --git a/src/WireGuardConfigGenerator/FormPassword.cs b/src/WireGuardConfigGenerator/FormPassword.cs
index 43ffd27..01aeee1 100644
--- a/src/WireGuardConfigGenerator/FormPassword.cs
+++ b/src/WireGuardConfigGenerator/FormPassword.cs
@@ -47,4 +47,13 @@ public partial class FormPassword : Form
{
this.lblError.Text = string.Empty;
}
+
+ private void txtPassword_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Enter)
+ {
+ e.Handled = true;
+ Ok_Click(sender, e);
+ }
+ }
}