change version comparisons

it is now possible to locally use newer application or driver versions without envyupdate yelling at you.
This commit is contained in:
fyr77 2020-08-18 15:19:38 +02:00
parent b99a2ee8c9
commit fff0d76b83
3 changed files with 8 additions and 5 deletions

View file

@ -9,7 +9,7 @@ namespace EnvyUpdate
public static readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location; 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 exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\";
public static readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); 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 appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\";
public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
public static readonly string desktopOverride = exepath + "desktop.envy"; public static readonly string desktopOverride = exepath + "desktop.envy";

View file

@ -51,7 +51,7 @@ namespace EnvyUpdate
{ {
try try
{ {
if (Util.GetNewVer() != GlobalVars.version) if (Util.GetNewVer() > GlobalVars.version)
{ {
Util.UpdateApp(); Util.UpdateApp();
} }
@ -142,7 +142,7 @@ namespace EnvyUpdate
textblockOnline.Text = onlineDriv; textblockOnline.Text = onlineDriv;
c.Dispose(); c.Dispose();
if (localDriv != onlineDriv) if (float.Parse(localDriv) < float.Parse(onlineDriv))
{ {
textblockOnline.Foreground = Brushes.Red; textblockOnline.Foreground = Brushes.Red;
buttonDL.Visibility = Visibility.Visible; buttonDL.Visibility = Visibility.Visible;

View file

@ -103,7 +103,7 @@ namespace EnvyUpdate
/// Checks for newest EnvyUpdate version. /// Checks for newest EnvyUpdate version.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static string GetNewVer() public static float GetNewVer()
{ {
// This will fetch the most recent version's tag on GitHub. // This will fetch the most recent version's tag on GitHub.
string updPath = "https://api.github.com/repos/fyr77/envyupdate/releases/latest"; 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"); 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); string webData = wc.DownloadString(updPath);
dynamic data = JsonConvert.DeserializeObject(webData); 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; return version;
} }