Browse Source

Check program is updated

tags/4.1.9.3
Student Main 5 years ago
parent
commit
79d8c41654
2 changed files with 37 additions and 1 deletions
  1. +8
    -0
      shadowsocks-csharp/Model/Configuration.cs
  2. +29
    -1
      shadowsocks-csharp/View/MenuViewController.cs

+ 8
- 0
shadowsocks-csharp/Model/Configuration.cs View File

@@ -37,6 +37,10 @@ namespace Shadowsocks.Model
public HotkeyConfig hotkey;
private static readonly string CONFIG_FILE = "gui-config.json";
[JsonIgnore]
public bool updated = false;
[JsonIgnore]
public string localHost => GetLocalHost();
private string GetLocalHost() {
@@ -78,6 +82,10 @@ namespace Shadowsocks.Model
string configContent = File.ReadAllText(CONFIG_FILE);
Configuration config = JsonConvert.DeserializeObject<Configuration>(configContent);
config.isDefault = false;
if (UpdateChecker.Asset.CompareVersion(UpdateChecker.Version, config.version) > 0)
{
config.updated = true;
}
if (config.configs == null)
config.configs = new List<Server>();


+ 29
- 1
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -30,6 +30,7 @@ namespace Shadowsocks.View
private bool _isFirstRun;
private bool _isStartupChecking;
private string _urlToOpen;
private bool _updated;
private ContextMenu contextMenu1;
private MenuItem disableItem;
@@ -113,6 +114,18 @@ namespace Shadowsocks.View
_isStartupChecking = true;
updateChecker.CheckUpdate(config, 3000);
}
if (config.updated)
{
ShowBalloonTip(
I18N.GetString("Updated"),
I18N.GetString("updated"),
ToolTipIcon.Info,
0
);
config.updated = false;
Configuration.Save(config);
}
}
private void controller_TrafficChanged(object sender, EventArgs e)
@@ -565,9 +578,24 @@ namespace Shadowsocks.View
if (_isFirstRun)
{
CheckUpdateForFirstRun();
ShowFirstTimeBalloon();
ShowBalloonTip(
I18N.GetString("Shadowsocks is here"),
I18N.GetString("You can turn on/off Shadowsocks in the context menu"),
ToolTipIcon.Info,
0
);
_isFirstRun = false;
}
if (_updated)
{
ShowBalloonTip(
I18N.GetString("Updated"),
I18N.GetString("updated"),
ToolTipIcon.Info,
0
);
_updated = false;
}
}
void proxyForm_FormClosed(object sender, FormClosedEventArgs e)


Loading…
Cancel
Save