diff --git a/EnvyUpdate/DashboardPage.xaml.cs b/EnvyUpdate/DashboardPage.xaml.cs
index d275b3f..f53ef42 100644
--- a/EnvyUpdate/DashboardPage.xaml.cs
+++ b/EnvyUpdate/DashboardPage.xaml.cs
@@ -210,6 +210,15 @@ namespace EnvyUpdate
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();
}
@@ -340,25 +349,34 @@ namespace EnvyUpdate
private void buttonDownload_Click(object sender, RoutedEventArgs e)
{
- progressbarDownload.Visibility = Visibility.Visible;
- buttonDownload.IsEnabled = false;
-
- if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading")))
+ if (GlobalVars.isDownloading)
{
- Debug.LogToFile("WARN Found previous unfinished download, retrying.");
- File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
+ 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);
}
- Thread thread = new Thread(() => {
- using (WebClient client = new WebClient())
+ else
+ {
+ progressbarDownload.Visibility = Visibility.Visible;
+ buttonDownload.IsEnabled = false;
+ GlobalVars.isDownloading = true;
+
+ if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading")))
{
- 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"));
+ Debug.LogToFile("WARN Found previous unfinished download, retrying.");
+ File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
}
- });
- thread.Start();
- Debug.LogToFile("INFO Started installer download.");
+ 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)
@@ -376,6 +394,7 @@ namespace EnvyUpdate
Application.Current.Dispatcher.Invoke(new Action(() => {
buttonDownload.IsEnabled = true;
progressbarDownload.Visibility = Visibility.Collapsed;
+ GlobalVars.isDownloading = false;
}));
if (e.Error == null)
{
diff --git a/EnvyUpdate/GlobalVars.cs b/EnvyUpdate/GlobalVars.cs
index e830039..f52b4af 100644
--- a/EnvyUpdate/GlobalVars.cs
+++ b/EnvyUpdate/GlobalVars.cs
@@ -19,5 +19,7 @@ namespace EnvyUpdate
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/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs
index d139842..6522ee3 100644
--- a/EnvyUpdate/MainWindow.xaml.cs
+++ b/EnvyUpdate/MainWindow.xaml.cs
@@ -115,6 +115,12 @@ namespace EnvyUpdate
GlobalVars.isMobile = Util.IsMobile();
Debug.LogToFile("INFO Mobile: " + GlobalVars.isMobile);
+
+ if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "autodl.envy")))
+ {
+ Debug.LogToFile("INFO Auto-download is enabled.");
+ GlobalVars.autoDownload = true;
+ }
}
private void Window_StateChanged(object sender, EventArgs e)
{
diff --git a/EnvyUpdate/Properties/Resources.Designer.cs b/EnvyUpdate/Properties/Resources.Designer.cs
index 4f80cf9..466a9c0 100644
--- a/EnvyUpdate/Properties/Resources.Designer.cs
+++ b/EnvyUpdate/Properties/Resources.Designer.cs
@@ -105,6 +105,24 @@ namespace EnvyUpdate.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to A download process is already running!.
+ ///
+ public static string info_download_running {
+ get {
+ return ResourceManager.GetString("info_download_running", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Download running.
+ ///
+ public static string info_download_running_title {
+ get {
+ return ResourceManager.GetString("info_download_running_title", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Driver installer successfully downloaded..
///
@@ -267,6 +285,15 @@ namespace EnvyUpdate.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Download updates automatically.
+ ///
+ public static string ui_enable_autodownload {
+ get {
+ return ResourceManager.GetString("ui_enable_autodownload", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Enable logging to file.
///
diff --git a/EnvyUpdate/Properties/Resources.de.resx b/EnvyUpdate/Properties/Resources.de.resx
index 40102a4..b5a18f5 100644
--- a/EnvyUpdate/Properties/Resources.de.resx
+++ b/EnvyUpdate/Properties/Resources.de.resx
@@ -132,6 +132,12 @@
Fehler beim Herunterladen
+
+ Ein Downloadvorgang läuft bereits!
+
+
+ Download läuft
+
Treiber-Installationsdatei erfolgreich heruntergeladen.
@@ -186,6 +192,9 @@
Programmdaten in AppData speichern
+
+ Updates automatisch herunterladen
+
Programm-Log in Datei schreiben
diff --git a/EnvyUpdate/Properties/Resources.resx b/EnvyUpdate/Properties/Resources.resx
index 3780249..2623dae 100644
--- a/EnvyUpdate/Properties/Resources.resx
+++ b/EnvyUpdate/Properties/Resources.resx
@@ -132,6 +132,12 @@
Error while downloading
+
+ A download process is already running!
+
+
+ Download running
+
Driver installer successfully downloaded.
@@ -186,6 +192,9 @@
Save files to AppData
+
+ Download updates automatically
+
Enable logging to file
diff --git a/EnvyUpdate/SettingsPage.xaml b/EnvyUpdate/SettingsPage.xaml
index f00cd4b..ab6f973 100644
--- a/EnvyUpdate/SettingsPage.xaml
+++ b/EnvyUpdate/SettingsPage.xaml
@@ -35,9 +35,19 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/EnvyUpdate/SettingsPage.xaml.cs b/EnvyUpdate/SettingsPage.xaml.cs
index 35e33f1..e65aa94 100644
--- a/EnvyUpdate/SettingsPage.xaml.cs
+++ b/EnvyUpdate/SettingsPage.xaml.cs
@@ -30,6 +30,16 @@ namespace EnvyUpdate
if (!GlobalVars.hasWrite)
chkAppdata.IsEnabled = false;
+ if (GlobalVars.autoDownload)
+ chkAutodl.IsChecked = true;
+
+ if (GlobalVars.isDownloading)
+ {
+ chkAppdata.IsEnabled = false;
+ }
+ else
+ chkAppdata.IsEnabled = true;
+
textBoxLicEnvyupdate.Text = Properties.Licenses.EnvyUpdate;
textBoxLicFody.Text = Properties.Licenses.Fody;
textBoxLicCostura.Text = Properties.Licenses.CosturaFody;
@@ -91,5 +101,23 @@ namespace EnvyUpdate
Debug.LogToFile("INFO Switched to EXE directory.");
}
+
+ private void chkAutodl_Checked(object sender, RoutedEventArgs e)
+ {
+ GlobalVars.autoDownload = true;
+ if (!File.Exists(Path.Combine(GlobalVars.saveDirectory, "autodl.envy")))
+ {
+ File.Create(Path.Combine(GlobalVars.saveDirectory, "autodl.envy"));
+ }
+ }
+
+ private void chkAutodl_Unchecked(object sender, RoutedEventArgs e)
+ {
+ GlobalVars.autoDownload = false;
+ if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "autodl.envy")))
+ {
+ File.Delete(Path.Combine(GlobalVars.saveDirectory, "autodl.envy"));
+ }
+ }
}
}