Skip to content

Commit

Permalink
fix first run check update
Browse files Browse the repository at this point in the history
  • Loading branch information
GangZhuo committed Mar 2, 2016
1 parent 0b59fcb commit 87ff1c1
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions shadowsocks-csharp/View/MenuViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,16 @@ public MenuViewController(ShadowsocksController controller)

Configuration config = controller.GetConfigurationCopy();

if (config.autoCheckUpdate)
{
_isStartupChecking = true;
updateChecker.CheckUpdate(config, 3000);
}

if (config.isDefault)
{
_isFirstRun = true;
ShowConfigForm();
}
else if(config.autoCheckUpdate)
{
_isStartupChecking = true;
updateChecker.CheckUpdate(config, 3000);
}
}

void controller_Errored(object sender, System.IO.ErrorEventArgs e)
Expand Down Expand Up @@ -261,13 +260,12 @@ void updateChecker_CheckUpdateCompleted(object sender, EventArgs e)
{
if (updateChecker.NewVersionFound)
{
Logging.Debug($"New version {updateChecker.LatestVersionNumber} found");
ShowBalloonTip(String.Format(I18N.GetString("Shadowsocks {0} Update Found"), updateChecker.LatestVersionNumber), I18N.GetString("Click here to update"), ToolTipIcon.Info, 5000);
_isFirstRun = false;
}
else if (!_isStartupChecking)
{
ShowBalloonTip(I18N.GetString("Shadowsocks"), I18N.GetString("No update is available"), ToolTipIcon.Info, 5000);
_isFirstRun = false;
}
_isStartupChecking = false;
}
Expand Down Expand Up @@ -389,7 +387,12 @@ void configForm_FormClosed(object sender, FormClosedEventArgs e)
{
configForm = null;
Utils.ReleaseMemory(true);
ShowFirstTimeBalloon();
if (_isFirstRun)
{
CheckUpdateForFirstRun();
ShowFirstTimeBalloon();
_isFirstRun = false;
}
}

private void Config_Click(object sender, EventArgs e)
Expand All @@ -404,18 +407,24 @@ private void Quit_Click(object sender, EventArgs e)
Application.Exit();
}

private void ShowFirstTimeBalloon()
private void CheckUpdateForFirstRun()
{
if (_isFirstRun)
Configuration config = controller.GetConfigurationCopy();
if (!config.isDefault)
{
_notifyIcon.BalloonTipTitle = I18N.GetString("Shadowsocks is here");
_notifyIcon.BalloonTipText = I18N.GetString("You can turn on/off Shadowsocks in the context menu");
_notifyIcon.BalloonTipIcon = ToolTipIcon.Info;
_notifyIcon.ShowBalloonTip(0);
_isFirstRun = false;
_isStartupChecking = true;
updateChecker.CheckUpdate(config, 3000);
}
}

private void ShowFirstTimeBalloon()
{
_notifyIcon.BalloonTipTitle = I18N.GetString("Shadowsocks is here");
_notifyIcon.BalloonTipText = I18N.GetString("You can turn on/off Shadowsocks in the context menu");
_notifyIcon.BalloonTipIcon = ToolTipIcon.Info;
_notifyIcon.ShowBalloonTip(0);
}

private void AboutItem_Click(object sender, EventArgs e)
{
Process.Start("https://github.com/shadowsocks/shadowsocks-windows");
Expand Down

0 comments on commit 87ff1c1

Please sign in to comment.