Skip to content

Commit ecd59c8

Browse files
Stzxceleron533
authored andcommitted
Switch configuration enable button (shadowsocks#2460)
Fix shadowsocks/shadowsocks-windows/shadowsocks#2458
1 parent f1caff4 commit ecd59c8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

shadowsocks-csharp/View/ConfigForm.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public partial class ConfigForm : Form
1515
private Configuration _modifiedConfiguration;
1616
private int _lastSelectedIndex = -1;
1717

18+
private bool isChange = false;
19+
1820
public ConfigForm(ShadowsocksController controller)
1921
{
2022
Font = SystemFonts.MessageBoxFont;
@@ -85,6 +87,7 @@ private void Controller_ConfigChanged(object sender, EventArgs e)
8587

8688
private void ConfigValueChanged(object sender, EventArgs e)
8789
{
90+
isChange = true;
8891
ApplyButton.Enabled = true;
8992
}
9093

@@ -178,7 +181,7 @@ private bool GetServerDetailsFromUI(out Server server, bool isSave = false, bool
178181
if (result == DialogResult.OK)
179182
return null;
180183
}
181-
else if (ApplyButton.Enabled && !isSave && !isCopy)
184+
else if (isChange && !isSave && !isCopy)
182185
{
183186
var result = MessageBox.Show(I18N.GetString("Invalid server address, Cannot automatically save or discard changes"), I18N.GetString("Auto save failed"), MessageBoxButtons.OKCancel);
184187

@@ -216,7 +219,7 @@ private bool GetServerDetailsFromUI(out Server server, bool isSave = false, bool
216219
if (result == DialogResult.OK)
217220
return null;
218221
}
219-
else if (!isSave && !isCopy)
222+
else if (isChange && !isSave && !isCopy)
220223
{
221224
var result = MessageBox.Show(I18N.GetString("Illegal port number format, Cannot automatically save or discard changes"), I18N.GetString("Auto save failed"), MessageBoxButtons.OKCancel);
222225

@@ -255,7 +258,7 @@ private bool GetServerDetailsFromUI(out Server server, bool isSave = false, bool
255258
if (result == DialogResult.OK)
256259
return null;
257260
}
258-
else if (ApplyButton.Enabled && !isSave && !isCopy)
261+
else if (isChange && !isSave && !isCopy)
259262
{
260263
var result = MessageBox.Show(I18N.GetString("Password can not be blank, Cannot automatically save or discard changes"), I18N.GetString("Auto save failed"), MessageBoxButtons.OKCancel);
261264

@@ -293,7 +296,7 @@ private bool GetServerDetailsFromUI(out Server server, bool isSave = false, bool
293296
if (result == DialogResult.OK)
294297
return null;
295298
}
296-
else if (ApplyButton.Enabled && !isSave && !isCopy)
299+
else if (isChange && !isSave && !isCopy)
297300
{
298301
var result = MessageBox.Show(I18N.GetString("Illegal timeout format, Cannot automatically save or discard changes"), I18N.GetString("Auto save failed"), MessageBoxButtons.OKCancel);
299302

@@ -347,7 +350,7 @@ private void SetServerDetailsToUI(Server server)
347350
RemarksTextBox.Text = server.remarks;
348351
TimeoutTextBox.Text = server.timeout.ToString();
349352

350-
ApplyButton.Enabled = false;
353+
isChange = false;
351354
}
352355

353356
private void ShowHidePluginArgInput(bool show)

0 commit comments

Comments
 (0)