Browse Source

add modify detector

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

+ 8
- 2
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -57,7 +57,7 @@ namespace Shadowsocks.Controller
UpdateSystemProxy();
}
public Server GetCurrentServer()
{
return _config.GetCurrentServer();
@@ -69,9 +69,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);
}
@@ -89,6 +90,7 @@ namespace Shadowsocks.Controller
public void ToggleShareOverLAN(bool enabled)
{
_config.shareOverLan = enabled;
_config.noChange = false;
SaveConfig(_config);
if (ShareOverLANStatusChanged != null)
{
@@ -138,6 +140,10 @@ namespace Shadowsocks.Controller
protected 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

@@ -434,7 +434,6 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ConfigForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Edit Servers";


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

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


+ 2
- 2
shadowsocks-csharp/View/QRCodeForm.cs View File

@@ -24,12 +24,12 @@ namespace Shadowsocks.View
private void GenQR(string ssconfig)
{
string qrText = ssconfig;
string qrText = ssconfig;
QRCode4CS.Options options = new QRCode4CS.Options();
options.Text = qrText;
QRCode4CS.QRCode qrCoded = null;
bool success = false;
foreach (var level in new QRErrorCorrectLevel[]{QRErrorCorrectLevel.H, QRErrorCorrectLevel.Q, QRErrorCorrectLevel.M, QRErrorCorrectLevel.L})
foreach (var level in new QRErrorCorrectLevel[]{QRErrorCorrectLevel.H, QRErrorCorrectLevel.Q, QRErrorCorrectLevel.M, QRErrorCorrectLevel.L})
{
for (int i = 3; i < 10; i++)
{


Loading…
Cancel
Save