Browse Source

add modify detector

Don't reload server if config not change.
pull/45/head
wzxjohn 10 years ago
parent
commit
aa5f9463d8
3 changed files with 8 additions and 3 deletions
  1. +7
    -1
      shadowsocks-csharp/Controller/ShadowsocksController.cs
  2. +0
    -1
      shadowsocks-csharp/View/ConfigForm.Designer.cs
  3. +1
    -1
      shadowsocks-csharp/View/ConfigForm.cs

+ 7
- 1
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -64,9 +64,10 @@ namespace Shadowsocks.Controller
return Configuration.Load();
}
public void SaveServers(List<Server> servers)
public void SaveServers(List<Server> servers, bool noChange)
{
_config.configs = servers;
_config.noChange = noChange;
SaveConfig(_config);
}
@@ -84,6 +85,7 @@ namespace Shadowsocks.Controller
public void ToggleShareOverLAN(bool enabled)
{
_config.shareOverLan = enabled;
_config.noChange = false;
SaveConfig(_config);
if (ShareOverLANStatusChanged != null)
{
@@ -133,6 +135,10 @@ namespace Shadowsocks.Controller
public void SaveConfig(Configuration newConfig)
{
Configuration.Save(newConfig);
if (newConfig.noChange)
{
return;
}
// some logic in configuration updated the config when saving, we need to read it again
_config = Configuration.Load();


+ 0
- 1
shadowsocks-csharp/View/ConfigForm.Designer.cs View File

@@ -418,7 +418,6 @@
this.ServersListBox.TabIndex = 5;
this.ServersListBox.SelectedIndexChanged += new System.EventHandler(this.ServersListBox_SelectedIndexChanged);
//
//
// ConfigForm
//
this.AcceptButton = this.OKButton;


+ 1
- 1
shadowsocks-csharp/View/ConfigForm.cs View File

@@ -301,7 +301,7 @@ namespace Shadowsocks.View
MessageBox.Show("Please add at least one server");
return;
}
controller.SaveConfig(_modifiedConfiguration);
controller.SaveServers(_modifiedConfiguration.configs, _modifiedConfiguration.noChange);
this.Hide();
ShowFirstTimeBalloon();
}


Loading…
Cancel
Save