Skip to content

Commit

Permalink
fixed windows 7 build and added new release link icon
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallet committed Oct 13, 2018
1 parent f6fa69b commit 3387fcc
Show file tree
Hide file tree
Showing 15 changed files with 330 additions and 243 deletions.
6 changes: 2 additions & 4 deletions EspionSpotify/EspionSpotify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -293,6 +290,7 @@
<Content Include="libmp3lame.64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Resources\release.gif" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
23 changes: 19 additions & 4 deletions EspionSpotify/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using EspionSpotify.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace EspionSpotify.Extensions
{
public static class StringExtensions
{
private static Regex _regexVersion = new Regex(@"(\d+\.)(\d+\.)?(\d+\.)?(\*|\d+)");
private static Regex _regexTag = new Regex(@"[^0-9.]");

public static AlbumCoverSize? ConvertToAlbumCoverSize(this string value)
{
var types = typeof(AlbumCoverSize);
Expand All @@ -20,5 +20,20 @@ public static class StringExtensions

return (AlbumCoverSize) Enum.Parse(types, value, ignoreCase: true);
}

public static Version ToVersion(this string value)
{
var versionString = value.ToStringVersion();

if (string.IsNullOrEmpty(versionString) || !_regexVersion.IsMatch(versionString)) return null;

return new Version(value);
}

public static string ToStringVersion(this string tag)
{
return string.IsNullOrEmpty(tag) ? string.Empty : _regexTag.Replace(tag, string.Empty);
}

}
}
39 changes: 11 additions & 28 deletions EspionSpotify/GitHub.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using EspionSpotify.Models.GitHub;
using EspionSpotify.Extensions;
using EspionSpotify.Models.GitHub;
using EspionSpotify.Properties;
using Newtonsoft.Json;
using System;
Expand All @@ -15,11 +16,9 @@ namespace EspionSpotify
{
internal static class GitHub
{
private static Regex _regexVersion = new Regex(@"(\d+\.)(\d+\.)?(\d+\.)?(\*|\d+)");
private static Regex _regexTag = new Regex(@"[^0-9.]");
private const string _repoReleaseLink = "https://api.github.com/repos/jwallet/spy-spotify/releases/latest";

public static async void NewestVersion()
public static async void GetVersion()
{
if (!Uri.TryCreate(_repoReleaseLink, UriKind.Absolute, out var uri)) return;

Expand All @@ -43,15 +42,14 @@ public static async void NewestVersion()

var body = Encoding.UTF8.GetString(content.ToArray());
var release = JsonConvert.DeserializeObject<Release>(body);
var versionTag = ParseTagToVersionString(release.tag_name);
var githubTagVersion = release.tag_name.ToVersion();

if (!_regexVersion.IsMatch(versionTag)) return;
if (githubTagVersion == null) return;

var githubTagVersion = new Version(versionTag);
var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;

if (githubTagVersion <= assemblyVersion) return;
if (LastVersionPrompted() == assemblyVersion) return;
if (Settings.Default.LastVersionPrompted.ToVersion() == githubTagVersion) return;

var dialogTitle = string.Format(FrmEspionSpotify.Rm.GetString($"msgNewVersionTitle"), githubTagVersion);
var dialogMessage = FrmEspionSpotify.Rm.GetString($"msgNewVersionContent");
Expand All @@ -66,18 +64,16 @@ public static async void NewestVersion()
FrmEspionSpotify.Instance,
dialogMessage,
dialogTitle,
MessageBoxButtons.YesNoCancel,
MessageBoxButtons.OKCancel,
MessageBoxIcon.Question);

if (dialogResult == DialogResult.Yes)
if (dialogResult == DialogResult.OK)
{
Process.Start(new ProcessStartInfo(release.html_url));
}
else if (dialogResult == DialogResult.No)
{
Settings.Default.LastVersionPrompted = assemblyVersion.ToString();
Settings.Default.Save();
}

Settings.Default.LastVersionPrompted = githubTagVersion.ToString();
Settings.Default.Save();
}
}
catch (Exception ex)
Expand All @@ -86,18 +82,5 @@ public static async void NewestVersion()
Console.WriteLine(ex.Message);
}
}

private static Version LastVersionPrompted()
{
var lastVersionPromptedSaved = Settings.Default.LastVersionPrompted;
if (!_regexVersion.IsMatch(lastVersionPromptedSaved)) return null;

return new Version(lastVersionPromptedSaved);
}

private static string ParseTagToVersionString(string tag)
{
return string.IsNullOrEmpty(tag) ? string.Empty : _regexTag.Replace(tag, string.Empty);
}
}
}
16 changes: 8 additions & 8 deletions EspionSpotify/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("EspionSpotify")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("Spytify")]
[assembly: AssemblyDescription("github.com/jwallet")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCompany("jwallet")]
[assembly: AssemblyProduct("Spytify")]
[assembly: AssemblyCopyright("jwallet")]
[assembly: AssemblyTrademark("Spytify")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
Expand All @@ -31,5 +31,5 @@
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.4.0")]
[assembly: AssemblyFileVersion("1.1.4.0")]
[assembly: AssemblyVersion("1.1.2.1")]
[assembly: AssemblyFileVersion("1.1.2.1")]
10 changes: 10 additions & 0 deletions EspionSpotify/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions EspionSpotify/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,7 @@
<data name="record" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\record.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="release" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\release.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added EspionSpotify/Resources/release.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions EspionSpotify/english.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions EspionSpotify/english.resx
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,8 @@
<data name="logUnsupportedNumberChannels" xml:space="preserve">
<value>// Error while recording: Recording multi-channel files is not supported, reduce the number of channels to 2 (stereo) or 1 (mono).</value>
</data>
<data name="tipRelease" xml:space="preserve">
<value>New version available</value>
<comment>interface</comment>
</data>
</root>
4 changes: 4 additions & 0 deletions EspionSpotify/french.resx
Original file line number Diff line number Diff line change
Expand Up @@ -415,4 +415,8 @@
<data name="logUnsupportedNumberChannels" xml:space="preserve">
<value>// Erreur lors de l'enregistrement: L'enregistrement multi-canaux de fichiers n'est pas supporté, veuillez réduire le nombre de canaux à 2 (stéréo) ou 1 (mono).</value>
</data>
<data name="tipRelease" xml:space="preserve">
<value>Nouvelle version disponible</value>
<comment>interface</comment>
</data>
</root>
9 changes: 9 additions & 0 deletions EspionSpotify/french1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3387fcc

Please sign in to comment.