move SheepIt settings to global settings

This commit is contained in:
Nathan
2025-12-17 16:19:08 -07:00
parent 03b3ae58f4
commit 202ad49f48
11 changed files with 268 additions and 34 deletions

View File

@@ -0,0 +1,61 @@
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Interactivity;
using UnifiedFarmLauncher.Services;
using UnifiedFarmLauncher.ViewModels;
namespace UnifiedFarmLauncher.Views
{
public partial class GlobalSettingsWindow : Window
{
private readonly GlobalSettingsViewModel _viewModel;
private bool _result;
public GlobalSettingsWindow()
{
InitializeComponent();
var configService = new ConfigService();
_viewModel = new GlobalSettingsViewModel(configService);
DataContext = _viewModel;
SetupEventHandlers();
}
private void InitializeComponent()
{
Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(this);
}
private void SetupEventHandlers()
{
this.FindControl<Button>("OkButton")!.Click += OkButton_Click;
this.FindControl<Button>("CancelButton")!.Click += CancelButton_Click;
}
private void OkButton_Click(object? sender, RoutedEventArgs e)
{
try
{
_viewModel.Save();
_result = true;
Close();
}
catch (System.Exception ex)
{
// Could show error message here
System.Diagnostics.Debug.WriteLine($"Failed to save global settings: {ex.Message}");
}
}
private void CancelButton_Click(object? sender, RoutedEventArgs e)
{
_result = false;
Close();
}
public async Task<bool> ShowDialogAsync(Window parent)
{
await base.ShowDialog(parent);
return _result;
}
}
}