Little Update system and reworked versions
This commit is contained in:
parent
4a1ec5853b
commit
39e7733778
|
@ -15,7 +15,7 @@ namespace Discord_Media_Loader.Helper
|
||||||
{
|
{
|
||||||
internal static Version CurrentVersion => Assembly.GetExecutingAssembly().GetName().Version;
|
internal static Version CurrentVersion => Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
|
||||||
internal static async Task<Version> GetLatestReleaseVersion(string owner, string repository)
|
internal static async Task<Version> GetLatestReleaseVersion()
|
||||||
{
|
{
|
||||||
var github = new GitHubClient(new ProductHeaderValue("DiscordMediaLoader"));
|
var github = new GitHubClient(new ProductHeaderValue("DiscordMediaLoader"));
|
||||||
var tag =
|
var tag =
|
||||||
|
@ -23,5 +23,24 @@ namespace Discord_Media_Loader.Helper
|
||||||
var version = new Version(tag);
|
var version = new Version(tag);
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static async Task<string> DownloadLatestReleaseVersion()
|
||||||
|
{
|
||||||
|
return await DownloadReleaseVersion(await GetLatestReleaseVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static async Task<string> DownloadReleaseVersion(Version version)
|
||||||
|
{
|
||||||
|
var github = new GitHubClient(new ProductHeaderValue("DiscordMediaLoader"));
|
||||||
|
var releaseVersion = (from release in (await github.Repository.Release.GetAll("Serraniel", "DiscordMediaLoader")) where release.TagName == $"v{version.Major}.{version.Minor}.{version.Build}.{version.Revision}" select release).First();
|
||||||
|
//where release.TagName == $"v{version.Major}.{version.Minor}.{version.Revision}.{version.Build}"
|
||||||
|
/*var r = releases.ElementAt(0);
|
||||||
|
if (r.TagName == $"v{version.Major}.{version.Minor}.{version.Build}.{version.Revision}")
|
||||||
|
{
|
||||||
|
var releaseVersion = releases.First();
|
||||||
|
return releaseVersion.Url;
|
||||||
|
}*/
|
||||||
|
return releaseVersion.ZipballUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
23
Discord Media Loader/MainForm.Designer.cs
generated
23
Discord Media Loader/MainForm.Designer.cs
generated
|
@ -48,8 +48,7 @@
|
||||||
this.lbCopyright = new System.Windows.Forms.Label();
|
this.lbCopyright = new System.Windows.Forms.Label();
|
||||||
this.lbGithub = new System.Windows.Forms.LinkLabel();
|
this.lbGithub = new System.Windows.Forms.LinkLabel();
|
||||||
this.lbAbout = new System.Windows.Forms.LinkLabel();
|
this.lbAbout = new System.Windows.Forms.LinkLabel();
|
||||||
this.lbVersion = new System.Windows.Forms.Label();
|
this.lbVersion = new System.Windows.Forms.LinkLabel();
|
||||||
this.button1 = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nupThreadCount)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.nupThreadCount)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
@ -242,27 +241,18 @@
|
||||||
//
|
//
|
||||||
this.lbVersion.Location = new System.Drawing.Point(328, 274);
|
this.lbVersion.Location = new System.Drawing.Point(328, 274);
|
||||||
this.lbVersion.Name = "lbVersion";
|
this.lbVersion.Name = "lbVersion";
|
||||||
this.lbVersion.Size = new System.Drawing.Size(100, 13);
|
this.lbVersion.Size = new System.Drawing.Size(100, 15);
|
||||||
this.lbVersion.TabIndex = 25;
|
this.lbVersion.TabIndex = 26;
|
||||||
|
this.lbVersion.TabStop = true;
|
||||||
this.lbVersion.Text = "version";
|
this.lbVersion.Text = "version";
|
||||||
this.lbVersion.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
this.lbVersion.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||||
//
|
this.lbVersion.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lbVersion_LinkClicked);
|
||||||
// button1
|
|
||||||
//
|
|
||||||
this.button1.Location = new System.Drawing.Point(294, 256);
|
|
||||||
this.button1.Name = "button1";
|
|
||||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.button1.TabIndex = 26;
|
|
||||||
this.button1.Text = "button1";
|
|
||||||
this.button1.UseVisualStyleBackColor = true;
|
|
||||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
|
||||||
//
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(439, 296);
|
this.ClientSize = new System.Drawing.Size(439, 296);
|
||||||
this.Controls.Add(this.button1);
|
|
||||||
this.Controls.Add(this.lbVersion);
|
this.Controls.Add(this.lbVersion);
|
||||||
this.Controls.Add(this.lbAbout);
|
this.Controls.Add(this.lbAbout);
|
||||||
this.Controls.Add(this.lbGithub);
|
this.Controls.Add(this.lbGithub);
|
||||||
|
@ -317,7 +307,6 @@
|
||||||
private System.Windows.Forms.Label lbCopyright;
|
private System.Windows.Forms.Label lbCopyright;
|
||||||
private System.Windows.Forms.LinkLabel lbGithub;
|
private System.Windows.Forms.LinkLabel lbGithub;
|
||||||
private System.Windows.Forms.LinkLabel lbAbout;
|
private System.Windows.Forms.LinkLabel lbAbout;
|
||||||
private System.Windows.Forms.Label lbVersion;
|
private System.Windows.Forms.LinkLabel lbVersion;
|
||||||
private System.Windows.Forms.Button button1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -87,9 +87,9 @@ namespace Discord_Media_Loader
|
||||||
|
|
||||||
private async void MainForm_Shown(object sender, EventArgs e)
|
private async void MainForm_Shown(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
lbVersion.Text = $"v{Assembly.GetExecutingAssembly().GetName().Version}";
|
lbVersion.Text = $"v{VersionHelper.CurrentVersion}";
|
||||||
|
|
||||||
SetEnabled(false);
|
SetEnabled(false);
|
||||||
|
await CheckForUpdates();
|
||||||
|
|
||||||
if (!await Login())
|
if (!await Login())
|
||||||
{
|
{
|
||||||
|
@ -120,7 +120,6 @@ namespace Discord_Media_Loader
|
||||||
foreach (Control c in Controls)
|
foreach (Control c in Controls)
|
||||||
{
|
{
|
||||||
SetControlPropertyThreadSafe(c, "Enabled", enabled);
|
SetControlPropertyThreadSafe(c, "Enabled", enabled);
|
||||||
//c.Enabled = enabled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +259,7 @@ namespace Discord_Media_Loader
|
||||||
}
|
}
|
||||||
|
|
||||||
msgScanCount++;
|
msgScanCount++;
|
||||||
OnUpdateProgress(new UpdateProgessEventArgs() { Downloaded = downloadCount, Scanned = msgScanCount});
|
OnUpdateProgress(new UpdateProgessEventArgs() { Downloaded = downloadCount, Scanned = msgScanCount });
|
||||||
}
|
}
|
||||||
|
|
||||||
stop = stop || messages.Length < limit;
|
stop = stop || messages.Length < limit;
|
||||||
|
@ -289,9 +288,24 @@ namespace Discord_Media_Loader
|
||||||
MessageBox.Show(Properties.Resources.AboutString);
|
MessageBox.Show(Properties.Resources.AboutString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void button1_Click(object sender, EventArgs e)
|
private async Task CheckForUpdates(bool manually = false)
|
||||||
{
|
{
|
||||||
await VersionHelper.GetLatestReleaseVersion("Serraniel", "DiscordMediaLoader");
|
if (VersionHelper.CurrentVersion < await VersionHelper.GetLatestReleaseVersion())
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("A new version is available, do you want to update now?", "Update available", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Process.Start(await VersionHelper.DownloadLatestReleaseVersion());
|
||||||
|
}
|
||||||
|
else if (manually)
|
||||||
|
{
|
||||||
|
MessageBox.Show("You already use the newest version.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lbVersion_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||||
|
{
|
||||||
|
CheckForUpdates(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,7 @@ namespace Discord_Media_Loader
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
var v = VersionHelper.GetLatestReleaseVersion("Serraniel", "DiscordMediaLoader");
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new MainForm());
|
Application.Run(new MainForm());
|
||||||
|
|
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.1.1.78")]
|
[assembly: AssemblyVersion("0.1.98.0")]
|
||||||
[assembly: AssemblyFileVersion("0.1.1.78")]
|
[assembly: AssemblyFileVersion("0.1.98.0")]
|
||||||
|
|
Loading…
Reference in a new issue