prep-work for adding auto updates option

This commit is contained in:
WeeXnes 2024-02-07 10:27:35 +01:00
parent 56174d8003
commit 48ef43f31e
4 changed files with 26 additions and 0 deletions

View file

@ -18,6 +18,7 @@ namespace WeeXnes.Core
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
public static UpdateVar<string> AppDataPathRPC = new UpdateVar<string>();
public static UpdateVar<string> AppDataPathKEY = new UpdateVar<string>();
public static UpdateVar<bool> checkUpdateOnStartup = new UpdateVar<bool>();
public static string SettingsFile = "settings.ini";
public class Defaults
{

View file

@ -18,6 +18,7 @@ namespace WeeXnes.Core
public const string Section = "GENERAL";
public const string RpcFilesPath = "RpcFilesPath";
public const string KeyFilesPath = "KeyFilesPath";
public const string StartupUpdateCheck = "StartupUpdateCheck";
}
public static class KeyManager
{
@ -87,6 +88,14 @@ namespace WeeXnes.Core
Global.AppDataPathKEY.Value
);
};
Global.checkUpdateOnStartup.ValueChanged += () =>
{
SettingsView.Data.settingsFile.SetValue(
Data.General.Section,
Data.General.StartupUpdateCheck,
Global.checkUpdateOnStartup.Value.ToString()
);
};
}
}
}

View file

@ -114,6 +114,11 @@
<StackPanel Orientation="Vertical" Visibility="Collapsed" Name="DebugOptions">
<Label Content="Debug" HorizontalAlignment="Center"/>
<CheckBox Content="Check for updates on Startup"
Name="CheckboxAutoUpdate"
Checked="CheckboxAutoUpdate_OnChecked"
Unchecked="CheckboxAutoUpdate_OnUnchecked"/>
<ui:CardAction Icon="ErrorCircle24"
Click="dbg_throwException">
<StackPanel>

View file

@ -50,7 +50,18 @@ namespace WeeXnes.Views.Settings
{
KeyManagerView.Data.censorKeys.Value = false;
}
private void CheckboxAutoUpdate_OnChecked(object sender, RoutedEventArgs e)
{
Global.checkUpdateOnStartup.Value = true;
}
private void CheckboxAutoUpdate_OnUnchecked(object sender, RoutedEventArgs e)
{
Global.checkUpdateOnStartup.Value = false;
}
private void ButtonCheckForUpdates_OnClick(object sender, RoutedEventArgs e)