add version skipping

This commit is contained in:
Jakob 2022-05-21 22:49:43 +02:00
parent 80badd436e
commit 25fa94144b
6 changed files with 98 additions and 8 deletions

View file

@ -7,7 +7,7 @@
xmlns:p="clr-namespace:EnvyUpdate.Properties"
xmlns:tb="http://www.hardcodet.net/taskbar"
mc:Ignorable="d"
Title="EnvyUpdate" Height="270" Width="300" Icon="icon.ico" StateChanged="Window_StateChanged" Closing="Window_Closing" ResizeMode="CanMinimize">
Title="EnvyUpdate" Height="270" Width="389" Icon="icon.ico" StateChanged="Window_StateChanged" Closing="Window_Closing" ResizeMode="CanMinimize">
<Grid Margin="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="17*"/>
@ -23,8 +23,9 @@
<TextBlock x:Name="textblockGPUName" Margin="10,14,35,0" TextWrapping="Wrap" Text="GPU..." Height="16" VerticalAlignment="Top" TextAlignment="Center" Grid.RowSpan="2" FontWeight="Bold"/>
<TextBlock HorizontalAlignment="Left" Margin="10,19,0,0" TextWrapping="Wrap" FontWeight="Bold" Width="140" Height="16" VerticalAlignment="Top" Grid.Row="1" Text="{x:Static p:Resources.ui_localdriver_type}"/>
<TextBlock x:Name="textblockLocalType" HorizontalAlignment="Right" Margin="0,19,10,0" TextWrapping="Wrap" Width="134" Height="16" VerticalAlignment="Top" TextAlignment="Right" Grid.Row="1"><Run Text="&lt;none&gt;"/><LineBreak/><Run/></TextBlock>
<RadioButton x:Name="radioGRD" Content="Game Ready Driver" HorizontalAlignment="Left" Margin="10,40,0,0" Grid.Row="1" VerticalAlignment="Top" IsChecked="True" Checked="radioGRD_Checked"/>
<RadioButton x:Name="radioGRD" Content="Game Ready Driver" HorizontalAlignment="Left" Margin="10,40,0,0" Grid.Row="1" VerticalAlignment="Top" Checked="radioGRD_Checked"/>
<RadioButton x:Name="radioSD" Content="Studio Driver" HorizontalAlignment="Left" Margin="10,60,0,0" Grid.Row="1" VerticalAlignment="Top" Checked="radioSD_Checked"/>
<CheckBox x:Name="chkAutostart" Content="{x:Static p:Resources.ui_autostart}" HorizontalAlignment="Left" Margin="10,131,0,0" Grid.Row="1" VerticalAlignment="Top" Click="chkAutostart_Click"/>
<Button x:Name="buttonSkip" Content="{x:Static p:Resources.ui_skipversion}" Margin="0,131,10,0" Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Right" Click="buttonSkip_Click" IsEnabled="False"/>
</Grid>
</Window>

View file

@ -20,6 +20,7 @@ namespace EnvyUpdate
private string gpuURL = null;
private string[] arguments = null;
private bool isDebug = false;
private string skippedVer = null;
public MainWindow()
{
@ -122,6 +123,11 @@ namespace EnvyUpdate
if (File.Exists(GlobalVars.exepath + "sd.envy"))
radioSD.IsChecked = true;
else
radioGRD.IsChecked = true;
if (File.Exists(GlobalVars.exepath + "skip.envy"))
skippedVer = File.ReadLines(GlobalVars.exepath + "skip.envy").First();
// This little bool check is necessary for debug mode on systems without an Nvidia GPU.
if (!isDebug)
@ -172,27 +178,56 @@ namespace EnvyUpdate
{
textblockOnline.Foreground = Brushes.Red;
buttonDL.IsEnabled = true;
if (skippedVer == null)
{
buttonSkip.Content = Properties.Resources.ui_skipversion;
buttonSkip.IsEnabled = true;
}
else
buttonSkip.Content = Properties.Resources.ui_skipped;
if (skippedVer != onlineDriv)
Notify.ShowDrivUpdatePopup();
}
else
{
buttonSkip.IsEnabled = false;
textblockOnline.Foreground = Brushes.Green;
}
}
catch (FormatException)
{
//Thank you locales. Some languages need , instead of .
//Thank you locales. Some languages need , instead of . for proper parsing
string cLocalDriv = localDriv.Replace('.', ',');
string cOnlineDriv = onlineDriv.Replace('.', ',');
if (float.Parse(cLocalDriv) < float.Parse(cOnlineDriv))
{
textblockOnline.Foreground = Brushes.Red;
buttonDL.IsEnabled = true;
if (skippedVer == null)
buttonSkip.IsEnabled = true;
else
buttonSkip.Content = Properties.Resources.ui_skipped;
if (skippedVer != onlineDriv)
Notify.ShowDrivUpdatePopup();
}
else
{
buttonSkip.IsEnabled = false;
textblockOnline.Foreground = Brushes.Green;
}
}
//Check for different version than skipped version
if (skippedVer != onlineDriv)
{
skippedVer = null;
if (File.Exists(GlobalVars.exepath + "skip.envy"))
File.Delete(GlobalVars.exepath + "skip.envy");
buttonSkip.Content = Properties.Resources.ui_skipversion;
buttonSkip.IsEnabled = true;
}
}
private void buttonDL_Click(object sender, RoutedEventArgs e)
{
Process.Start(gpuURL);
@ -270,5 +305,14 @@ namespace EnvyUpdate
Util.CreateShortcut("EnvyUpdate", Environment.GetFolderPath(Environment.SpecialFolder.Startup), GlobalVars.exeloc, "NVidia Update Checker", "/minimize");
}
}
private void buttonSkip_Click(object sender, RoutedEventArgs e)
{
skippedVer = onlineDriv;
File.WriteAllText(GlobalVars.exepath + "skip.envy", onlineDriv);
buttonSkip.IsEnabled = false;
buttonSkip.Content = Properties.Resources.ui_skipped;
MessageBox.Show(Properties.Resources.skip_confirm);
}
}
}

View file

@ -49,5 +49,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.12")]
[assembly: AssemblyFileVersion("2.12")]
[assembly: AssemblyVersion("2.13")]
[assembly: AssemblyFileVersion("2.13")]

View file

@ -19,7 +19,7 @@ namespace EnvyUpdate.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
@ -123,6 +123,15 @@ namespace EnvyUpdate.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Version was skipped. Update popups will be disabled until a new version releases..
/// </summary>
public static string skip_confirm {
get {
return ResourceManager.GetString("skip_confirm", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Run at Windows startup.
/// </summary>
@ -195,6 +204,24 @@ namespace EnvyUpdate.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Version skipped.
/// </summary>
public static string ui_skipped {
get {
return ResourceManager.GetString("ui_skipped", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Skip this version.
/// </summary>
public static string ui_skipversion {
get {
return ResourceManager.GetString("ui_skipversion", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Are you sure you want to uninstall EnvyUpdate?.
/// </summary>

View file

@ -138,6 +138,9 @@
<data name="no_compatible_gpu" xml:space="preserve">
<value>Keine NVIDIA GPU gefunden. EnvyUpdate wird sich nun schließen.</value>
</data>
<data name="skip_confirm" xml:space="preserve">
<value>Version übersprungen. Aktualisierungsbenachrichtigungen werden bis zur nächsten Version deaktiviert.</value>
</data>
<data name="ui_autostart" xml:space="preserve">
<value>Beim Start von Windows ausführen</value>
</data>
@ -162,6 +165,12 @@
<data name="ui_onlinedriver" xml:space="preserve">
<value>Online Treiberversion:</value>
</data>
<data name="ui_skipped" xml:space="preserve">
<value>Version übersprungen</value>
</data>
<data name="ui_skipversion" xml:space="preserve">
<value>Diese Version überspringen</value>
</data>
<data name="uninstall_confirm" xml:space="preserve">
<value>Sind Sie sich sicher, dass Sie EnvyUpdate deinstallieren wollen?</value>
</data>

View file

@ -138,6 +138,9 @@
<data name="no_compatible_gpu" xml:space="preserve">
<value>No NVIDIA GPU found. Application will exit.</value>
</data>
<data name="skip_confirm" xml:space="preserve">
<value>Version was skipped. Update popups will be disabled until a new version releases.</value>
</data>
<data name="ui_autostart" xml:space="preserve">
<value>Run at Windows startup</value>
</data>
@ -162,6 +165,12 @@
<data name="ui_onlinedriver" xml:space="preserve">
<value>Online driver version:</value>
</data>
<data name="ui_skipped" xml:space="preserve">
<value>Version skipped</value>
</data>
<data name="ui_skipversion" xml:space="preserve">
<value>Skip this version</value>
</data>
<data name="uninstall_confirm" xml:space="preserve">
<value>Are you sure you want to uninstall EnvyUpdate?</value>
</data>