finish downloader
This commit is contained in:
parent
0760600d47
commit
726adc7193
6 changed files with 159 additions and 66 deletions
|
@ -11,6 +11,7 @@
|
||||||
Title="DashboardPage">
|
Title="DashboardPage">
|
||||||
|
|
||||||
<Grid Margin="8,0,8,8">
|
<Grid Margin="8,0,8,8">
|
||||||
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
|
@ -82,4 +83,6 @@
|
||||||
<ui:ToggleSwitch x:Name="switchAutostart" IsChecked="False" Click="switchAutostart_Click" />
|
<ui:ToggleSwitch x:Name="switchAutostart" IsChecked="False" Click="switchAutostart_Click" />
|
||||||
</ui:CardControl>
|
</ui:CardControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<ui:Snackbar x:Name="snackbarInfo" Timeout="0"/>
|
||||||
|
</Grid>
|
||||||
</ui:UiPage>
|
</ui:UiPage>
|
||||||
|
|
|
@ -8,6 +8,8 @@ using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
using Wpf.Ui.Controls;
|
||||||
|
using MessageBox = System.Windows.MessageBox;
|
||||||
|
|
||||||
namespace EnvyUpdate
|
namespace EnvyUpdate
|
||||||
{
|
{
|
||||||
|
@ -352,7 +354,7 @@ namespace EnvyUpdate
|
||||||
client.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0";
|
client.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0";
|
||||||
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
|
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
|
||||||
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
|
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
|
||||||
client.DownloadFileAsync(new Uri(Util.GetDirectDownload(gpuURL)), Path.Combine(GlobalVars.exedirectory, "nvidia-installer.exe"));
|
client.DownloadFileAsync(new Uri(Util.GetDirectDownload(gpuURL)), Path.Combine(GlobalVars.exedirectory, "nvidia-installer.exe.downloading"));
|
||||||
});
|
});
|
||||||
thread.Start();
|
thread.Start();
|
||||||
}
|
}
|
||||||
|
@ -369,9 +371,34 @@ namespace EnvyUpdate
|
||||||
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
|
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() => {
|
Application.Current.Dispatcher.Invoke(new Action(() => {
|
||||||
|
buttonDownload.IsEnabled = true;
|
||||||
progressbarDownload.Visibility = Visibility.Collapsed;
|
progressbarDownload.Visibility = Visibility.Collapsed;
|
||||||
buttonDownload.Icon = Wpf.Ui.Common.SymbolRegular.CheckmarkCircle24;
|
}));
|
||||||
|
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);
|
||||||
|
}));
|
||||||
|
if (File.Exists(Path.Combine(GlobalVars.exedirectory, "nvidia-installer.exe")))
|
||||||
|
File.Delete(Path.Combine(GlobalVars.exedirectory, "nvidia-installer.exe"));
|
||||||
|
File.Move(Path.Combine(GlobalVars.exedirectory, "nvidia-installer.exe.downloading"), Path.Combine(GlobalVars.exedirectory, "nvidia-installer.exe"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File.Delete(Path.Combine(GlobalVars.exedirectory, "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);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
36
EnvyUpdate/Properties/Resources.Designer.cs
generated
36
EnvyUpdate/Properties/Resources.Designer.cs
generated
|
@ -78,6 +78,42 @@ namespace EnvyUpdate.Properties {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to There was a problem downloading the driver installer. Please try again..
|
||||||
|
/// </summary>
|
||||||
|
public static string info_download_error {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("info_download_error", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Error while downloading.
|
||||||
|
/// </summary>
|
||||||
|
public static string info_download_error_title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("info_download_error_title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Driver installer successfully downloaded..
|
||||||
|
/// </summary>
|
||||||
|
public static string info_download_success {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("info_download_success", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Download successful.
|
||||||
|
/// </summary>
|
||||||
|
public static string info_download_success_title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("info_download_success_title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Preference reset..
|
/// Looks up a localized string similar to Preference reset..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -123,6 +123,18 @@
|
||||||
<data name="exit_confirm" xml:space="preserve">
|
<data name="exit_confirm" xml:space="preserve">
|
||||||
<value>EnvyUpdate schließen?</value>
|
<value>EnvyUpdate schließen?</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="info_download_error" xml:space="preserve">
|
||||||
|
<value>Fehler beim Herunterladen der Treiber-Installationsdatei. Bitte versuchen Sie es erneut.</value>
|
||||||
|
</data>
|
||||||
|
<data name="info_download_error_title" xml:space="preserve">
|
||||||
|
<value>Fehler beim Herunterladen</value>
|
||||||
|
</data>
|
||||||
|
<data name="info_download_success" xml:space="preserve">
|
||||||
|
<value>Treiber-Installationsdatei erfolgreich heruntergeladen.</value>
|
||||||
|
</data>
|
||||||
|
<data name="info_download_success_title" xml:space="preserve">
|
||||||
|
<value>Herunterladen erfolgreich abgeschlossen</value>
|
||||||
|
</data>
|
||||||
<data name="info_reset_caption" xml:space="preserve">
|
<data name="info_reset_caption" xml:space="preserve">
|
||||||
<value>Einstellung zurückgesetzt.</value>
|
<value>Einstellung zurückgesetzt.</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -123,6 +123,18 @@
|
||||||
<data name="exit_confirm" xml:space="preserve">
|
<data name="exit_confirm" xml:space="preserve">
|
||||||
<value>Exit EnvyUpdate?</value>
|
<value>Exit EnvyUpdate?</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="info_download_error" xml:space="preserve">
|
||||||
|
<value>There was a problem downloading the driver installer. Please try again.</value>
|
||||||
|
</data>
|
||||||
|
<data name="info_download_error_title" xml:space="preserve">
|
||||||
|
<value>Error while downloading</value>
|
||||||
|
</data>
|
||||||
|
<data name="info_download_success" xml:space="preserve">
|
||||||
|
<value>Driver installer successfully downloaded.</value>
|
||||||
|
</data>
|
||||||
|
<data name="info_download_success_title" xml:space="preserve">
|
||||||
|
<value>Download successful</value>
|
||||||
|
</data>
|
||||||
<data name="info_reset_caption" xml:space="preserve">
|
<data name="info_reset_caption" xml:space="preserve">
|
||||||
<value>Preference reset.</value>
|
<value>Preference reset.</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using IWshRuntimeLibrary;
|
using EnvyUpdate.Properties;
|
||||||
|
using IWshRuntimeLibrary;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -7,7 +8,9 @@ using System.Linq;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace EnvyUpdate
|
namespace EnvyUpdate
|
||||||
|
|
Reference in a new issue