Skip to content

Commit aea690d

Browse files
committed
feat: Add apply button for server configuration form.
1 parent d4ae7b9 commit aea690d

File tree

5 files changed

+55
-13
lines changed

5 files changed

+55
-13
lines changed

shadowsocks-csharp/Data/ja.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Remarks=付記
6161
Timeout(Sec)=タイムアウト (秒)
6262
OK=OK
6363
Cancel=キャンセル
64+
Apply=適用
6465
New server=新規サーバー
6566
Move &Up=上に移動 (&U)
6667
Move D&own=下に移動 (&O)

shadowsocks-csharp/Data/zh_CN.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Remarks=备注
6262
Timeout(Sec)=超时(秒)
6363
OK=确定
6464
Cancel=取消
65+
Apply=应用
6566
New server=未配置的服务器
6667
Move &Up=上移(&U)
6768
Move D&own=下移(&O)

shadowsocks-csharp/Data/zh_TW.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Remarks=註解
6161
Timeout(Sec)=逾時 (秒)
6262
OK=確定
6363
Cancel=取消
64+
Apply=應用
6465
New server=新伺服器
6566
Move &Up=上移 (&U)
6667
Move D&own=下移 (&O)

shadowsocks-csharp/View/ConfigForm.Designer.cs

Lines changed: 24 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shadowsocks-csharp/View/ConfigForm.cs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
42
using System.Drawing;
5-
using System.Text;
63
using System.Windows.Forms;
7-
using System.Diagnostics;
8-
using Microsoft.Win32;
94
using Shadowsocks.Controller;
105
using Shadowsocks.Model;
116
using Shadowsocks.Properties;
12-
using System.Threading.Tasks;
137

148
namespace Shadowsocks.View
159
{
@@ -32,6 +26,7 @@ public ConfigForm(ShadowsocksController controller)
3226
this.PerformLayout();
3327

3428
UpdateTexts();
29+
SetupValueChangedListeners();
3530
this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon());
3631

3732
this.controller = controller;
@@ -62,16 +57,37 @@ private void UpdateTexts()
6257
ServerGroupBox.Text = I18N.GetString("Server");
6358
OKButton.Text = I18N.GetString("OK");
6459
MyCancelButton.Text = I18N.GetString("Cancel");
60+
ApplyButton.Text = I18N.GetString("Apply");
6561
MoveUpButton.Text = I18N.GetString("Move &Up");
6662
MoveDownButton.Text = I18N.GetString("Move D&own");
6763
this.Text = I18N.GetString("Edit Servers");
6864
}
6965

66+
private void SetupValueChangedListeners()
67+
{
68+
IPTextBox.TextChanged += ConfigValueChanged;
69+
ProxyPortTextBox.TextChanged += ConfigValueChanged;
70+
PasswordTextBox.TextChanged += ConfigValueChanged;
71+
EncryptionSelect.SelectedIndexChanged += ConfigValueChanged;
72+
PluginTextBox.TextChanged += ConfigValueChanged;
73+
PluginArgumentsTextBox.TextChanged += ConfigValueChanged;
74+
PluginOptionsTextBox.TextChanged += ConfigValueChanged;
75+
RemarksTextBox.TextChanged += ConfigValueChanged;
76+
TimeoutTextBox.TextChanged += ConfigValueChanged;
77+
PortableModeCheckBox.CheckedChanged += ConfigValueChanged;
78+
ServerPortTextBox.TextChanged += ConfigValueChanged;
79+
}
80+
7081
private void controller_ConfigChanged(object sender, EventArgs e)
7182
{
7283
LoadCurrentConfiguration();
7384
}
7485

86+
private void ConfigValueChanged(object sender, EventArgs e)
87+
{
88+
ApplyButton.Enabled = true;
89+
}
90+
7591
private bool ValidateAndSaveSelectedServerDetails()
7692
{
7793
try
@@ -186,6 +202,7 @@ private void LoadCurrentConfiguration()
186202
LoadSelectedServerDetails();
187203
ProxyPortTextBox.Text = _modifiedConfiguration.localPort.ToString();
188204
PortableModeCheckBox.Checked = _modifiedConfiguration.portableMode;
205+
ApplyButton.Enabled = false;
189206
}
190207

191208
private bool SaveValidConfiguration()
@@ -308,6 +325,11 @@ private void CancelButton_Click(object sender, EventArgs e)
308325
this.Close();
309326
}
310327

328+
private void ApplyButton_Click(object sender, EventArgs e)
329+
{
330+
SaveValidConfiguration();
331+
}
332+
311333
private void ConfigForm_Shown(object sender, EventArgs e)
312334
{
313335
IPTextBox.Focus();

0 commit comments

Comments
 (0)