mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Interim update checker commit
This commit is contained in:
parent
192305d57c
commit
7189210661
8 changed files with 24 additions and 22 deletions
|
@ -38,9 +38,11 @@ public class GitHubUpdateChecker
|
|||
{
|
||||
private const string APIURL = "https://api.github.com";
|
||||
|
||||
public IWebProxy Proxy { get; set; }
|
||||
public string Owner { get; set; }
|
||||
public string Repo { get; set; }
|
||||
public Version CurrentVersion { get; set; }
|
||||
public IWebProxy Proxy { get; set; }
|
||||
public UpdateInfo UpdateInfo { get; private set; }
|
||||
|
||||
public string ReleasesURL
|
||||
{
|
||||
|
@ -50,13 +52,14 @@ public string ReleasesURL
|
|||
}
|
||||
}
|
||||
|
||||
public GitHubUpdateChecker(string owner, string repo)
|
||||
public GitHubUpdateChecker(string owner, string repo, Version currentVersion)
|
||||
{
|
||||
Owner = owner;
|
||||
Repo = repo;
|
||||
CurrentVersion = currentVersion;
|
||||
}
|
||||
|
||||
public string CheckUpdate(Version currentVersion)
|
||||
public string CheckUpdate()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -69,7 +72,7 @@ public string CheckUpdate(Version currentVersion)
|
|||
if (latestRelease != null && !string.IsNullOrEmpty(latestRelease.tag_name) && latestRelease.tag_name[0] == 'v')
|
||||
{
|
||||
Version latestVersion = new Version(latestRelease.tag_name.Substring(1));
|
||||
bool isUpdateExist = Helpers.CheckVersion(latestVersion, currentVersion);
|
||||
bool isUpdateExist = Helpers.CheckVersion(latestVersion, CurrentVersion);
|
||||
|
||||
if (isUpdateExist)
|
||||
{
|
||||
|
@ -150,6 +153,6 @@ public class GitHubAsset
|
|||
public int size { get; set; }
|
||||
public int download_count { get; set; }
|
||||
public string created_at { get; set; }
|
||||
public string published_at { get; set; }
|
||||
public string updated_at { get; set; }
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace UpdateCheckerLib
|
||||
namespace HelpersLib
|
||||
{
|
||||
public class UpdateChecker
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace UpdateCheckerLib
|
||||
namespace HelpersLib
|
||||
{
|
||||
partial class UpdateCheckerLabel
|
||||
{
|
||||
|
|
|
@ -27,11 +27,11 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace UpdateCheckerLib
|
||||
namespace HelpersLib
|
||||
{
|
||||
public partial class UpdateCheckerLabel : UserControl
|
||||
{
|
||||
private UpdateChecker updateChecker;
|
||||
private GitHubUpdateChecker updateChecker;
|
||||
private bool isBusy;
|
||||
|
||||
public UpdateCheckerLabel()
|
||||
|
@ -39,7 +39,7 @@ public UpdateCheckerLabel()
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CheckUpdate(UpdateChecker updateChecker)
|
||||
public void CheckUpdate(GitHubUpdateChecker updateChecker)
|
||||
{
|
||||
this.updateChecker = updateChecker;
|
||||
|
||||
|
@ -78,11 +78,11 @@ private void UpdateControls()
|
|||
lblStatus.Visible = true;
|
||||
break;
|
||||
case UpdateStatus.UpdateRequired:
|
||||
llblUpdateAvailable.Text = "A newer version of " + updateChecker.ApplicationName + " is available";
|
||||
llblUpdateAvailable.Text = "A newer version of ShareX is available";
|
||||
llblUpdateAvailable.Visible = true;
|
||||
break;
|
||||
case UpdateStatus.UpToDate:
|
||||
lblStatus.Text = updateChecker.ApplicationName + " is up to date";
|
||||
lblStatus.Text = "ShareX is up to date";
|
||||
lblStatus.Visible = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace UpdateCheckerLib
|
||||
namespace HelpersLib
|
||||
{
|
||||
public class UpdateInfo
|
||||
{
|
||||
|
|
4
ShareX/Forms/AboutForm.Designer.cs
generated
4
ShareX/Forms/AboutForm.Designer.cs
generated
|
@ -49,7 +49,7 @@ private void InitializeComponent()
|
|||
this.pbDanaSteamURL = new System.Windows.Forms.PictureBox();
|
||||
this.rtbShareXInfo = new System.Windows.Forms.RichTextBox();
|
||||
this.cLogo = new HelpersLib.Canvas();
|
||||
this.uclUpdate = new UpdateCheckerLib.UpdateCheckerLabel();
|
||||
this.uclUpdate = new HelpersLib.UpdateCheckerLabel();
|
||||
this.lblOwners = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbTR)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbBerkURL)).BeginInit();
|
||||
|
@ -363,7 +363,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.PictureBox pbMikeURL;
|
||||
private System.Windows.Forms.PictureBox pbAU;
|
||||
private System.Windows.Forms.Label lblMike;
|
||||
private UpdateCheckerLib.UpdateCheckerLabel uclUpdate;
|
||||
private HelpersLib.Canvas cLogo;
|
||||
private System.Windows.Forms.PictureBox pbBerkSteamURL;
|
||||
private System.Windows.Forms.RichTextBox rtbCredits;
|
||||
|
@ -378,5 +377,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.PictureBox pbDanaSteamURL;
|
||||
private System.Windows.Forms.RichTextBox rtbShareXInfo;
|
||||
private System.Windows.Forms.Label lblOwners;
|
||||
private HelpersLib.UpdateCheckerLabel uclUpdate;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using UpdateCheckerLib;
|
||||
using UploadersLib;
|
||||
|
||||
namespace ShareX
|
||||
|
@ -44,9 +43,10 @@ public AboutForm()
|
|||
Text = Program.FullTitle;
|
||||
lblProductName.Text = Program.FullTitle;
|
||||
|
||||
UpdateChecker updateChecker = new UpdateChecker("", Application.ProductName, Program.AssemblyVersion,
|
||||
ReleaseChannelType.Stable, Uploader.ProxyInfo.GetWebProxy());
|
||||
uclUpdate.CheckUpdate(updateChecker);
|
||||
GitHubUpdateChecker updateChecker = new GitHubUpdateChecker("ShareX", "ShareX", Program.AssemblyVersion);
|
||||
updateChecker.Proxy = Uploader.ProxyInfo.GetWebProxy();
|
||||
|
||||
//uclUpdate.CheckUpdate(updateChecker);
|
||||
}
|
||||
|
||||
private void AboutForm_Shown(object sender, EventArgs e)
|
||||
|
|
|
@ -32,7 +32,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using UpdateCheckerLib;
|
||||
using UploadersLib;
|
||||
|
||||
namespace ShareX
|
||||
|
@ -404,9 +403,9 @@ private void UpdateUploaderMenuNames()
|
|||
|
||||
private void CheckUpdate()
|
||||
{
|
||||
GitHubUpdateChecker updateChecker = new GitHubUpdateChecker("ShareX", "ShareX");
|
||||
GitHubUpdateChecker updateChecker = new GitHubUpdateChecker("ShareX", "ShareX", Program.AssemblyVersion);
|
||||
updateChecker.Proxy = Uploader.ProxyInfo.GetWebProxy();
|
||||
string downloadURL = updateChecker.CheckUpdate(Program.AssemblyVersion);
|
||||
string downloadURL = updateChecker.CheckUpdate();
|
||||
|
||||
if (!string.IsNullOrEmpty(downloadURL) && MessageBox.Show("An update is available for ShareX.\r\nWould you like to download it?",
|
||||
"ShareX", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
|
||||
|
|
Loading…
Reference in a new issue