From fff0d76b83fdbc247433031c537a797f1a53539e Mon Sep 17 00:00:00 2001 From: fyr77 Date: Tue, 18 Aug 2020 15:19:38 +0200 Subject: [PATCH] change version comparisons it is now possible to locally use newer application or driver versions without envyupdate yelling at you. --- EnvyUpdate/GlobalVars.cs | 2 +- EnvyUpdate/MainWindow.xaml.cs | 4 ++-- EnvyUpdate/Util.cs | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/EnvyUpdate/GlobalVars.cs b/EnvyUpdate/GlobalVars.cs index ac8de7f..402384c 100644 --- a/EnvyUpdate/GlobalVars.cs +++ b/EnvyUpdate/GlobalVars.cs @@ -9,7 +9,7 @@ namespace EnvyUpdate public static readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location; public static readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; public static readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); - public static readonly string version = "2.2"; + public static readonly float version = 2.3F; public static readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); public static readonly string desktopOverride = exepath + "desktop.envy"; diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs index ae45cde..fc7fb9c 100644 --- a/EnvyUpdate/MainWindow.xaml.cs +++ b/EnvyUpdate/MainWindow.xaml.cs @@ -51,7 +51,7 @@ namespace EnvyUpdate { try { - if (Util.GetNewVer() != GlobalVars.version) + if (Util.GetNewVer() > GlobalVars.version) { Util.UpdateApp(); } @@ -142,7 +142,7 @@ namespace EnvyUpdate textblockOnline.Text = onlineDriv; c.Dispose(); - if (localDriv != onlineDriv) + if (float.Parse(localDriv) < float.Parse(onlineDriv)) { textblockOnline.Foreground = Brushes.Red; buttonDL.Visibility = Visibility.Visible; diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index b60c006..6f2be10 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -103,7 +103,7 @@ namespace EnvyUpdate /// Checks for newest EnvyUpdate version. /// /// - public static string GetNewVer() + public static float GetNewVer() { // This will fetch the most recent version's tag on GitHub. string updPath = "https://api.github.com/repos/fyr77/envyupdate/releases/latest"; @@ -113,7 +113,10 @@ namespace EnvyUpdate wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko"); string webData = wc.DownloadString(updPath); dynamic data = JsonConvert.DeserializeObject(webData); - string version = data.tag_name; + + // I am not catching a possible parsing exception, because I cannot think of any way it could happen. + // If there is no internet connection, it should already throw when using the web client. + float version = float.Parse(data.tag_name); return version; }