From 1fb4427757fd4c40b65bc4c56012abc6074d2f66 Mon Sep 17 00:00:00 2001 From: fyr77 Date: Sat, 8 May 2021 11:57:16 +0200 Subject: [PATCH] remove overrides and leftover code --- EnvyUpdate/GlobalVars.cs | 2 -- EnvyUpdate/MainWindow.xaml.cs | 9 +----- EnvyUpdate/Util.cs | 54 +---------------------------------- 3 files changed, 2 insertions(+), 63 deletions(-) diff --git a/EnvyUpdate/GlobalVars.cs b/EnvyUpdate/GlobalVars.cs index 9804523..6cc8e8b 100644 --- a/EnvyUpdate/GlobalVars.cs +++ b/EnvyUpdate/GlobalVars.cs @@ -11,7 +11,5 @@ namespace EnvyUpdate public static readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); 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"; - public static readonly string mobileOverride = exepath + "mobile.envy"; } } diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs index 4df3f60..5731ac4 100644 --- a/EnvyUpdate/MainWindow.xaml.cs +++ b/EnvyUpdate/MainWindow.xaml.cs @@ -44,14 +44,7 @@ namespace EnvyUpdate // Delete installed legacy versions UninstallAll(); - // Check for overrides - if (File.Exists(GlobalVars.desktopOverride)) - GlobalVars.isMobile = false; - else if (File.Exists(GlobalVars.mobileOverride)) - GlobalVars.isMobile = true; - // Check if mobile, if no override is present - else - GlobalVars.isMobile = Util.IsMobile(); + GlobalVars.isMobile = Util.IsMobile(); string locDriv = Util.GetLocDriv(); if (locDriv != null) diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index 1404bf8..2c0676f 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -98,62 +98,10 @@ namespace EnvyUpdate Application.Current.MainWindow.Show(); Application.Current.MainWindow.WindowState = WindowState.Normal; } - /// - /// Checks for newest EnvyUpdate version. - /// - /// - 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"; - dynamic data = null; - - using (var wc = new WebClient()) - { - // Use some user agent to not get 403'd by GitHub. - wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0"); - string webData = wc.DownloadString(updPath); - data = JsonConvert.DeserializeObject(webData); - } - - // 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. - string tagver = data.tag_name; - float version = float.Parse(tagver); - - return version; - } /// - /// Updates the application by downloading the new version from Github and replacing the old file using a seperate CMD instance. + /// Deletes EnvyUpdate.exe by calling cmd /// - public static void UpdateApp() - { - string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; - - using (var client = new WebClient()) - { - client.DownloadFile("https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.exe", appdata + "EnvyUpdated.exe"); - } - - MessageBox.Show(Properties.Resources.message_new_version); - - // Replace exe with new one. - // This starts a seperate cmd process which will wait a bit, then delete EnvyUpdate and rename the previously downloaded EnvyUpdated.exe to EnvyUpdate.exe - // I know this is a bit dumb, but I honestly couldn't think of a different way to solve this properly, since the Application has to delete itself. - Process process = new Process(); - ProcessStartInfo startInfo = new ProcessStartInfo - { - WindowStyle = ProcessWindowStyle.Hidden, - WorkingDirectory = appdata, - FileName = "cmd.exe", - Arguments = "/C timeout 5 && del EnvyUpdate.exe && ren EnvyUpdated.exe EnvyUpdate.exe && EnvyUpdate.exe" - }; - process.StartInfo = startInfo; - process.Start(); - - Environment.Exit(2); - } public static void SelfDelete() { string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\";