handle running download

This commit is contained in:
Jakob 2024-02-26 19:42:06 +01:00
parent bbe0e8dde9
commit a271150b0c
4 changed files with 42 additions and 16 deletions

View file

@ -22,6 +22,7 @@ namespace EnvyUpdate
private string gpuURL = null; private string gpuURL = null;
private string skippedVer = null; private string skippedVer = null;
private DateTime lastFileChanged = DateTime.MinValue; private DateTime lastFileChanged = DateTime.MinValue;
private bool isDownloading = false;
public DashboardPage() public DashboardPage()
{ {
@ -345,9 +346,17 @@ namespace EnvyUpdate
} }
private void buttonDownload_Click(object sender, RoutedEventArgs e) private void buttonDownload_Click(object sender, RoutedEventArgs e)
{
if (isDownloading)
{
Debug.LogToFile("WARN A download is already running.");
ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Danger, Wpf.Ui.Common.SymbolRegular.ErrorCircle24, Properties.Resources.info_install_complete, Properties.Resources.info_install_complete_title);
}
else
{ {
progressbarDownload.Visibility = Visibility.Visible; progressbarDownload.Visibility = Visibility.Visible;
buttonDownload.IsEnabled = false; buttonDownload.IsEnabled = false;
isDownloading = true;
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"))) if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading")))
{ {
@ -366,6 +375,7 @@ namespace EnvyUpdate
thread.Start(); thread.Start();
Debug.LogToFile("INFO Started installer download."); Debug.LogToFile("INFO Started installer download.");
} }
}
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{ {
@ -382,6 +392,7 @@ namespace EnvyUpdate
Application.Current.Dispatcher.Invoke(new Action(() => { Application.Current.Dispatcher.Invoke(new Action(() => {
buttonDownload.IsEnabled = true; buttonDownload.IsEnabled = true;
progressbarDownload.Visibility = Visibility.Collapsed; progressbarDownload.Visibility = Visibility.Collapsed;
isDownloading = false;
})); }));
if (e.Error == null) if (e.Error == null)
{ {

View file

@ -105,6 +105,15 @@ namespace EnvyUpdate.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to A download process is already running!.
/// </summary>
public static string info_download_running {
get {
return ResourceManager.GetString("info_download_running", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Driver installer successfully downloaded.. /// Looks up a localized string similar to Driver installer successfully downloaded..
/// </summary> /// </summary>

View file

@ -132,6 +132,9 @@
<data name="info_download_error_title" xml:space="preserve"> <data name="info_download_error_title" xml:space="preserve">
<value>Fehler beim Herunterladen</value> <value>Fehler beim Herunterladen</value>
</data> </data>
<data name="info_download_running" xml:space="preserve">
<value>Ein Downloadvorgang läuft bereits!</value>
</data>
<data name="info_download_success" xml:space="preserve"> <data name="info_download_success" xml:space="preserve">
<value>Treiber-Installationsdatei erfolgreich heruntergeladen.</value> <value>Treiber-Installationsdatei erfolgreich heruntergeladen.</value>
</data> </data>

View file

@ -132,6 +132,9 @@
<data name="info_download_error_title" xml:space="preserve"> <data name="info_download_error_title" xml:space="preserve">
<value>Error while downloading</value> <value>Error while downloading</value>
</data> </data>
<data name="info_download_running" xml:space="preserve">
<value>A download process is already running!</value>
</data>
<data name="info_download_success" xml:space="preserve"> <data name="info_download_success" xml:space="preserve">
<value>Driver installer successfully downloaded.</value> <value>Driver installer successfully downloaded.</value>
</data> </data>