1
1
using System ;
2
- using System . Collections . Generic ;
3
- using System . ComponentModel ;
4
2
using System . Drawing ;
5
- using System . Text ;
6
3
using System . Windows . Forms ;
7
- using System . Diagnostics ;
8
- using Microsoft . Win32 ;
9
4
using Shadowsocks . Controller ;
10
5
using Shadowsocks . Model ;
11
6
using Shadowsocks . Properties ;
12
- using System . Threading . Tasks ;
13
7
14
8
namespace Shadowsocks . View
15
9
{
@@ -32,6 +26,7 @@ public ConfigForm(ShadowsocksController controller)
32
26
this . PerformLayout ( ) ;
33
27
34
28
UpdateTexts ( ) ;
29
+ SetupValueChangedListeners ( ) ;
35
30
this . Icon = Icon . FromHandle ( Resources . ssw128 . GetHicon ( ) ) ;
36
31
37
32
this . controller = controller ;
@@ -62,16 +57,37 @@ private void UpdateTexts()
62
57
ServerGroupBox . Text = I18N . GetString ( "Server" ) ;
63
58
OKButton . Text = I18N . GetString ( "OK" ) ;
64
59
MyCancelButton . Text = I18N . GetString ( "Cancel" ) ;
60
+ ApplyButton . Text = I18N . GetString ( "Apply" ) ;
65
61
MoveUpButton . Text = I18N . GetString ( "Move &Up" ) ;
66
62
MoveDownButton . Text = I18N . GetString ( "Move D&own" ) ;
67
63
this . Text = I18N . GetString ( "Edit Servers" ) ;
68
64
}
69
65
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
+
70
81
private void controller_ConfigChanged ( object sender , EventArgs e )
71
82
{
72
83
LoadCurrentConfiguration ( ) ;
73
84
}
74
85
86
+ private void ConfigValueChanged ( object sender , EventArgs e )
87
+ {
88
+ ApplyButton . Enabled = true ;
89
+ }
90
+
75
91
private bool ValidateAndSaveSelectedServerDetails ( )
76
92
{
77
93
try
@@ -186,6 +202,7 @@ private void LoadCurrentConfiguration()
186
202
LoadSelectedServerDetails ( ) ;
187
203
ProxyPortTextBox . Text = _modifiedConfiguration . localPort . ToString ( ) ;
188
204
PortableModeCheckBox . Checked = _modifiedConfiguration . portableMode ;
205
+ ApplyButton . Enabled = false ;
189
206
}
190
207
191
208
private bool SaveValidConfiguration ( )
@@ -308,6 +325,11 @@ private void CancelButton_Click(object sender, EventArgs e)
308
325
this . Close ( ) ;
309
326
}
310
327
328
+ private void ApplyButton_Click ( object sender , EventArgs e )
329
+ {
330
+ SaveValidConfiguration ( ) ;
331
+ }
332
+
311
333
private void ConfigForm_Shown ( object sender , EventArgs e )
312
334
{
313
335
IPTextBox . Focus ( ) ;
0 commit comments