From 2fdb26c063450a4ec306cd49bb77c92b995b8b4f Mon Sep 17 00:00:00 2001 From: Jackson Ming Hu Date: Fri, 4 Sep 2015 11:59:23 +1000 Subject: [PATCH] Fix a tiny bug Sometimes the users may hit enter key by mistake, and the form will close without saving entries. --- shadowsocks-csharp/View/ConfigForm.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/shadowsocks-csharp/View/ConfigForm.cs b/shadowsocks-csharp/View/ConfigForm.cs index d7d5c1f3..dc290249 100755 --- a/shadowsocks-csharp/View/ConfigForm.cs +++ b/shadowsocks-csharp/View/ConfigForm.cs @@ -146,6 +146,28 @@ namespace Shadowsocks.View } + private void ConfigForm_KeyDown(object sender, KeyEventArgs e) + { + // Sometimes the users may hit enter key by mistake, and the form will close without saving entries. + + if (e.KeyCode == Keys.Enter) + { + Server server = controller.GetCurrentServer(); + if (!SaveOldSelectedServer()) + { + return; + } + if (_modifiedConfiguration.configs.Count == 0) + { + MessageBox.Show(I18N.GetString("Please add at least one server")); + return; + } + controller.SaveServers(_modifiedConfiguration.configs, _modifiedConfiguration.localPort); + controller.SelectServerIndex(_modifiedConfiguration.configs.IndexOf(server)); + } + + } + private void ServersListBox_SelectedIndexChanged(object sender, EventArgs e) { if (!ServersListBox.CanSelect)