Skip to content

Commit

Permalink
Versioning: Show indicator, if a new version is available
Browse files Browse the repository at this point in the history
  • Loading branch information
vipoo committed Apr 2, 2016
1 parent 96c2796 commit a3d345e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
13 changes: 10 additions & 3 deletions AboutBox1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// https://github.com/vipoo/iRacingReplayOverlay.net

using iRacingSDK.Support;
using System;
using System.Reflection;
using System.Windows.Forms;

Expand All @@ -30,14 +31,20 @@ public string AssemblyTitle
}
}

public static string AssemblyVersion
public static Version AssemblyVersionStamp
{
get
{
var assName = Assembly.GetExecutingAssembly().GetName();
var version = assName.Version;
return assName.Version;
}
}

return version.ToString();
public static string AssemblyVersion
{
get
{
return AssemblyVersionStamp.ToString();
}
}

Expand Down
22 changes: 19 additions & 3 deletions Main.Designer.cs

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

29 changes: 28 additions & 1 deletion Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with iRacingReplayOverlay. If not, see <http://www.gnu.org/licenses/>.

using GitHubReleases;
using iRacingReplayOverlay.Phases;
using iRacingReplayOverlay.Phases.Capturing;
using iRacingReplayOverlay.Support;
Expand Down Expand Up @@ -172,7 +173,7 @@ string GetDefaultLogFileName()
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "general.log");
}

void Main_Load(object sender, EventArgs e)
async void Main_Load(object sender, EventArgs e)
{
changeVersionButton.Visible = File.Exists(Settings.Default.MainExecPath);

Expand Down Expand Up @@ -211,6 +212,32 @@ void Main_Load(object sender, EventArgs e)
WaitingForIRacingLabel.Visible = false;
})
.InTheBackground(errorMessage => { });

try
{
var items = await GitHubAccess.GetVersions("vipoo", "iRacingReplayOverlay.net");

var currentVersionItem = items.FirstOrDefault(r => r.VersionStamp == AboutBox1.AssemblyVersion);
var isNewVersionAvailable = false;

if (currentVersionItem.VersionStamp == null)
isNewVersionAvailable = true;
else
{
var isPreRelease = currentVersionItem.Prerelease;

var latestVersion = items.OrderByDescending(r => new Version(r.VersionStamp)).Where(r => r.Prerelease == isPreRelease).First();
isNewVersionAvailable = new Version(latestVersion.VersionStamp) > AboutBox1.AssemblyVersionStamp;
}

if (isNewVersionAvailable)
newVersionMessage.Visible = true;
}
catch(Exception ee)
{
TraceError.WriteLine(ee.Message);
TraceError.WriteLine(ee.StackTrace);
}
}

void LogSystemInformation()
Expand Down

0 comments on commit a3d345e

Please sign in to comment.