diff --git a/src/client/DCSInsight/DCSInsight.csproj b/src/client/DCSInsight/DCSInsight.csproj index 2edde4c..c8e05a4 100644 --- a/src/client/DCSInsight/DCSInsight.csproj +++ b/src/client/DCSInsight/DCSInsight.csproj @@ -6,7 +6,7 @@ true dcs-insight 1.0.0 - 1.8.0 + 1.7.0 Images\Magnifier_icon.ico @@ -25,6 +25,7 @@ + diff --git a/src/client/DCSInsight/DCSInsight.sln.DotSettings b/src/client/DCSInsight/DCSInsight.sln.DotSettings index 4901df7..d366ca5 100644 --- a/src/client/DCSInsight/DCSInsight.sln.DotSettings +++ b/src/client/DCSInsight/DCSInsight.sln.DotSettings @@ -11,4 +11,5 @@ True True True - True \ No newline at end of file + True + True \ No newline at end of file diff --git a/src/client/DCSInsight/MainWindow.xaml b/src/client/DCSInsight/MainWindow.xaml index 5825dea..f77021a 100644 --- a/src/client/DCSInsight/MainWindow.xaml +++ b/src/client/DCSInsight/MainWindow.xaml @@ -46,6 +46,9 @@ wiki + + check version + diff --git a/src/client/DCSInsight/MainWindow.xaml.cs b/src/client/DCSInsight/MainWindow.xaml.cs index c0bf74b..9c35302 100644 --- a/src/client/DCSInsight/MainWindow.xaml.cs +++ b/src/client/DCSInsight/MainWindow.xaml.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using DCSInsight.Events; @@ -19,6 +20,8 @@ using System.Windows.Media.Imaging; using DCSInsight.Communication; using DCSInsight.Windows; +using Octokit; +using ProductHeaderValue = System.Net.Http.Headers.ProductHeaderValue; namespace DCSInsight { @@ -530,5 +533,52 @@ private void UIElement_OnMouseLeave(object sender, MouseEventArgs e) { Mouse.OverrideCursor = Cursors.Arrow; } + + private async void TextBlockCheckNewVersion_OnMouseDown(object sender, MouseButtonEventArgs e) + { + try + { + await CheckForNewVersion(); + } + catch (Exception ex) + { + Common.ShowErrorMessageBox(ex); + } + } + + private async Task CheckForNewVersion() + { + var assembly = Assembly.GetExecutingAssembly(); + var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); + if (string.IsNullOrEmpty(fileVersionInfo.FileVersion)) return; + + var thisVersion = new Version(fileVersionInfo.FileVersion); + + try + { + var client = new GitHubClient(new Octokit.ProductHeaderValue("dcs-insight")); + var lastRelease = await client.Repository.Release.GetLatest("DCS-Skunkworks", "dcs-insight"); + var githubVersion = new Version(lastRelease.TagName.Replace("v.", "").Replace("v","")); + if (githubVersion.CompareTo(thisVersion) > 0) + { + if (MessageBox.Show(this, $"Newer version can be downloaded ({lastRelease.TagName}).\nGo to download page?", "New Version Available", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) + { + Process.Start(new ProcessStartInfo + { + FileName = "https://github.com/DCS-Skunkworks/dcs-insight/releases", + UseShellExecute = true + }); + } + } + else if (githubVersion.CompareTo(thisVersion) == 0) + { + MessageBox.Show(this, $"You have the latest version.", "", MessageBoxButton.OK, MessageBoxImage.Information); + } + } + catch (Exception ex) + { + Logger.Error(ex, "Error checking for newer releases."); + } + } } }