finish downloader
This commit is contained in:
parent
0760600d47
commit
726adc7193
6 changed files with 159 additions and 66 deletions
|
@ -11,75 +11,78 @@
|
|||
Title="DashboardPage">
|
||||
|
||||
<Grid Margin="8,0,8,8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ui:SymbolIcon Symbol="DeveloperBoard24" FontSize="56"/>
|
||||
<TextBlock Margin="8,0,0,0" x:Name="textblockGPUName" Grid.Column="1" Text="GPU..." FontSize="32" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ui:SymbolIcon Symbol="DeveloperBoard24" FontSize="56"/>
|
||||
<TextBlock Margin="8,0,0,0" x:Name="textblockGPUName" Grid.Column="1" Text="GPU..." FontSize="32" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ui:InfoBar x:Name="infoBarStatus"
|
||||
Title="Checking"
|
||||
IsOpen="True"
|
||||
IsClosable="False"
|
||||
Message="..."
|
||||
Severity="Informational" />
|
||||
<ui:InfoBar x:Name="infoBarStatus"
|
||||
Title="Checking"
|
||||
IsOpen="True"
|
||||
IsClosable="False"
|
||||
Message="..."
|
||||
Severity="Informational" />
|
||||
|
||||
<ui:Button x:Name="buttonSkipVersion" Margin="8,0,0,0" Grid.Column="1" Appearance="Secondary" Icon="ArrowForward24" Visibility="Collapsed" ToolTip="{x:Static p:Resources.ui_skipversion}" Click="buttonSkipVersion_Click" />
|
||||
<ui:Button x:Name="buttonSkipVersion" Margin="8,0,0,0" Grid.Column="1" Appearance="Secondary" Icon="ArrowForward24" Visibility="Collapsed" ToolTip="{x:Static p:Resources.ui_skipversion}" Click="buttonSkipVersion_Click" />
|
||||
|
||||
<ui:Button x:Name="buttonDownload" Margin="8,0,0,0" MinWidth="100" Grid.Column="2" Appearance="Primary" Icon="ArrowDownload24" Visibility="Collapsed" Click="buttonDownload_Click" />
|
||||
<ui:Button x:Name="buttonDownload" Margin="8,0,0,0" MinWidth="100" Grid.Column="2" Appearance="Primary" Icon="ArrowDownload24" Visibility="Collapsed" Click="buttonDownload_Click" />
|
||||
</Grid>
|
||||
|
||||
<ProgressBar x:Name="progressbarDownload" Grid.Row="2" Value="0" Visibility="Collapsed"/>
|
||||
<!-- This is for later automatic downloading. Todo! -->
|
||||
|
||||
<Grid Margin="0,12,0,0" Grid.Row="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ui:CardExpander x:Name="cardLocal" Margin="0,0,4,0" Grid.Column="0" Grid.Row="0" Icon="Desktop32" Header="..." ToolTip="{x:Static p:Resources.ui_localdriver}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" FontWeight="Bold" Text="{x:Static p:Resources.ui_localdriver_type}"/>
|
||||
<TextBlock Grid.Column="1" x:Name="textblockLocalType" Text="?" />
|
||||
</Grid>
|
||||
</ui:CardExpander>
|
||||
<ui:CardExpander x:Name="cardOnline" Margin="4,0,0,0" Grid.Column="1" Grid.Row="0" Icon="Earth32" Header="..." ToolTip="{x:Static p:Resources.ui_onlinedriver}">
|
||||
<ui:Button Icon="Open24" Click="CardOnline_Click" Content="{x:Static p:Resources.ui_openwebsite}" HorizontalAlignment="Stretch"/>
|
||||
</ui:CardExpander>
|
||||
</Grid>
|
||||
|
||||
<ui:CardControl Margin="0,12,0,0" Grid.Row="4" Icon="Color24" Header="Studio Driver">
|
||||
<ui:ToggleSwitch x:Name="switchStudioDriver" IsChecked="False" Checked="switchStudioDriver_Checked" Unchecked="switchStudioDriver_Unchecked" />
|
||||
</ui:CardControl>
|
||||
|
||||
<ui:CardControl Margin="0,12,0,0" Grid.Row="5" Icon="LightbulbFilament48" Header="{x:Static p:Resources.ui_autostart}">
|
||||
<ui:ToggleSwitch x:Name="switchAutostart" IsChecked="False" Click="switchAutostart_Click" />
|
||||
</ui:CardControl>
|
||||
</Grid>
|
||||
|
||||
<ProgressBar x:Name="progressbarDownload" Grid.Row="2" Value="0" Visibility="Collapsed"/>
|
||||
<!-- This is for later automatic downloading. Todo! -->
|
||||
|
||||
<Grid Margin="0,12,0,0" Grid.Row="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ui:CardExpander x:Name="cardLocal" Margin="0,0,4,0" Grid.Column="0" Grid.Row="0" Icon="Desktop32" Header="..." ToolTip="{x:Static p:Resources.ui_localdriver}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" FontWeight="Bold" Text="{x:Static p:Resources.ui_localdriver_type}"/>
|
||||
<TextBlock Grid.Column="1" x:Name="textblockLocalType" Text="?" />
|
||||
</Grid>
|
||||
</ui:CardExpander>
|
||||
<ui:CardExpander x:Name="cardOnline" Margin="4,0,0,0" Grid.Column="1" Grid.Row="0" Icon="Earth32" Header="..." ToolTip="{x:Static p:Resources.ui_onlinedriver}">
|
||||
<ui:Button Icon="Open24" Click="CardOnline_Click" Content="{x:Static p:Resources.ui_openwebsite}" HorizontalAlignment="Stretch"/>
|
||||
</ui:CardExpander>
|
||||
</Grid>
|
||||
|
||||
<ui:CardControl Margin="0,12,0,0" Grid.Row="4" Icon="Color24" Header="Studio Driver">
|
||||
<ui:ToggleSwitch x:Name="switchStudioDriver" IsChecked="False" Checked="switchStudioDriver_Checked" Unchecked="switchStudioDriver_Unchecked" />
|
||||
</ui:CardControl>
|
||||
|
||||
<ui:CardControl Margin="0,12,0,0" Grid.Row="5" Icon="LightbulbFilament48" Header="{x:Static p:Resources.ui_autostart}">
|
||||
<ui:ToggleSwitch x:Name="switchAutostart" IsChecked="False" Click="switchAutostart_Click" />
|
||||
</ui:CardControl>
|
||||
<ui:Snackbar x:Name="snackbarInfo" Timeout="0"/>
|
||||
</Grid>
|
||||
</ui:UiPage>
|
||||
|
|
|
@ -8,6 +8,8 @@ using System.Text.RegularExpressions;
|
|||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Wpf.Ui.Controls;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
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.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
|
||||
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();
|
||||
}
|
||||
|
@ -369,9 +371,34 @@ namespace EnvyUpdate
|
|||
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(new Action(() => {
|
||||
buttonDownload.IsEnabled = true;
|
||||
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>
|
||||
/// Looks up a localized string similar to Preference reset..
|
||||
/// </summary>
|
||||
|
|
|
@ -123,6 +123,18 @@
|
|||
<data name="exit_confirm" xml:space="preserve">
|
||||
<value>EnvyUpdate schließen?</value>
|
||||
</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">
|
||||
<value>Einstellung zurückgesetzt.</value>
|
||||
</data>
|
||||
|
|
|
@ -123,6 +123,18 @@
|
|||
<data name="exit_confirm" xml:space="preserve">
|
||||
<value>Exit EnvyUpdate?</value>
|
||||
</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">
|
||||
<value>Preference reset.</value>
|
||||
</data>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using IWshRuntimeLibrary;
|
||||
using EnvyUpdate.Properties;
|
||||
using IWshRuntimeLibrary;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
@ -7,7 +8,9 @@ using System.Linq;
|
|||
using System.Management;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace EnvyUpdate
|
||||
|
|
Reference in a new issue