Skip to content

Commit

Permalink
Switch configuration enable button (shadowsocks#2460)
Browse files Browse the repository at this point in the history
Fix shadowsocks/shadowsocks-windows/shadowsocks#2458
  • Loading branch information
Stzx authored and celeron533 committed Jul 14, 2019
1 parent f1caff4 commit ecd59c8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions shadowsocks-csharp/View/ConfigForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public partial class ConfigForm : Form
private Configuration _modifiedConfiguration;
private int _lastSelectedIndex = -1;

private bool isChange = false;

public ConfigForm(ShadowsocksController controller)
{
Font = SystemFonts.MessageBoxFont;
Expand Down Expand Up @@ -85,6 +87,7 @@ private void Controller_ConfigChanged(object sender, EventArgs e)

private void ConfigValueChanged(object sender, EventArgs e)
{
isChange = true;
ApplyButton.Enabled = true;
}

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

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

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

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

Expand Down Expand Up @@ -347,7 +350,7 @@ private void SetServerDetailsToUI(Server server)
RemarksTextBox.Text = server.remarks;
TimeoutTextBox.Text = server.timeout.ToString();

ApplyButton.Enabled = false;
isChange = false;
}

private void ShowHidePluginArgInput(bool show)
Expand Down

0 comments on commit ecd59c8

Please sign in to comment.