Files
UFL/ViewModels/GlobalSettingsViewModel.cs
2025-12-17 16:23:40 -07:00

53 lines
1.5 KiB
C#

using UnifiedFarmLauncher.Models;
using UnifiedFarmLauncher.Services;
namespace UnifiedFarmLauncher.ViewModels
{
public class GlobalSettingsViewModel : ViewModelBase
{
private readonly ConfigService _configService;
private string _sheepItUsername = string.Empty;
private string _sheepItRenderKey = string.Empty;
private bool _isRenderKeyVisible = false;
public GlobalSettingsViewModel(ConfigService configService)
{
_configService = configService;
LoadSettings();
}
public string SheepItUsername
{
get => _sheepItUsername;
set => SetAndRaise(ref _sheepItUsername, value);
}
public string SheepItRenderKey
{
get => _sheepItRenderKey;
set => SetAndRaise(ref _sheepItRenderKey, value);
}
public bool IsRenderKeyVisible
{
get => _isRenderKeyVisible;
set => SetAndRaise(ref _isRenderKeyVisible, value);
}
private void LoadSettings()
{
var config = _configService.Load();
SheepItUsername = config.GlobalSettings.SheepItUsername;
SheepItRenderKey = config.GlobalSettings.SheepItRenderKey;
}
public void Save()
{
var config = _configService.Load();
config.GlobalSettings.SheepItUsername = SheepItUsername;
config.GlobalSettings.SheepItRenderKey = SheepItRenderKey;
_configService.Save(config);
}
}
}