Auto update

This commit is contained in:
Serge
2023-05-15 22:21:41 +02:00
parent 75c90ee155
commit df3324d641

View File

@@ -298,15 +298,22 @@ namespace GHelper
var gitVersion = new Version(tag); var gitVersion = new Version(tag);
var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString()); var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());
//appVersion = new Version("0.50.0.0"); appVersion = new Version("0.50.0.0");
int newer = gitVersion.CompareTo(appVersion); int newer = gitVersion.CompareTo(appVersion);
if (newer > 0) if (newer > 0)
{ {
SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, url); SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, url);
DialogResult dialogResult = MessageBox.Show(Properties.Strings.DownloadUpdate + ": G-Helper " + tag + "?", "Update", MessageBoxButtons.YesNo); if (Program.config.getConfigString("skip_version") != tag)
if (dialogResult == DialogResult.Yes) AutoUpdate(url); {
DialogResult dialogResult = MessageBox.Show(Properties.Strings.DownloadUpdate + ": G-Helper " + tag + "?", "Update", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
AutoUpdate(url);
else
Program.config.setConfig("skip_version", tag);
}
} }
else else
{ {
@@ -342,10 +349,11 @@ namespace GHelper
{ {
Uri uri = new Uri(requestUri); Uri uri = new Uri(requestUri);
string filename = Path.GetFileName(uri.LocalPath); string zipName = Path.GetFileName(uri.LocalPath);
string exeLocation = Application.ExecutablePath; string exeLocation = Application.ExecutablePath;
string exeDir = Path.GetDirectoryName(exeLocation); string exeDir = Path.GetDirectoryName(exeLocation);
string zipLocation = exeDir + "\\" + filename; string zipLocation = exeDir + "\\" + zipName;
using (WebClient client = new WebClient()) using (WebClient client = new WebClient())
{ {
@@ -370,10 +378,7 @@ namespace GHelper
private void LabelVersion_Click(object? sender, EventArgs e) private void LabelVersion_Click(object? sender, EventArgs e)
{ {
if (versionUrl.Contains(".zip")) Process.Start(new ProcessStartInfo(versionUrl) { UseShellExecute = true });
AutoUpdate(versionUrl);
else
Process.Start(new ProcessStartInfo(versionUrl) { UseShellExecute = true });
} }
private static void TrayIcon_MouseMove(object? sender, MouseEventArgs e) private static void TrayIcon_MouseMove(object? sender, MouseEventArgs e)