ShareX will check for updates every hour

This commit is contained in:
Jaex 2015-01-03 16:06:32 +02:00
parent 13814e350e
commit a134dea59e
5 changed files with 34 additions and 20 deletions

View file

@ -30,6 +30,7 @@ public static class Links
public const string URL_WEBSITE = "http://getsharex.com"; public const string URL_WEBSITE = "http://getsharex.com";
public const string URL_PROJECT = "https://github.com/ShareX/ShareX"; public const string URL_PROJECT = "https://github.com/ShareX/ShareX";
public const string URL_ISSUES = URL_PROJECT + "/issues"; public const string URL_ISSUES = URL_PROJECT + "/issues";
public const string URL_UPDATE = URL_WEBSITE + "/Update.xml";
public const string URL_CALLBACK = URL_WEBSITE + "/callback/"; public const string URL_CALLBACK = URL_WEBSITE + "/callback/";
public const string URL_VERSION_HISTORY = URL_PROJECT + "/wiki/Changelog"; public const string URL_VERSION_HISTORY = URL_PROJECT + "/wiki/Changelog";
public const string URL_DONATE = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PCNWK2G6ZYJ2E"; public const string URL_DONATE = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PCNWK2G6ZYJ2E";

View file

@ -32,6 +32,8 @@ namespace ShareX.HelpersLib
{ {
public partial class UpdateMessageBox : Form public partial class UpdateMessageBox : Form
{ {
public static bool IsOpen { get; private set; }
private Rectangle fillRect; private Rectangle fillRect;
public UpdateMessageBox() public UpdateMessageBox()
@ -49,25 +51,34 @@ public static void Start(UpdateChecker updateChecker)
{ {
if (updateChecker != null && updateChecker.Status == UpdateStatus.UpdateAvailable) if (updateChecker != null && updateChecker.Status == UpdateStatus.UpdateAvailable)
{ {
DialogResult result; IsOpen = true;
using (UpdateMessageBox messageBox = new UpdateMessageBox()) try
{ {
result = messageBox.ShowDialog(); DialogResult result;
}
if (result == DialogResult.Yes) using (UpdateMessageBox messageBox = new UpdateMessageBox())
{
using (DownloaderForm updaterForm = new DownloaderForm(updateChecker))
{ {
updaterForm.ShowDialog(); result = messageBox.ShowDialog();
}
if (updaterForm.Status == DownloaderFormStatus.InstallStarted) if (result == DialogResult.Yes)
{
using (DownloaderForm updaterForm = new DownloaderForm(updateChecker))
{ {
Application.Exit(); updaterForm.ShowDialog();
if (updaterForm.Status == DownloaderFormStatus.InstallStarted)
{
Application.Exit();
}
} }
} }
} }
finally
{
IsOpen = false;
}
} }
} }

View file

@ -46,9 +46,9 @@ public AboutForm()
uclUpdate.CheckUpdate(TaskHelpers.CheckUpdate); uclUpdate.CheckUpdate(TaskHelpers.CheckUpdate);
rtbShareXInfo.Text = string.Format(@"{0}: http://getsharex.com rtbShareXInfo.Text = string.Format(@"{0}: {1}
{1}: https://github.com/ShareX/ShareX {2}: {3}
{2}: https://github.com/ShareX/ShareX/issues", Resources.AboutForm_AboutForm_Website, Resources.AboutForm_AboutForm_Project_page, Resources.AboutForm_AboutForm_Issues); {4}: {5}", Resources.AboutForm_AboutForm_Website, Links.URL_WEBSITE, Resources.AboutForm_AboutForm_Project_page, Links.URL_PROJECT, Resources.AboutForm_AboutForm_Issues, Links.URL_ISSUES);
rtbCredits.Text = string.Format(@"{0}: rtbCredits.Text = string.Format(@"{0}:

View file

@ -46,6 +46,7 @@ public partial class MainForm : HotkeyForm
private bool forceClose; private bool forceClose;
private UploadInfoManager uim; private UploadInfoManager uim;
private ToolStripDropDownItem tsmiImageFileUploaders, tsmiTrayImageFileUploaders, tsmiTextFileUploaders, tsmiTrayTextFileUploaders; private ToolStripDropDownItem tsmiImageFileUploaders, tsmiTrayImageFileUploaders, tsmiTextFileUploaders, tsmiTrayTextFileUploaders;
private System.Threading.Timer updateTimer;
public MainForm() public MainForm()
{ {
@ -650,18 +651,19 @@ private void UpdateUploaderMenuNames()
private void AutoCheckUpdate() private void AutoCheckUpdate()
{ {
if (Program.Settings.AutoCheckUpdate) if (Program.Settings.AutoCheckUpdate && updateTimer == null)
{ {
Thread updateThread = new Thread(CheckUpdate); updateTimer = new System.Threading.Timer(state => CheckUpdate(), null, 0, 1000 * 60 * 60);
updateThread.IsBackground = true;
updateThread.Start();
} }
} }
private void CheckUpdate() private void CheckUpdate()
{ {
UpdateChecker updateChecker = TaskHelpers.CheckUpdate(); if (!UpdateMessageBox.IsOpen)
UpdateMessageBox.Start(updateChecker); {
UpdateChecker updateChecker = TaskHelpers.CheckUpdate();
UpdateMessageBox.Start(updateChecker);
}
} }
private void ForceClose() private void ForceClose()

View file

@ -411,7 +411,7 @@ public static UpdateChecker CheckUpdate()
// Fallback if GitHub API fails // Fallback if GitHub API fails
if (updateChecker.Status == UpdateStatus.None || updateChecker.Status == UpdateStatus.UpdateCheckFailed) if (updateChecker.Status == UpdateStatus.None || updateChecker.Status == UpdateStatus.UpdateCheckFailed)
{ {
updateChecker = new XMLUpdateChecker("http://getsharex.com/Update.xml", "ShareX"); updateChecker = new XMLUpdateChecker(Links.URL_UPDATE, "ShareX");
updateChecker.IsBeta = Program.IsBeta; updateChecker.IsBeta = Program.IsBeta;
updateChecker.Proxy = ProxyInfo.Current.GetWebProxy(); updateChecker.Proxy = ProxyInfo.Current.GetWebProxy();
updateChecker.CheckUpdate(); updateChecker.CheckUpdate();