From 95913d65ac69cde0294ae280fa08789246a4035a Mon Sep 17 00:00:00 2001 From: Jakob Date: Sat, 9 Nov 2019 19:28:10 +0100 Subject: [PATCH 001/193] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89c2799..c63af82 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## How to use - 1. Download the [latest release](https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.exe) (or as a [.zip](https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.zip)) and run it. Windows SmartScreen Messages can be safely ignored. They only happen because this project is not digitally signed. + 1. Download the latest release from the [releases page](https://github.com/fyr77/EnvyUpdate/releases) and run it. Windows SmartScreen Messages can be safely ignored. They only happen because this project is not digitally signed. 2. If you want to use the application without saving any settings to your drive, keep the "Portable mode" checkbox checked. Otherwise uncheck it to automatically save your configuration. 3. Install the cookie-txt addon for [Firefox](https://addons.mozilla.org/en-US/firefox/addon/cookies-txt-one-click/) or [Chrome](https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg). 4. Go to the [Nvidia driver download page](https://www.nvidia.com/Download/index.aspx), enter your graphics card model, operating system, etc. and click "Search". From 56ae58028e62f734dfb934cd6e9c7206a1f91f63 Mon Sep 17 00:00:00 2001 From: Jakob Date: Sat, 9 Nov 2019 19:31:49 +0100 Subject: [PATCH 002/193] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index c63af82..f1f31fd 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,9 @@ 6. Drag this .txt file into the corresponding space inside EnvyUpdate. 7. If everything works correctly, the online driver version should be displayed in the application window. 8. When not in portable mode, you may activate Autostart. This will make the application start everytime Windows boots. This will also install the application itself in your APPDATA folder. + +## Licenses + +This project: [MIT](https://github.com/fyr77/EnvyUpdate/blob/master/LICENSE) +Fody (for embedding DLLs into the main executable): [MIT](https://github.com/Fody/Fody/blob/master/License.txt) +wpf-notifyicon (for showing an icon in the system tray): [CPOL](https://github.com/hardcodet/wpf-notifyicon/blob/master/LICENSE) From ba690ec5d9cca34f18a38457c025cc198d9f7a79 Mon Sep 17 00:00:00 2001 From: Jakob Date: Sat, 9 Nov 2019 19:32:02 +0100 Subject: [PATCH 003/193] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f1f31fd..e4c3c20 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,6 @@ ## Licenses -This project: [MIT](https://github.com/fyr77/EnvyUpdate/blob/master/LICENSE) -Fody (for embedding DLLs into the main executable): [MIT](https://github.com/Fody/Fody/blob/master/License.txt) -wpf-notifyicon (for showing an icon in the system tray): [CPOL](https://github.com/hardcodet/wpf-notifyicon/blob/master/LICENSE) +* This project: [MIT](https://github.com/fyr77/EnvyUpdate/blob/master/LICENSE) +* Fody (for embedding DLLs into the main executable): [MIT](https://github.com/Fody/Fody/blob/master/License.txt) +* wpf-notifyicon (for showing an icon in the system tray): [CPOL](https://github.com/hardcodet/wpf-notifyicon/blob/master/LICENSE) From 802b2daaaf29d20c41afb71fc38608348d1373fa Mon Sep 17 00:00:00 2001 From: Jakob Date: Sat, 9 Nov 2019 19:48:21 +0100 Subject: [PATCH 004/193] add check if application is running --- EnvyUpdate/MainWindow.xaml.cs | 8 ++++++-- EnvyUpdate/Util.cs | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs index 99cd603..f0a9897 100644 --- a/EnvyUpdate/MainWindow.xaml.cs +++ b/EnvyUpdate/MainWindow.xaml.cs @@ -1,6 +1,5 @@ using System; using System.Windows; -using System.Windows.Shapes; using System.IO; using System.Net; using System.Text.RegularExpressions; @@ -26,6 +25,11 @@ namespace EnvyUpdate public MainWindow() { InitializeComponent(); + if (Util.IsProcessOpen("EnvyUpdate")) + { + MessageBox.Show("Application is already running."); + System.Environment.Exit(1); + } if (!Directory.Exists(appdata)) { Directory.CreateDirectory(appdata); @@ -39,7 +43,7 @@ namespace EnvyUpdate else { MessageBox.Show("No NVIDIA GPU found. Application will exit."); - System.Windows.Application.Current.Shutdown(); + System.Environment.Exit(255); } if (File.Exists(appdata + "nvidia-update.txt")) { diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index 3854fd3..0fa59b8 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -1,12 +1,9 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Management; -using System.Net; using System.IO; using IWshRuntimeLibrary; +using System.Diagnostics; namespace EnvyUpdate { @@ -86,5 +83,17 @@ namespace EnvyUpdate shortcut.TargetPath = targetFileLocation; shortcut.Save(); } + public static bool IsProcessOpen(string name) + { + foreach (Process clsProcess in Process.GetProcesses()) + { + if (clsProcess.ProcessName.Contains(name)) + { + return true; + } + } + + return false; + } } } From 187f7366ab66ba6a136aef77d0bdb1ddcb61ddcd Mon Sep 17 00:00:00 2001 From: Jakob Date: Fri, 29 Nov 2019 11:07:08 +0100 Subject: [PATCH 005/193] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e4c3c20..6568192 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,14 @@ 2. If you want to use the application without saving any settings to your drive, keep the "Portable mode" checkbox checked. Otherwise uncheck it to automatically save your configuration. 3. Install the cookie-txt addon for [Firefox](https://addons.mozilla.org/en-US/firefox/addon/cookies-txt-one-click/) or [Chrome](https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg). 4. Go to the [Nvidia driver download page](https://www.nvidia.com/Download/index.aspx), enter your graphics card model, operating system, etc. and click "Search". - 5. On the resulting page, use the previously installed cookie-txt addon to save your site cookies as a .txt file. + 5. On the resulting page, click back in your browser and use the previously installed cookie-txt addon to save your site cookies as a .txt file. 6. Drag this .txt file into the corresponding space inside EnvyUpdate. 7. If everything works correctly, the online driver version should be displayed in the application window. 8. When not in portable mode, you may activate Autostart. This will make the application start everytime Windows boots. This will also install the application itself in your APPDATA folder. + +## Uninstalling + +Simply download the latest release from the [releases page](https://github.com/fyr77/EnvyUpdate/releases), run it and untick "Autostart". This will remove EnvyUpdate from your system. ## Licenses From 1b16cb65ea0eff340fc1cb63abf54b9d744ecca4 Mon Sep 17 00:00:00 2001 From: Jakob Date: Sun, 29 Dec 2019 12:02:57 +0100 Subject: [PATCH 006/193] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 6568192..c9c3489 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,15 @@ Simply download the latest release from the [releases page](https://github.com/fyr77/EnvyUpdate/releases), run it and untick "Autostart". This will remove EnvyUpdate from your system. +## Compatibility + +The application is compatible with all Nvidia GPUs that have their drivers available on the nvidia.com download page. + +## Branches + +* The main `master` branch requires Windows 10 because of the way it sends notifications. +* The `compat` branch does not use notifications, opening the main window instead. This is compatible with Windows 7 and up. + ## Licenses * This project: [MIT](https://github.com/fyr77/EnvyUpdate/blob/master/LICENSE) From 44f9c1c91ed992d52ad99de6624f2bcbe17007f7 Mon Sep 17 00:00:00 2001 From: Jakob Date: Sun, 29 Dec 2019 21:41:57 +0100 Subject: [PATCH 007/193] inching towards 1.0 * update Fody * fix instance detection * add notification support --- EnvyUpdate/EnvyUpdate.csproj | 8 ++++++-- EnvyUpdate/MainWindow.xaml.cs | 26 ++++++++++---------------- EnvyUpdate/Notify.cs | 19 +++++++++++++++++++ EnvyUpdate/Util.cs | 16 +++++++++++++--- EnvyUpdate/packages.config | 3 ++- README.md | 8 ++------ 6 files changed, 52 insertions(+), 28 deletions(-) create mode 100644 EnvyUpdate/Notify.cs diff --git a/EnvyUpdate/EnvyUpdate.csproj b/EnvyUpdate/EnvyUpdate.csproj index 4a0ab73..edcf909 100644 --- a/EnvyUpdate/EnvyUpdate.csproj +++ b/EnvyUpdate/EnvyUpdate.csproj @@ -50,6 +50,9 @@ ..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll + + ..\packages\Notifications.Wpf.0.1.1\lib\net461\Notifications.Wpf.dll + @@ -71,6 +74,7 @@ MSBuild:Compile Designer + MSBuild:Compile @@ -130,12 +134,12 @@ - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + \ No newline at end of file diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs index f0a9897..4a5026b 100644 --- a/EnvyUpdate/MainWindow.xaml.cs +++ b/EnvyUpdate/MainWindow.xaml.cs @@ -25,10 +25,10 @@ namespace EnvyUpdate public MainWindow() { InitializeComponent(); - if (Util.IsProcessOpen("EnvyUpdate")) + if (Util.IsInstanceOpen("EnvyUpdate")) { MessageBox.Show("Application is already running."); - System.Environment.Exit(1); + Application.Current.Shutdown(1); } if (!Directory.Exists(appdata)) { @@ -43,7 +43,7 @@ namespace EnvyUpdate else { MessageBox.Show("No NVIDIA GPU found. Application will exit."); - System.Environment.Exit(255); + Application.Current.Shutdown(255); } if (File.Exists(appdata + "nvidia-update.txt")) { @@ -63,11 +63,6 @@ namespace EnvyUpdate private void Dt_Tick(object sender, EventArgs e) { Load(); - if (textblockOnline.Foreground == Brushes.Red) - { - Show(); - WindowState = WindowState.Normal; - } } private void buttonHelp_Click(object sender, RoutedEventArgs e) @@ -121,15 +116,14 @@ namespace EnvyUpdate { textblockOnline.Foreground = Brushes.Red; buttonDL.Visibility = Visibility.Visible; + Notify.ShowUpdatePopup(); } else - { textblockOnline.Foreground = Brushes.Green; - if (exepath == appdata) - { - WindowState = WindowState.Minimized; - Hide(); - } + if (exepath == appdata) + { + WindowState = WindowState.Minimized; + Hide(); } } private void Load(string[] files) @@ -180,8 +174,7 @@ namespace EnvyUpdate private void TaskbarIcon_TrayLeftMouseDown(object sender, RoutedEventArgs e) { - Show(); - WindowState = WindowState.Normal; + Util.ShowMain(); } private void Window_StateChanged(object sender, EventArgs e) @@ -234,6 +227,7 @@ namespace EnvyUpdate { var window = MessageBox.Show("Exit EnvyUpdate?", "", MessageBoxButton.YesNo); e.Cancel = (window == MessageBoxResult.No); + Application.Current.Shutdown(); } } } diff --git a/EnvyUpdate/Notify.cs b/EnvyUpdate/Notify.cs new file mode 100644 index 0000000..88e4643 --- /dev/null +++ b/EnvyUpdate/Notify.cs @@ -0,0 +1,19 @@ +using Notifications.Wpf; + +namespace EnvyUpdate +{ + class Notify + { + public static void ShowUpdatePopup() + { + var notificationManager = new NotificationManager(); + + notificationManager.Show(new NotificationContent + { + Title = "EnvyUpdate", + Message = "A new driver update is available for your graphics card. Click for more info.", + Type = NotificationType.Information + }, onClick: Util.ShowMain); + } + } +} diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index 0fa59b8..37bc68c 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -4,6 +4,7 @@ using System.Management; using System.IO; using IWshRuntimeLibrary; using System.Diagnostics; +using System.Windows; namespace EnvyUpdate { @@ -83,17 +84,26 @@ namespace EnvyUpdate shortcut.TargetPath = targetFileLocation; shortcut.Save(); } - public static bool IsProcessOpen(string name) + public static bool IsInstanceOpen(string name) { + int count = 0; foreach (Process clsProcess in Process.GetProcesses()) { if (clsProcess.ProcessName.Contains(name)) { - return true; + count++; } } - return false; + if (count > 1) + return true; + else + return false; + } + public static void ShowMain() + { + Application.Current.MainWindow.Show(); + Application.Current.MainWindow.WindowState = WindowState.Normal; } } } diff --git a/EnvyUpdate/packages.config b/EnvyUpdate/packages.config index 68a097f..1c2b0dd 100644 --- a/EnvyUpdate/packages.config +++ b/EnvyUpdate/packages.config @@ -1,6 +1,7 @@  - + + \ No newline at end of file diff --git a/README.md b/README.md index c9c3489..f385068 100644 --- a/README.md +++ b/README.md @@ -18,15 +18,11 @@ Simply download the latest release from the [releases page](https://github.com/f ## Compatibility -The application is compatible with all Nvidia GPUs that have their drivers available on the nvidia.com download page. - -## Branches - -* The main `master` branch requires Windows 10 because of the way it sends notifications. -* The `compat` branch does not use notifications, opening the main window instead. This is compatible with Windows 7 and up. +The application is compatible with all Nvidia GPUs that have their drivers available on the nvidia.com download page and runs on Windows 7 and up. ## Licenses * This project: [MIT](https://github.com/fyr77/EnvyUpdate/blob/master/LICENSE) * Fody (for embedding DLLs into the main executable): [MIT](https://github.com/Fody/Fody/blob/master/License.txt) * wpf-notifyicon (for showing an icon in the system tray): [CPOL](https://github.com/hardcodet/wpf-notifyicon/blob/master/LICENSE) +* Notifications.Wpf [MIT](https://github.com/Federerer/Notifications.Wpf/blob/master/LICENSE) From 75762bd44fb8734062f42a56f6f51b8997e48e98 Mon Sep 17 00:00:00 2001 From: Jakob Date: Mon, 30 Dec 2019 20:57:13 +0100 Subject: [PATCH 008/193] 1.0 baby! * add self-updater * fix error-exits * some cleanup Let's call this a stable release. --- EnvyUpdate/MainWindow.xaml.cs | 22 ++++++++++++++++---- EnvyUpdate/Notify.cs | 2 +- EnvyUpdate/Util.cs | 38 +++++++++++++++++++++++++++++++++++ res/version.txt | 1 + 4 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 res/version.txt diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs index 4a5026b..c8a2626 100644 --- a/EnvyUpdate/MainWindow.xaml.cs +++ b/EnvyUpdate/MainWindow.xaml.cs @@ -19,22 +19,36 @@ namespace EnvyUpdate readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); string gpuURL = null; readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location; - readonly string exepath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; + readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); + readonly string version = "1.0"; public MainWindow() { InitializeComponent(); + Title += " " + version; if (Util.IsInstanceOpen("EnvyUpdate")) { MessageBox.Show("Application is already running."); - Application.Current.Shutdown(1); + Environment.Exit(1); } if (!Directory.Exists(appdata)) { Directory.CreateDirectory(appdata); } + try + { + if (Util.GetNewVer() != version && exepath == appdata) + { + Util.UpdateApp(); + } + } + catch (WebException) + { + //Silently fail. + } + if (Util.GetLocDriv() != null) { localDriv = Util.GetLocDriv(); @@ -43,7 +57,7 @@ namespace EnvyUpdate else { MessageBox.Show("No NVIDIA GPU found. Application will exit."); - Application.Current.Shutdown(255); + Environment.Exit(255); } if (File.Exists(appdata + "nvidia-update.txt")) { @@ -116,7 +130,7 @@ namespace EnvyUpdate { textblockOnline.Foreground = Brushes.Red; buttonDL.Visibility = Visibility.Visible; - Notify.ShowUpdatePopup(); + Notify.ShowDrivUpdatePopup(); } else textblockOnline.Foreground = Brushes.Green; diff --git a/EnvyUpdate/Notify.cs b/EnvyUpdate/Notify.cs index 88e4643..4754310 100644 --- a/EnvyUpdate/Notify.cs +++ b/EnvyUpdate/Notify.cs @@ -4,7 +4,7 @@ namespace EnvyUpdate { class Notify { - public static void ShowUpdatePopup() + public static void ShowDrivUpdatePopup() { var notificationManager = new NotificationManager(); diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index 37bc68c..f4a1ba1 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -5,6 +5,7 @@ using System.IO; using IWshRuntimeLibrary; using System.Diagnostics; using System.Windows; +using System.Net; namespace EnvyUpdate { @@ -105,5 +106,42 @@ namespace EnvyUpdate Application.Current.MainWindow.Show(); Application.Current.MainWindow.WindowState = WindowState.Normal; } + public static string GetNewVer() + { + string updPath = "https://raw.githubusercontent.com/fyr77/EnvyUpdate/master/res/version.txt"; + + System.Net.WebClient wc = new System.Net.WebClient(); + string webData = wc.DownloadString(updPath); + + return webData; + } + /// + /// Updates the application by downloading the new version from Github and replacing the old file using a seperate CMD instance. + /// + 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("New version of EnvyUpdate found. Application will restart.\nThis will probably take a few seconds."); + + // Replace exe with new one + 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); + } } } diff --git a/res/version.txt b/res/version.txt new file mode 100644 index 0000000..d3827e7 --- /dev/null +++ b/res/version.txt @@ -0,0 +1 @@ +1.0 From 76ead731633d43529b7d027fa8e449a5af39e28f Mon Sep 17 00:00:00 2001 From: Jakob Date: Mon, 30 Dec 2019 21:06:47 +0100 Subject: [PATCH 009/193] fix updater i feel dumb --- EnvyUpdate/EnvyUpdate.csproj | 1 + EnvyUpdate/StringExt.cs | 17 +++++++++++++++++ EnvyUpdate/Util.cs | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 EnvyUpdate/StringExt.cs diff --git a/EnvyUpdate/EnvyUpdate.csproj b/EnvyUpdate/EnvyUpdate.csproj index edcf909..c773f85 100644 --- a/EnvyUpdate/EnvyUpdate.csproj +++ b/EnvyUpdate/EnvyUpdate.csproj @@ -75,6 +75,7 @@ Designer + MSBuild:Compile diff --git a/EnvyUpdate/StringExt.cs b/EnvyUpdate/StringExt.cs new file mode 100644 index 0000000..7f421b5 --- /dev/null +++ b/EnvyUpdate/StringExt.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EnvyUpdate +{ + public static class StringExt + { + public static string Truncate(this string value, int maxLength) + { + if (string.IsNullOrEmpty(value)) return value; + return value.Length <= maxLength ? value : value.Substring(0, maxLength); + } + } +} diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index f4a1ba1..9a10b15 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -111,7 +111,7 @@ namespace EnvyUpdate string updPath = "https://raw.githubusercontent.com/fyr77/EnvyUpdate/master/res/version.txt"; System.Net.WebClient wc = new System.Net.WebClient(); - string webData = wc.DownloadString(updPath); + string webData = wc.DownloadString(updPath).Truncate(3); return webData; } From bfa35c89fe127e218744536dd0aa73374ff8a61e Mon Sep 17 00:00:00 2001 From: Jakob Date: Mon, 30 Dec 2019 21:10:19 +0100 Subject: [PATCH 010/193] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index f385068..29d33c7 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,10 @@ Simply download the latest release from the [releases page](https://github.com/f The application is compatible with all Nvidia GPUs that have their drivers available on the nvidia.com download page and runs on Windows 7 and up. +## Planned features + +* Translation support + ## Licenses * This project: [MIT](https://github.com/fyr77/EnvyUpdate/blob/master/LICENSE) From 527e1b691dbda5d03f1a11bec9921b096aead6b3 Mon Sep 17 00:00:00 2001 From: Jakob Date: Mon, 30 Dec 2019 21:14:47 +0100 Subject: [PATCH 011/193] bump version --- EnvyUpdate/MainWindow.xaml.cs | 2 +- res/version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs index c8a2626..138a4b3 100644 --- a/EnvyUpdate/MainWindow.xaml.cs +++ b/EnvyUpdate/MainWindow.xaml.cs @@ -21,7 +21,7 @@ namespace EnvyUpdate readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location; readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); - readonly string version = "1.0"; + readonly string version = "1.1"; public MainWindow() { diff --git a/res/version.txt b/res/version.txt index d3827e7..9459d4b 100644 --- a/res/version.txt +++ b/res/version.txt @@ -1 +1 @@ -1.0 +1.1 From 1f29a05e8017b762bfd1104b5508a6b04f2fd3f8 Mon Sep 17 00:00:00 2001 From: Jakob Date: Mon, 30 Dec 2019 21:19:42 +0100 Subject: [PATCH 012/193] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 29d33c7..0e67e77 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## How to use - 1. Download the latest release from the [releases page](https://github.com/fyr77/EnvyUpdate/releases) and run it. Windows SmartScreen Messages can be safely ignored. They only happen because this project is not digitally signed. + 1. Download the [latest release](https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.exe) (or as a [.zip](https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.zip)) and run it. Windows SmartScreen Messages can be safely ignored. They only happen because this project is not digitally signed. 2. If you want to use the application without saving any settings to your drive, keep the "Portable mode" checkbox checked. Otherwise uncheck it to automatically save your configuration. 3. Install the cookie-txt addon for [Firefox](https://addons.mozilla.org/en-US/firefox/addon/cookies-txt-one-click/) or [Chrome](https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg). 4. Go to the [Nvidia driver download page](https://www.nvidia.com/Download/index.aspx), enter your graphics card model, operating system, etc. and click "Search". @@ -29,4 +29,4 @@ The application is compatible with all Nvidia GPUs that have their drivers avail * This project: [MIT](https://github.com/fyr77/EnvyUpdate/blob/master/LICENSE) * Fody (for embedding DLLs into the main executable): [MIT](https://github.com/Fody/Fody/blob/master/License.txt) * wpf-notifyicon (for showing an icon in the system tray): [CPOL](https://github.com/hardcodet/wpf-notifyicon/blob/master/LICENSE) -* Notifications.Wpf [MIT](https://github.com/Federerer/Notifications.Wpf/blob/master/LICENSE) +* Notifications.Wpf: [MIT](https://github.com/Federerer/Notifications.Wpf/blob/master/LICENSE) From b7ae273fa34d588ed0977e8f93d6a45b8bb07187 Mon Sep 17 00:00:00 2001 From: Jakob Date: Mon, 30 Dec 2019 21:21:22 +0100 Subject: [PATCH 013/193] optimise startup a bit --- EnvyUpdate/MainWindow.xaml.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs index 138a4b3..de69848 100644 --- a/EnvyUpdate/MainWindow.xaml.cs +++ b/EnvyUpdate/MainWindow.xaml.cs @@ -37,16 +37,19 @@ namespace EnvyUpdate Directory.CreateDirectory(appdata); } - try + if (exepath == appdata) { - if (Util.GetNewVer() != version && exepath == appdata) + try { - Util.UpdateApp(); + if (Util.GetNewVer() != version) + { + Util.UpdateApp(); + } + } + catch (WebException) + { + //Silently fail. } - } - catch (WebException) - { - //Silently fail. } if (Util.GetLocDriv() != null) From 2b523fa7d449b1ba9595aeeb656ccd5027a5e4ef Mon Sep 17 00:00:00 2001 From: fyr77 Date: Fri, 29 May 2020 11:21:03 +0200 Subject: [PATCH 014/193] cleanup code and update packages --- EnvyUpdate/EnvyUpdate.csproj | 4 ++-- EnvyUpdate/MainWindow.xaml.cs | 28 +++++++++++++++++----------- EnvyUpdate/Notify.cs | 4 ++-- EnvyUpdate/StringExt.cs | 10 ++-------- EnvyUpdate/Util.cs | 22 ++++++++++++++-------- EnvyUpdate/packages.config | 2 +- 6 files changed, 38 insertions(+), 32 deletions(-) diff --git a/EnvyUpdate/EnvyUpdate.csproj b/EnvyUpdate/EnvyUpdate.csproj index c773f85..d6075f6 100644 --- a/EnvyUpdate/EnvyUpdate.csproj +++ b/EnvyUpdate/EnvyUpdate.csproj @@ -140,7 +140,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs index de69848..bdccd02 100644 --- a/EnvyUpdate/MainWindow.xaml.cs +++ b/EnvyUpdate/MainWindow.xaml.cs @@ -1,8 +1,8 @@ using System; -using System.Windows; using System.IO; using System.Net; using System.Text.RegularExpressions; +using System.Windows; using System.Windows.Media; using System.Windows.Threading; @@ -13,20 +13,22 @@ namespace EnvyUpdate /// public partial class MainWindow : Window { - string localDriv = null; - string onlineDriv = null; - readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; - readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); - string gpuURL = null; - readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location; - readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; - readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); - readonly string version = "1.1"; + private string localDriv = null; + private string onlineDriv = null; + private readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; + private readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); + private string gpuURL = null; + private readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location; + private readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; + private readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); + private readonly string version = "1.1"; public MainWindow() { InitializeComponent(); Title += " " + version; + + // Check if EnvyUpdate is already running if (Util.IsInstanceOpen("EnvyUpdate")) { MessageBox.Show("Application is already running."); @@ -37,6 +39,7 @@ namespace EnvyUpdate Directory.CreateDirectory(appdata); } + // Check if application is in Autorun mode and update if (exepath == appdata) { try @@ -102,6 +105,7 @@ namespace EnvyUpdate } } } + private void Load() { FileInfo f = new FileInfo(appdata + "nvidia-update.txt"); @@ -143,6 +147,7 @@ namespace EnvyUpdate Hide(); } } + private void Load(string[] files) { FileInfo f = new FileInfo(files[0]); @@ -184,6 +189,7 @@ namespace EnvyUpdate else textblockOnline.Foreground = Brushes.Green; } + private void buttonDL_Click(object sender, RoutedEventArgs e) { System.Diagnostics.Process.Start(gpuURL); @@ -247,4 +253,4 @@ namespace EnvyUpdate Application.Current.Shutdown(); } } -} +} \ No newline at end of file diff --git a/EnvyUpdate/Notify.cs b/EnvyUpdate/Notify.cs index 4754310..a7c944c 100644 --- a/EnvyUpdate/Notify.cs +++ b/EnvyUpdate/Notify.cs @@ -2,7 +2,7 @@ namespace EnvyUpdate { - class Notify + internal class Notify { public static void ShowDrivUpdatePopup() { @@ -16,4 +16,4 @@ namespace EnvyUpdate }, onClick: Util.ShowMain); } } -} +} \ No newline at end of file diff --git a/EnvyUpdate/StringExt.cs b/EnvyUpdate/StringExt.cs index 7f421b5..fbcd4e0 100644 --- a/EnvyUpdate/StringExt.cs +++ b/EnvyUpdate/StringExt.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace EnvyUpdate +namespace EnvyUpdate { public static class StringExt { @@ -14,4 +8,4 @@ namespace EnvyUpdate return value.Length <= maxLength ? value : value.Substring(0, maxLength); } } -} +} \ No newline at end of file diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index 9a10b15..2edd933 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -1,15 +1,15 @@ -using System; +using IWshRuntimeLibrary; +using System; +using System.Diagnostics; +using System.IO; using System.Linq; using System.Management; -using System.IO; -using IWshRuntimeLibrary; -using System.Diagnostics; -using System.Windows; using System.Net; +using System.Windows; namespace EnvyUpdate { - class Util + internal class Util { /// /// Parses GPU info from a cookie file @@ -35,6 +35,7 @@ namespace EnvyUpdate int lastno = Convert.ToInt32(found.Split().Last()); return lastno; } + /// /// Gets local driver version. /// @@ -68,6 +69,7 @@ namespace EnvyUpdate return null; } } + /// /// Creates a standard Windows shortcut. /// @@ -85,6 +87,7 @@ namespace EnvyUpdate shortcut.TargetPath = targetFileLocation; shortcut.Save(); } + public static bool IsInstanceOpen(string name) { int count = 0; @@ -101,20 +104,23 @@ namespace EnvyUpdate else return false; } + public static void ShowMain() { Application.Current.MainWindow.Show(); Application.Current.MainWindow.WindowState = WindowState.Normal; } + public static string GetNewVer() { string updPath = "https://raw.githubusercontent.com/fyr77/EnvyUpdate/master/res/version.txt"; - System.Net.WebClient wc = new System.Net.WebClient(); + WebClient wc = new WebClient(); string webData = wc.DownloadString(updPath).Truncate(3); return webData; } + /// /// Updates the application by downloading the new version from Github and replacing the old file using a seperate CMD instance. /// @@ -144,4 +150,4 @@ namespace EnvyUpdate Environment.Exit(2); } } -} +} \ No newline at end of file diff --git a/EnvyUpdate/packages.config b/EnvyUpdate/packages.config index 1c2b0dd..9ed1b0a 100644 --- a/EnvyUpdate/packages.config +++ b/EnvyUpdate/packages.config @@ -1,7 +1,7 @@  - + \ No newline at end of file From 9cc8e8869823bd50afee6b6f6cdb014a85072fc8 Mon Sep 17 00:00:00 2001 From: Jakob Date: Tue, 14 Jul 2020 14:32:47 +0200 Subject: [PATCH 015/193] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0e67e77..2047392 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # EnvyUpdate A small update checker application for Nvidia GPUs + ![License](https://img.shields.io/github/license/fyr77/envyupdate?style=for-the-badge) + ![Issues](https://img.shields.io/github/issues/fyr77/envyupdate?style=for-the-badge) + ![Version](https://img.shields.io/github/v/release/fyr77/envyupdate?style=for-the-badge) + ## How to use 1. Download the [latest release](https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.exe) (or as a [.zip](https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.zip)) and run it. Windows SmartScreen Messages can be safely ignored. They only happen because this project is not digitally signed. From 5c7831b855338b2db96035154ef98555f05bbbd9 Mon Sep 17 00:00:00 2001 From: fyr77 Date: Tue, 14 Jul 2020 15:31:32 +0200 Subject: [PATCH 016/193] add debug feature, update icon, add licenses, bump version --- EnvyUpdate/EnvyUpdate.csproj | 7 +++++ EnvyUpdate/InfoWindow.xaml | 19 +++++++++++++ EnvyUpdate/InfoWindow.xaml.cs | 51 ++++++++++++++++++++++++++++++++++ EnvyUpdate/MainWindow.xaml.cs | 26 ++++++++++++----- EnvyUpdate/icon.ico | Bin 101917 -> 106671 bytes EnvyUpdate/icon.png | Bin 6516 -> 14489 bytes README.md | 1 + res/version.txt | 2 +- 8 files changed, 98 insertions(+), 8 deletions(-) create mode 100644 EnvyUpdate/InfoWindow.xaml create mode 100644 EnvyUpdate/InfoWindow.xaml.cs diff --git a/EnvyUpdate/EnvyUpdate.csproj b/EnvyUpdate/EnvyUpdate.csproj index d6075f6..28d1867 100644 --- a/EnvyUpdate/EnvyUpdate.csproj +++ b/EnvyUpdate/EnvyUpdate.csproj @@ -74,9 +74,16 @@ MSBuild:Compile Designer + + InfoWindow.xaml + + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/EnvyUpdate/InfoWindow.xaml b/EnvyUpdate/InfoWindow.xaml new file mode 100644 index 0000000..86ce504 --- /dev/null +++ b/EnvyUpdate/InfoWindow.xaml @@ -0,0 +1,19 @@ + + + public partial class InfoWindow : Window { + bool defaultIsMobile = false; + bool isOverride = false; public InfoWindow() { InitializeComponent(); + + if (GlobalVars.isMobile) + chkMobile.IsChecked = true; + + if (Util.IsMobile()) + defaultIsMobile = true; + + if (defaultIsMobile != GlobalVars.isMobile) + isOverride = true; } - private void Button_Click(object sender, RoutedEventArgs e) + private void ButtonWeb_Click(object sender, RoutedEventArgs e) { System.Diagnostics.Process.Start("https://github.com/fyr77/EnvyUpdate/"); } @@ -56,5 +69,62 @@ namespace EnvyUpdate { System.Diagnostics.Process.Start("https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md"); } + + private void chkMobile_Checked(object sender, RoutedEventArgs e) + { + if (isOverride) + { + // If an override was present, delete it. + bool deleteSuccess = false; + while (!deleteSuccess) + { + try + { + File.Delete(GlobalVars.desktopOverride); + deleteSuccess = true; + } + catch (IOException) + { + // This is necessary in case someone ticks and unticks the option quickly, as the File.Create Method has sometimes yet to close the file. + } + } + isOverride = false; + } + else + { + File.Create(GlobalVars.mobileOverride).Close(); + GlobalVars.isMobile = true; + isOverride = true; + } + } + + private void chkMobile_Unchecked(object sender, RoutedEventArgs e) + { + if (isOverride) + { + // If an override was present, delete it. + bool deleteSuccess = false; + while (!deleteSuccess) + { + try + { + File.Delete(GlobalVars.mobileOverride); + deleteSuccess = true; + } + catch (IOException) + { + // This is necessary in case someone ticks and unticks the option quickly, as the File.Create Method has sometimes yet to close the file. + } + } + + isOverride = false; + } + else + { + File.Create(GlobalVars.desktopOverride).Close(); + GlobalVars.isMobile = false; + isOverride = true; + } + } } } diff --git a/EnvyUpdate/MainWindow.xaml b/EnvyUpdate/MainWindow.xaml index 078c8d0..d7300b3 100644 --- a/EnvyUpdate/MainWindow.xaml +++ b/EnvyUpdate/MainWindow.xaml @@ -4,18 +4,24 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:EnvyUpdate" + xmlns:p="clr-namespace:EnvyUpdate.Properties" xmlns:tb="http://www.hardcodet.net/taskbar" mc:Ignorable="d" - Title="EnvyUpdate" Height="140" Width="463" Icon="icon.ico" ResizeMode="CanMinimize" StateChanged="Window_StateChanged" Closing="Window_Closing"> - - - - -