Feature autodownload #44
4 changed files with 42 additions and 16 deletions
|
@ -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()
|
||||||
{
|
{
|
||||||
|
@ -346,25 +347,34 @@ namespace EnvyUpdate
|
||||||
|
|
||||||
private void buttonDownload_Click(object sender, RoutedEventArgs e)
|
private void buttonDownload_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
progressbarDownload.Visibility = Visibility.Visible;
|
if (isDownloading)
|
||||||
buttonDownload.IsEnabled = false;
|
|
||||||
|
|
||||||
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading")))
|
|
||||||
{
|
{
|
||||||
Debug.LogToFile("WARN Found previous unfinished download, retrying.");
|
Debug.LogToFile("WARN A download is already running.");
|
||||||
File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
|
ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Danger, Wpf.Ui.Common.SymbolRegular.ErrorCircle24, Properties.Resources.info_install_complete, Properties.Resources.info_install_complete_title);
|
||||||
}
|
}
|
||||||
Thread thread = new Thread(() => {
|
else
|
||||||
using (WebClient client = new WebClient())
|
{
|
||||||
|
progressbarDownload.Visibility = Visibility.Visible;
|
||||||
|
buttonDownload.IsEnabled = false;
|
||||||
|
isDownloading = true;
|
||||||
|
|
||||||
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading")))
|
||||||
{
|
{
|
||||||
client.Headers["User-Agent"] = GlobalVars.useragent;
|
Debug.LogToFile("WARN Found previous unfinished download, retrying.");
|
||||||
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
|
File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
|
||||||
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
|
|
||||||
client.DownloadFileAsync(new Uri(Util.GetDirectDownload(gpuURL)), Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
|
|
||||||
}
|
}
|
||||||
});
|
Thread thread = new Thread(() => {
|
||||||
thread.Start();
|
using (WebClient client = new WebClient())
|
||||||
Debug.LogToFile("INFO Started installer download.");
|
{
|
||||||
|
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)
|
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)
|
||||||
{
|
{
|
||||||
|
|
9
EnvyUpdate/Properties/Resources.Designer.cs
generated
9
EnvyUpdate/Properties/Resources.Designer.cs
generated
|
@ -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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Reference in a new issue