diff --git a/.gitignore b/.gitignore index b248083..87d5d82 100644 --- a/.gitignore +++ b/.gitignore @@ -347,3 +347,6 @@ healthchecksdb # Backup folder for Package Reference Convert tool in Visual Studio 2017 MigrationBackup/ + +# Markdown backups +*.md.backup \ No newline at end of file diff --git a/EnvyUpdate.sln b/EnvyUpdate.sln index 5225e06..d029e8c 100644 --- a/EnvyUpdate.sln +++ b/EnvyUpdate.sln @@ -1,23 +1,41 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29411.108 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33829.357 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnvyUpdate", "EnvyUpdate\EnvyUpdate.csproj", "{1BF2468D-9579-462D-9153-4836E9C8721F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug - ignoregpu|Any CPU = Debug - ignoregpu|Any CPU + Debug - ignoregpu|x64 = Debug - ignoregpu|x64 + Debug - ignoregpu|x86 = Debug - ignoregpu|x86 Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug - ignoregpu|Any CPU.ActiveCfg = Debug - ignoregpu|Any CPU {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug - ignoregpu|Any CPU.Build.0 = Debug - ignoregpu|Any CPU + {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug - ignoregpu|x64.ActiveCfg = Debug - ignoregpu|x64 + {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug - ignoregpu|x64.Build.0 = Debug - ignoregpu|x64 + {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug - ignoregpu|x86.ActiveCfg = Debug - ignoregpu|x86 + {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug - ignoregpu|x86.Build.0 = Debug - ignoregpu|x86 {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|x64.ActiveCfg = Debug|x64 + {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|x64.Build.0 = Debug|x64 + {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|x86.ActiveCfg = Debug|x86 + {1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|x86.Build.0 = Debug|x86 {1BF2468D-9579-462D-9153-4836E9C8721F}.Release|Any CPU.ActiveCfg = Release|Any CPU {1BF2468D-9579-462D-9153-4836E9C8721F}.Release|Any CPU.Build.0 = Release|Any CPU + {1BF2468D-9579-462D-9153-4836E9C8721F}.Release|x64.ActiveCfg = Release|x64 + {1BF2468D-9579-462D-9153-4836E9C8721F}.Release|x64.Build.0 = Release|x64 + {1BF2468D-9579-462D-9153-4836E9C8721F}.Release|x86.ActiveCfg = Release|x86 + {1BF2468D-9579-462D-9153-4836E9C8721F}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/EnvyUpdate/App.xaml b/EnvyUpdate/App.xaml index 414c0d4..de53160 100644 --- a/EnvyUpdate/App.xaml +++ b/EnvyUpdate/App.xaml @@ -2,8 +2,14 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:EnvyUpdate" + xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" StartupUri="MainWindow.xaml"> - + + + + + + diff --git a/EnvyUpdate/App.xaml.cs b/EnvyUpdate/App.xaml.cs index 3bd4437..185bc1d 100644 --- a/EnvyUpdate/App.xaml.cs +++ b/EnvyUpdate/App.xaml.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows; using Windows.Foundation.Collections; +using Wpf.Ui.Markup; namespace EnvyUpdate { @@ -19,25 +20,16 @@ namespace EnvyUpdate protected override void OnStartup(StartupEventArgs e) { // Listen to notification activation - ToastNotificationManagerCompat.OnActivated += toastArgs => - { - // Obtain the arguments from the notification - ToastArguments args = ToastArguments.Parse(toastArgs.Argument); + ToastNotificationManagerCompat.OnActivated += ToastNotificationManagerCompat_OnActivated; + } - // Need to dispatch to UI thread if performing UI operations - Application.Current.Dispatcher.Invoke(delegate - { - switch (args.Get("action")) - { - case "download": - Process.Start(Util.GetGpuUrl()); - break; - default: - Util.ShowMain(); - break; - } - }); - }; + private void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivatedEventArgsCompat e) + { + // Need to dispatch to UI thread if performing UI operations + Application.Current.Dispatcher.Invoke(delegate + { + Util.ShowMain(); + }); } } } diff --git a/EnvyUpdate/DashboardPage.xaml b/EnvyUpdate/DashboardPage.xaml new file mode 100644 index 0000000..546b018 --- /dev/null +++ b/EnvyUpdate/DashboardPage.xaml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EnvyUpdate/DashboardPage.xaml.cs b/EnvyUpdate/DashboardPage.xaml.cs new file mode 100644 index 0000000..f53ef42 --- /dev/null +++ b/EnvyUpdate/DashboardPage.xaml.cs @@ -0,0 +1,509 @@ +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net; +using System.Text.RegularExpressions; +using System.Threading; +using System.Windows; +using System.Windows.Threading; +using MessageBox = System.Windows.MessageBox; + +namespace EnvyUpdate +{ + /// + /// Interaction logic for Dashboard.xaml + /// + public partial class DashboardPage + { + private string localDriv = null; + private string onlineDriv = null; + private string gpuURL = null; + private string skippedVer = null; + private DateTime lastFileChanged = DateTime.MinValue; + + public DashboardPage() + { + InitializeComponent(); + + if (GlobalVars.startMinimized) + Application.Current.MainWindow.Hide(); // Hide only AFTER initializing dashboard page, otherwise tray icon doesn't work + + if (Debug.isFake) + localDriv = Debug.LocalDriv(); + else + localDriv = Util.GetLocDriv(); + + Debug.LogToFile("INFO Local driver version: " + localDriv); + + if (localDriv != null) + { + Debug.LogToFile("INFO Local driver version already known, updating info without reloading."); + UpdateLocalVer(false); + } + + Debug.LogToFile("INFO Detecting driver type."); + + if (Debug.isFake) + textblockLocalType.Text = "DCH (Debug)"; + else if (Util.IsDCH()) + textblockLocalType.Text = "DCH"; + else + textblockLocalType.Text = "Standard"; + + Debug.LogToFile("INFO Done detecting driver type: " + textblockLocalType.Text); + + // Check for startup shortcut + if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "EnvyUpdate.lnk"))) + { + Debug.LogToFile("INFO Autostart is enabled."); + switchAutostart.IsChecked = true; + switchAutostart_Click(null, null); //Automatically recreate shortcut to account for moved EXE. + } + + DispatcherTimer Dt = new DispatcherTimer(); + Dt.Tick += new EventHandler(Dt_Tick); + // Check for new updates every 5 hours. + Dt.Interval = new TimeSpan(5, 0, 0); + Dt.Start(); + Debug.LogToFile("INFO Started check timer."); + + string watchDirPath = Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramW6432%"), "NVIDIA Corporation\\Installer2\\InstallerCore"); + if (Directory.Exists(watchDirPath)) + { + GlobalVars.monitoringInstall = true; + + var driverFileChangedWatcher = new FileSystemWatcher(watchDirPath); + driverFileChangedWatcher.NotifyFilter = NotifyFilters.Attributes + | NotifyFilters.CreationTime + | NotifyFilters.FileName + | NotifyFilters.LastAccess + | NotifyFilters.LastWrite + | NotifyFilters.Size; + driverFileChangedWatcher.Changed += DriverFileChanged; + + driverFileChangedWatcher.Filter = "*.dll"; + driverFileChangedWatcher.IncludeSubdirectories = false; + driverFileChangedWatcher.EnableRaisingEvents = true; + Debug.LogToFile("INFO Started update file system watcher."); + } + else + Debug.LogToFile("WARN Could not start update file system watcher. Path not found: " + watchDirPath); + + Load(); + } + + private void Dt_Tick(object sender, EventArgs e) + { + Load(); + } + + private void Load() + { + if (Util.GetDTID() == 18) + { + Debug.LogToFile("INFO Found studio driver."); + switchStudioDriver.IsChecked = true; + } + else + { + Debug.LogToFile("INFO Found standard driver."); + switchStudioDriver.IsChecked = false; + } + + if (File.Exists(Path.Combine(GlobalVars.saveDirectory,"skip.envy"))) + { + Debug.LogToFile("INFO Found version skip config."); + skippedVer = File.ReadLines(Path.Combine(GlobalVars.saveDirectory, "skip.envy")).First(); + } + + // This little bool check is necessary for debug fake mode. + if (Debug.isFake) + { + localDriv = Debug.LocalDriv(); + cardLocal.Header = localDriv; + textblockGPUName.Text = Debug.GPUname(); + } + + try + { + Debug.LogToFile("INFO Trying to get GPU update URL."); + gpuURL = Util.GetGpuUrl(); + } + catch (ArgumentException) + { + Debug.LogToFile("WARN Could not get GPU update URL, trying again with non-studio driver."); + try + { + // disable SD and try with GRD + if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "sd.envy"))) + { + File.Delete(Path.Combine(GlobalVars.saveDirectory, "sd.envy")); + } + + gpuURL = Util.GetGpuUrl(); //try again with GRD + MessageBox.Show(Properties.Resources.ui_studionotsupported); + switchStudioDriver.IsChecked = false; + } + catch (ArgumentNullException) + { + MessageBox.Show("ERROR: Could not get list of GPU models from Nvidia, please check your network connection.\nOtherwise, please report this issue on GitHub."); + Environment.Exit(11); + } + catch (ArgumentException e) + { + // Now we have a problem. + Debug.LogToFile("FATAL Invalid API response from Nvidia. Attempted API call: " + e.Message); + MessageBox.Show("ERROR: Invalid API response from Nvidia. Please file an issue on GitHub.\nAttempted API call:\n" + e.Message); + Environment.Exit(10); + } + } + + using (var c = new WebClient()) + { + Debug.LogToFile("INFO Trying to get newest driver version."); + string pContent = c.DownloadString(gpuURL); + var pattern = @"Windows\/\d{3}\.\d{2}"; + Regex rgx = new Regex(pattern); + var matches = rgx.Matches(pContent); + onlineDriv = Regex.Replace(Convert.ToString(matches[0]), "Windows/", ""); + cardOnline.Header = onlineDriv; + Debug.LogToFile("INFO Got online driver version: " + onlineDriv); + } + + string correctLocalDriv; + string correctOnlineDriv; + + try + { + float.Parse(onlineDriv); + correctLocalDriv = localDriv; + correctOnlineDriv = onlineDriv; + } + catch (FormatException) + { + Debug.LogToFile("INFO Caught FormatException, assuming locale workaround is necessary."); + //Thank you locales. Some languages need , instead of . for proper parsing + correctLocalDriv = localDriv.Replace('.', ','); + correctOnlineDriv = onlineDriv.Replace('.', ','); + } + + if (float.Parse(correctLocalDriv) < float.Parse(correctOnlineDriv)) + { + Debug.LogToFile("INFO Local version is older than online. Setting UI..."); + SetInfoBar(false); + buttonDownload.Visibility = Visibility.Visible; + buttonSkipVersion.Visibility = Visibility.Visible; + if (skippedVer == null) + { + buttonSkipVersion.ToolTip = Properties.Resources.ui_skipversion; + buttonSkipVersion.IsEnabled = true; + } + else + { + buttonSkipVersion.IsEnabled = false; + buttonSkipVersion.ToolTip = Properties.Resources.ui_skipped; + } + + Debug.LogToFile("INFO UI set."); + + if (skippedVer != onlineDriv) + { + if (GlobalVars.autoDownload) + { + if (buttonDownload.IsVisible) + { + Debug.LogToFile("INFO Auto-Downloading driver."); + buttonDownload_Click(null, null); + } + } + + Debug.LogToFile("INFO Showing update popup notification."); + Notify.ShowDrivUpdatePopup(); + } + } + else + { + Debug.LogToFile("INFO Local version is up to date."); + buttonSkipVersion.Visibility = Visibility.Collapsed; + SetInfoBar(true); + } + + //Check for different version than skipped version + if (skippedVer != null && skippedVer != onlineDriv) + { + Debug.LogToFile("INFO Skipped version is surpassed, deleting setting."); + skippedVer = null; + if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "skip.envy"))) + File.Delete(Path.Combine(GlobalVars.saveDirectory, "skip.envy")); + buttonSkipVersion.ToolTip = Properties.Resources.ui_skipversion; + buttonSkipVersion.IsEnabled = true; + buttonSkipVersion.Visibility = Visibility.Visible; + } + + // Check if update file already exists and display install button instead + if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe"))) + { + Debug.LogToFile("INFO Found downloaded driver installer, no need to redownload."); + buttonDownload.Visibility = Visibility.Collapsed; + buttonInstall.Visibility = Visibility.Visible; + } + } + + private void switchStudioDriver_Unchecked(object sender, RoutedEventArgs e) + { + if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "sd.envy"))) + { + Debug.LogToFile("INFO Switching to game ready driver."); + File.Delete(Path.Combine(GlobalVars.saveDirectory, "sd.envy")); + Load(); + } + } + + private void switchStudioDriver_Checked(object sender, RoutedEventArgs e) + { + if (!File.Exists(Path.Combine(GlobalVars.saveDirectory, "sd.envy"))) + { + Debug.LogToFile("INFO Switching to studio driver."); + File.Create(Path.Combine(GlobalVars.saveDirectory, "sd.envy")).Close(); + Load(); + } + } + + private void switchAutostart_Click(object sender, RoutedEventArgs e) + { + if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "EnvyUpdate.lnk"))) + { + Debug.LogToFile("INFO Removing autostart entry."); + File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "EnvyUpdate.lnk")); + } + if (switchAutostart.IsChecked == true) + { + Debug.LogToFile("INFO Creating autostart entry."); + Util.CreateShortcut("EnvyUpdate", Environment.GetFolderPath(Environment.SpecialFolder.Startup), GlobalVars.pathToAppExe, "NVidia Update Checker", "/minimize"); + } + } + + private void buttonSkipVersion_Click(object sender, RoutedEventArgs e) + { + Debug.LogToFile("INFO Skipping version."); + skippedVer = onlineDriv; + File.WriteAllText(Path.Combine(GlobalVars.saveDirectory, "skip.envy"), onlineDriv); + buttonSkipVersion.IsEnabled = false; + buttonSkipVersion.ToolTip = Properties.Resources.ui_skipped; + MessageBox.Show(Properties.Resources.skip_confirm); + } + + private void UpdateLocalVer(bool reloadLocalDriv = true) + { + Debug.LogToFile("INFO Updating local driver version in UI."); + if (reloadLocalDriv) + { + Debug.LogToFile("INFO Reloading local driver version."); + localDriv = Util.GetLocDriv(); + } + cardLocal.Header = localDriv; + if (GlobalVars.isMobile) + textblockGPUName.Text = Util.GetGPUName(false) + " (mobile)"; + else + textblockGPUName.Text = Util.GetGPUName(false); + } + + void DriverFileChanged(object sender, FileSystemEventArgs e) + { + if (!GlobalVars.isInstalling && (DateTime.UtcNow.Subtract(lastFileChanged).TotalMinutes > 1)) + { + Debug.LogToFile("INFO Watched driver file changed! Reloading data."); + System.Threading.Thread.Sleep(10000); + lastFileChanged = DateTime.UtcNow; + Application.Current.Dispatcher.Invoke(delegate + { + UpdateLocalVer(); + Load(); + }); + } + } + + private void CardOnline_Click(object sender, RoutedEventArgs e) + { + Debug.LogToFile("INFO Opening download page."); + Process.Start(gpuURL); + } + + private void SetInfoBar (bool good) + { + if (good) + { + infoBarStatus.Severity = Wpf.Ui.Controls.InfoBarSeverity.Success; + infoBarStatus.Title = Properties.Resources.ui_info_uptodate; + infoBarStatus.Message = Properties.Resources.ui_message_good; + } + else + { + infoBarStatus.Severity = Wpf.Ui.Controls.InfoBarSeverity.Warning; + infoBarStatus.Title = Properties.Resources.ui_info_outdated; + infoBarStatus.Message = Properties.Resources.ui_message_update; + } + } + + private void buttonDownload_Click(object sender, RoutedEventArgs e) + { + if (GlobalVars.isDownloading) + { + Debug.LogToFile("WARN A download is already running."); + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Danger, Wpf.Ui.Common.SymbolRegular.ErrorCircle24, Properties.Resources.info_download_running, Properties.Resources.info_download_running_title); + } + else + { + progressbarDownload.Visibility = Visibility.Visible; + buttonDownload.IsEnabled = false; + GlobalVars.isDownloading = true; + + if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"))) + { + Debug.LogToFile("WARN Found previous unfinished download, retrying."); + File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading")); + } + Thread thread = new Thread(() => { + using (WebClient client = new WebClient()) + { + client.Headers["User-Agent"] = GlobalVars.useragent; + client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); + client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); + client.DownloadFileAsync(new Uri(Util.GetDirectDownload(gpuURL)), Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading")); + } + }); + thread.Start(); + Debug.LogToFile("INFO Started installer download."); + } + } + + void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) + { + double bytesIn = double.Parse(e.BytesReceived.ToString()); + double totalBytes = double.Parse(e.TotalBytesToReceive.ToString()); + double percentage = bytesIn / totalBytes * 100; + Application.Current.Dispatcher.Invoke(new Action(() => { + progressbarDownload.Value = int.Parse(Math.Truncate(percentage).ToString()); + })); + } + + void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) + { + Application.Current.Dispatcher.Invoke(new Action(() => { + buttonDownload.IsEnabled = true; + progressbarDownload.Visibility = Visibility.Collapsed; + GlobalVars.isDownloading = false; + })); + if (e.Error == null) + { + Application.Current.Dispatcher.Invoke(new Action(() => { + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Success, Wpf.Ui.Common.SymbolRegular.CheckmarkCircle24, Properties.Resources.info_download_success, Properties.Resources.info_download_success_title); + buttonDownload.Visibility = Visibility.Collapsed; + buttonInstall.Visibility = Visibility.Visible; + Debug.LogToFile("INFO Download successful."); + })); + if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe"))) + File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe")); + File.Move(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"), Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe")); + } + else + { + File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading")); + Application.Current.Dispatcher.Invoke(new Action(() => { + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Danger, Wpf.Ui.Common.SymbolRegular.ErrorCircle24, Properties.Resources.info_download_error, Properties.Resources.info_download_error_title); + Debug.LogToFile("INFO Download NOT successful. Error: " + e.Error.ToString()); + })); + } + } + private void buttonInstall_Click(object sender, RoutedEventArgs e) + { + buttonInstall.IsEnabled = false; + GlobalVars.isInstalling = true; + string sevenZipPath = Util.GetSevenZip(); + + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Info, Wpf.Ui.Common.SymbolRegular.FolderZip24, Properties.Resources.info_extracting, Properties.Resources.info_extracting_title); + + string filePath = Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe"); + string destinationDir = Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-extracted"); + + if (!Directory.Exists(destinationDir)) + Directory.CreateDirectory(destinationDir); + + Debug.LogToFile("INFO Starting extraction of driver files."); + + Process process = new Process(); + ProcessStartInfo startInfo = new ProcessStartInfo + { + WindowStyle = ProcessWindowStyle.Minimized, + WorkingDirectory = destinationDir, + FileName = sevenZipPath, + Arguments = "x -aoa -y \"" + filePath + "\" Display.Driver Display.Nview Display.Optimus HDAudio MSVCR NVI2 NVPCF PhysX PPC ShieldWirelessController EULA.txt ListDevices.txt setup.cfg setup.exe" + }; + process.EnableRaisingEvents = true; + process.StartInfo = startInfo; + process.Exited += new EventHandler(ExtractionFinished); + process.Start(); + } + + private void ExtractionFinished(object sender, EventArgs e) + { + string extractedPath = Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-extracted"); + Application.Current.Dispatcher.Invoke(new Action(() => { + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Success, Wpf.Ui.Common.SymbolRegular.FolderZip24, Properties.Resources.info_extract_complete, Properties.Resources.info_extract_complete_title); + })); + Debug.LogToFile("INFO Extraction exited, deleting 7-zip executable."); + + File.Delete(Path.Combine(GlobalVars.saveDirectory, "7zr.exe")); + + Util.CleanInstallConfig(Path.Combine(extractedPath, "setup.cfg")); + + Debug.LogToFile("Starting driver setup."); + + Process process = new Process(); + ProcessStartInfo startInfo = new ProcessStartInfo + { + WindowStyle = ProcessWindowStyle.Normal, + WorkingDirectory = extractedPath, + FileName = "setup.exe", + Arguments = "-passive -noreboot -noeula" + }; + process.EnableRaisingEvents = true; + process.StartInfo = startInfo; + process.Exited += new EventHandler(InstallFinished); + process.Start(); + } + + private void InstallFinished(object sender, EventArgs e) + { + Application.Current.Dispatcher.Invoke(new Action(() => { + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Success, Wpf.Ui.Common.SymbolRegular.CheckmarkCircle24, Properties.Resources.info_install_complete, Properties.Resources.info_install_complete_title); + buttonInstall.IsEnabled = true; + buttonInstall.Visibility = Visibility.Collapsed; + buttonDownload.IsEnabled = true; + buttonDownload.Visibility = Visibility.Collapsed; + })); + + Debug.LogToFile("INFO Driver setup complete. Cleaning up setup files."); + + File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe")); + Directory.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-extracted"), true); + GlobalVars.isInstalling = false; + Application.Current.Dispatcher.Invoke(delegate + { + UpdateLocalVer(); + Load(); + }); + } + + private void ShowSnackbar(Wpf.Ui.Common.ControlAppearance appearance, Wpf.Ui.Common.SymbolRegular icon, string message = "", string title = "") + { + snackbarInfo.Appearance = appearance; + snackbarInfo.Icon = icon; + snackbarInfo.Title = title; + snackbarInfo.Message = message; + snackbarInfo.Show(); + } + } +} diff --git a/EnvyUpdate/Debug.cs b/EnvyUpdate/Debug.cs index 5d7e5fd..35e6e04 100644 --- a/EnvyUpdate/Debug.cs +++ b/EnvyUpdate/Debug.cs @@ -1,12 +1,19 @@ using System; +using System.Diagnostics; using System.IO; using System.Linq; +using System.Security.Policy; namespace EnvyUpdate { class Debug { - public static bool isDebug = false; + public static bool isFake = false; +#if DEBUG + public static bool isVerbose = true; +#else + public static bool isVerbose = false; +#endif public static int LoadFakeIDs(string idType) { @@ -16,9 +23,9 @@ namespace EnvyUpdate switch (idType) { case "psid": - return 101; + return 127; case "pfid": - return 845; + return 999; case "osid": return 57; case "dtcid": @@ -36,7 +43,18 @@ namespace EnvyUpdate public static string GPUname() { - return "Nvidia GeForce GTX 1080ti (debug)"; + return "Nvidia GeForce RTX 4080 (debug)"; + } + + public static void LogToFile(string content) + { + if (isVerbose) + { + if (GlobalVars.useAppdata) + File.AppendAllText(Path.Combine(GlobalVars.appdata, "envyupdate.log"), content + "\n"); + else + File.AppendAllText(Path.Combine(GlobalVars.directoryOfExe, "envyupdate.log"), content + "\n"); + } } } } diff --git a/EnvyUpdate/EnvyUpdate.csproj b/EnvyUpdate/EnvyUpdate.csproj index b3e717f..cc7331b 100644 --- a/EnvyUpdate/EnvyUpdate.csproj +++ b/EnvyUpdate/EnvyUpdate.csproj @@ -72,6 +72,68 @@ app.manifest + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + 7.3 + prompt + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + 7.3 + prompt + true + + + true + bin\x86\Debug - ignoregpu\ + DEBUG;TRACE + full + x86 + 7.3 + prompt + MinimumRecommendedRules.ruleset + true + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + true + + + true + bin\x64\Debug - ignoregpu\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + true + @@ -100,21 +162,25 @@ - - InfoWindow.xaml - + + DashboardPage.xaml + + + True + True + Licenses.resx + Resources.de.resx True True + + SettingsPage.xaml + - - Designer - MSBuild:Compile - MSBuild:Compile Designer @@ -127,6 +193,14 @@ MainWindow.xaml Code + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + @@ -142,6 +216,10 @@ Settings.settings True + + ResXFileCodeGenerator + Licenses.Designer.cs + PublicResXFileCodeGenerator Resources.de.Designer.cs @@ -189,17 +267,14 @@ - - 4.1.0 + + 5.7.0 - 6.6.4 + 6.8.1 runtime; build; native; contentfiles; analyzers; buildtransitive all - - 1.1.0 - 7.1.3 @@ -207,7 +282,10 @@ 2.2.0 - 7.0.1 + 8.0.4 + + + 2.1.0 diff --git a/EnvyUpdate/FodyWeavers.xsd b/EnvyUpdate/FodyWeavers.xsd index 44a5374..05e92c1 100644 --- a/EnvyUpdate/FodyWeavers.xsd +++ b/EnvyUpdate/FodyWeavers.xsd @@ -17,6 +17,16 @@ A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. @@ -43,6 +53,16 @@ Controls if .pdbs for reference assemblies are also embedded. + + + Controls if runtime assemblies are also embedded. + + + + + Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. @@ -73,6 +93,16 @@ A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + A list of unmanaged 32 bit assembly names to include, delimited with |. diff --git a/EnvyUpdate/GlobalVars.cs b/EnvyUpdate/GlobalVars.cs index 57c5f1e..f52b4af 100644 --- a/EnvyUpdate/GlobalVars.cs +++ b/EnvyUpdate/GlobalVars.cs @@ -6,11 +6,20 @@ namespace EnvyUpdate class GlobalVars { public static bool isMobile = false; - 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 pathToAppExe = System.Reflection.Assembly.GetEntryAssembly().Location; + public static readonly string directoryOfExe = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); + public static string saveDirectory = directoryOfExe; 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 legacyAppdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; + public static readonly string appdata = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EnvyUpdate_Data"); public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); public static bool monitoringInstall = false; + public static bool startMinimized = false; + public static bool isInstalling = false; + public static readonly string useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Firefox/115.0"; + public static bool useAppdata = false; + public static bool hasWrite = true; + public static bool autoDownload = false; + public static bool isDownloading = false; } } diff --git a/EnvyUpdate/InfoWindow.xaml b/EnvyUpdate/InfoWindow.xaml deleted file mode 100644 index bdc6ca6..0000000 --- a/EnvyUpdate/InfoWindow.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - -