Merge branch 'develop'

* develop:
  Fixed UI Bug
  Little Update system and reworked versions
  Some experimental stuff
This commit is contained in:
Serraniel 2017-03-08 20:58:18 +01:00
commit 89de707eaf
8 changed files with 91 additions and 15 deletions

View file

@ -57,6 +57,10 @@
<HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Enlightenment.dll</HintPath> <HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Enlightenment.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Octokit, Version=0.24.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octokit.0.24.1-alpha0001\lib\net45\Octokit.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.105.2.3\lib\net46\RestSharp.dll</HintPath> <HintPath>..\packages\RestSharp.105.2.3\lib\net46\RestSharp.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -78,6 +82,7 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Helper\VersionHelper.cs" />
<Compile Include="LoginForm.cs"> <Compile Include="LoginForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

View file

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Octokit;
namespace Discord_Media_Loader.Helper
{
internal class VersionHelper
{
internal static Version CurrentVersion => Assembly.GetExecutingAssembly().GetName().Version;
internal static async Task<Version> GetLatestReleaseVersion()
{
var github = new GitHubClient(new ProductHeaderValue("DiscordMediaLoader"));
var tag =
(await github.Repository.Release.GetAll("Serraniel", "DiscordMediaLoader")).OrderBy(x => x.CreatedAt).First().TagName.Replace("v", "") ?? "";
var version = new Version(tag);
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;
}
}
}

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using Discord_Media_Loader.Helper;
namespace Discord_Media_Loader namespace Discord_Media_Loader
{ {

View file

@ -48,7 +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();
((System.ComponentModel.ISupportInitialize)(this.nupThreadCount)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nupThreadCount)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -122,9 +122,9 @@
// //
this.cbChannels.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbChannels.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbChannels.FormattingEnabled = true; this.cbChannels.FormattingEnabled = true;
this.cbChannels.Location = new System.Drawing.Point(264, 32); this.cbChannels.Location = new System.Drawing.Point(279, 32);
this.cbChannels.Name = "cbChannels"; this.cbChannels.Name = "cbChannels";
this.cbChannels.Size = new System.Drawing.Size(164, 21); this.cbChannels.Size = new System.Drawing.Size(149, 21);
this.cbChannels.TabIndex = 4; this.cbChannels.TabIndex = 4;
// //
// nupThreadCount // nupThreadCount
@ -144,9 +144,9 @@
this.lbChannel.AutoSize = true; this.lbChannel.AutoSize = true;
this.lbChannel.Location = new System.Drawing.Point(224, 38); this.lbChannel.Location = new System.Drawing.Point(224, 38);
this.lbChannel.Name = "lbChannel"; this.lbChannel.Name = "lbChannel";
this.lbChannel.Size = new System.Drawing.Size(34, 13); this.lbChannel.Size = new System.Drawing.Size(49, 13);
this.lbChannel.TabIndex = 3; this.lbChannel.TabIndex = 3;
this.lbChannel.Text = "Guild:"; this.lbChannel.Text = "Channel:";
// //
// lbScanCount // lbScanCount
// //
@ -241,10 +241,12 @@
// //
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);
// //
// MainForm // MainForm
// //
@ -305,6 +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;
} }
} }

View file

@ -9,6 +9,7 @@ using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Discord; using Discord;
using Discord.Net; using Discord.Net;
using Discord_Media_Loader.Helper;
using ConnectionState = Discord.ConnectionState; using ConnectionState = Discord.ConnectionState;
namespace Discord_Media_Loader namespace Discord_Media_Loader
@ -86,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())
{ {
@ -119,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;
} }
} }
@ -259,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;
@ -287,6 +287,26 @@ namespace Discord_Media_Loader
{ {
MessageBox.Show(Properties.Resources.AboutString); MessageBox.Show(Properties.Resources.AboutString);
} }
private async Task CheckForUpdates(bool manually = false)
{
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);
}
} }
internal class UpdateProgessEventArgs : EventArgs internal class UpdateProgessEventArgs : EventArgs

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using Discord_Media_Loader.Helper;
namespace Discord_Media_Loader namespace Discord_Media_Loader
{ {
@ -10,7 +11,7 @@ namespace Discord_Media_Loader
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() static void Main()
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm()); Application.Run(new MainForm());

View file

@ -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.58")] [assembly: AssemblyVersion("0.1.99.0")]
[assembly: AssemblyFileVersion("0.1.1.58")] [assembly: AssemblyFileVersion("0.1.99.0")]

View file

@ -3,6 +3,7 @@
<package id="Discord.Net" version="0.9.6" targetFramework="net461" /> <package id="Discord.Net" version="0.9.6" targetFramework="net461" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net461" /> <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net461" />
<package id="Nito.AsyncEx" version="3.0.1" targetFramework="net461" /> <package id="Nito.AsyncEx" version="3.0.1" targetFramework="net461" />
<package id="Octokit" version="0.24.1-alpha0001" targetFramework="net46" />
<package id="RestSharp" version="105.2.3" targetFramework="net461" /> <package id="RestSharp" version="105.2.3" targetFramework="net461" />
<package id="WebSocket4Net" version="0.14.1" targetFramework="net461" /> <package id="WebSocket4Net" version="0.14.1" targetFramework="net461" />
</packages> </packages>