0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-13 09:50:44 -05:00
2024-06-17 11:34:06 -04:00

64 lines
1.7 KiB
C#

using Wpf.Ui.Appearance;
using Wpf.Ui.Controls;
namespace ReCodeItGUI_WPF.ViewModels.Pages
{
public partial class SettingsViewModel : ObservableObject, INavigationAware
{
private bool _isInitialized = false;
[ObservableProperty]
private string _appVersion = String.Empty;
[ObservableProperty]
private ApplicationTheme _currentTheme = ApplicationTheme.Unknown;
public void OnNavigatedTo()
{
if (!_isInitialized)
InitializeViewModel();
}
public void OnNavigatedFrom() { }
private void InitializeViewModel()
{
CurrentTheme = ApplicationThemeManager.GetAppTheme();
AppVersion = $"UiDesktopApp1 - {GetAssemblyVersion()}";
_isInitialized = true;
}
private string GetAssemblyVersion()
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString()
?? String.Empty;
}
[RelayCommand]
private void OnChangeTheme(string parameter)
{
switch (parameter)
{
case "theme_light":
if (CurrentTheme == ApplicationTheme.Light)
break;
ApplicationThemeManager.Apply(ApplicationTheme.Light);
CurrentTheme = ApplicationTheme.Light;
break;
default:
if (CurrentTheme == ApplicationTheme.Dark)
break;
ApplicationThemeManager.Apply(ApplicationTheme.Dark);
CurrentTheme = ApplicationTheme.Dark;
break;
}
}
}
}