move SheepIt settings to global settings
This commit is contained in:
29
Views/GlobalSettingsWindow.axaml
Normal file
29
Views/GlobalSettingsWindow.axaml
Normal file
@@ -0,0 +1,29 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:UnifiedFarmLauncher.ViewModels"
|
||||
x:Class="UnifiedFarmLauncher.Views.GlobalSettingsWindow"
|
||||
x:DataType="vm:GlobalSettingsViewModel"
|
||||
Title="Global Settings"
|
||||
Width="500" Height="300"
|
||||
MinWidth="400" MinHeight="250">
|
||||
<Grid RowDefinitions="Auto,*,Auto" Margin="10">
|
||||
<!-- Settings Content -->
|
||||
<TabControl Grid.Row="1" Margin="0,10">
|
||||
<TabItem Header="SheepIt">
|
||||
<StackPanel Margin="10" Spacing="10">
|
||||
<TextBlock Text="Username:"/>
|
||||
<TextBox Name="SheepItUsernameTextBox" Text="{Binding SheepItUsername}"/>
|
||||
|
||||
<TextBlock Text="Render Key:" Margin="0,10,0,0"/>
|
||||
<TextBox Name="SheepItRenderKeyTextBox" Text="{Binding SheepItRenderKey}" PasswordChar="*"/>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2" Spacing="10" Margin="0,10,0,0">
|
||||
<Button Name="OkButton" Content="OK" Width="80" IsDefault="True"/>
|
||||
<Button Name="CancelButton" Content="Cancel" Width="80" IsCancel="True"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
61
Views/GlobalSettingsWindow.axaml.cs
Normal file
61
Views/GlobalSettingsWindow.axaml.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@
|
||||
<Button Name="StartWorkerButton" Content="Start" Margin="5" Width="80"/>
|
||||
<Button Name="StopWorkerButton" Content="Stop" Margin="5" Width="80"/>
|
||||
<Button Name="AttachWorkerButton" Content="Attach" Margin="5" Width="80"/>
|
||||
<Separator Margin="10,0"/>
|
||||
<Button Name="SettingsButton" Content="Settings" Margin="5" Width="80"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Worker Type Filter -->
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace UnifiedFarmLauncher.Views
|
||||
this.FindControl<Button>("StartWorkerButton")!.Click += StartWorkerButton_Click;
|
||||
this.FindControl<Button>("StopWorkerButton")!.Click += StopWorkerButton_Click;
|
||||
this.FindControl<Button>("AttachWorkerButton")!.Click += AttachWorkerButton_Click;
|
||||
this.FindControl<Button>("SettingsButton")!.Click += SettingsButton_Click;
|
||||
this.FindControl<TabControl>("WorkerTypeTabs")!.SelectionChanged += WorkerTypeTabs_SelectionChanged;
|
||||
this.FindControl<DataGrid>("WorkersGrid")!.SelectionChanged += WorkersGrid_SelectionChanged;
|
||||
}
|
||||
@@ -199,6 +200,12 @@ namespace UnifiedFarmLauncher.Views
|
||||
}
|
||||
}
|
||||
|
||||
private async void SettingsButton_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new GlobalSettingsWindow();
|
||||
await dialog.ShowDialogAsync(this);
|
||||
}
|
||||
|
||||
private void WorkersGrid_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (DataContext is MainWindowViewModel vm)
|
||||
|
||||
@@ -42,11 +42,11 @@
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Text="Username:" IsVisible="{Binding HasSheepIt}" Margin="0,10,0,0"/>
|
||||
<TextBox Name="SheepItUsernameTextBox" Text="{Binding SheepItUsername}" IsVisible="{Binding HasSheepIt}"/>
|
||||
|
||||
<TextBlock Text="Render Key:" IsVisible="{Binding HasSheepIt}" Margin="0,10,0,0"/>
|
||||
<TextBox Name="SheepItRenderKeyTextBox" Text="{Binding SheepItRenderKey}" IsVisible="{Binding HasSheepIt}" PasswordChar="*"/>
|
||||
<TextBlock Text="Note: Username and Render Key are configured in Global Settings."
|
||||
IsVisible="{Binding HasSheepIt}"
|
||||
Margin="0,10,0,0"
|
||||
Foreground="Gray"
|
||||
TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user