Updated MainWindow

Updated MainWindow.xaml with UI controls for FreeTubeSyncer application
settings.

Updated MainWindow.xaml.cs code behind file top handle logic of not
closing the app when the window is closed, and handling Saving and
Hiding of the Window when close is requestd.
This commit is contained in:
Mario Steele 2025-07-31 03:34:31 -05:00
parent 56432cd33d
commit b0ac6c1b7b
2 changed files with 66 additions and 6 deletions

View file

@ -1,9 +1,51 @@
<Window xmlns="https://github.com/avaloniaui" <suki:SukiWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" xmlns:suki="https://github.com/kikipoulet/SukiUI"
xmlns:vm="clr-namespace:FreeTubeSyncer.Models"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="345"
Width="400" Height="345"
x:Class="FreeTubeSyncer.MainWindow" x:Class="FreeTubeSyncer.MainWindow"
x:DataType="vm:AppSettings"
BackgroundStyle="GradientDarker"
CanResize="False"
CanMaximize="False"
Title="FreeTubeSyncer"> Title="FreeTubeSyncer">
Welcome to Avalonia!
</Window> <StackPanel Orientation="Vertical" Margin="10" Spacing="5">
<Label Content="Settings" FontSize="24"/>
<Separator/>
<Grid
ColumnDefinitions="182,*"
RowDefinitions="*,*">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="REST API Backend Server: " FontWeight="Bold"/>
<TextBox Grid.Row="0" Grid.Column="1" Watermark="http://localhost:8080" Text="{Binding RestBaseUrl, Mode=TwoWay}"/>
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="Refresh Interval: " FontWeight="Bold"/>
<NumericUpDown Grid.Row="1" Grid.Column="1" Watermark="30" suki:NumericUpDownExtensions.Unit="seconds" FormatString="N0" Value="{Binding CheckInterval, Mode=TwoWay}"/>
</Grid>
<Grid
ColumnDefinitions="170,*"
RowDefinitions="*,*,*">
<ToggleSwitch Grid.Row="0" Grid.Column="0" IsPressed="{Binding SyncHistory, Mode=TwoWay}" OnContent="Sync History" />
<ToggleSwitch Grid.Row="0" Grid.Column="1" IsPressed="{Binding SyncPlaylist, Mode=TwoWay}" OnContent="Sync Playlists"/>
<ToggleSwitch Grid.Row="1" Grid.Column="0" IsPressed="{Binding SyncProfile, Mode=TwoWay}" OnContent="Sync Profiles"/>
<ToggleSwitch Grid.Row="1" Grid.Column="1" IsPressed="{Binding SyncSearchHistory, Mode=TwoWay}" OnContent="Sync Search History"/>
<ToggleSwitch Grid.Row="2" Grid.Column="0" IsPressed="{Binding SyncSettings, Mode=TwoWay}" OnContent="Sync Settings"/>
</Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="10">
<Button
IsEnabled="{Binding SettingsDirty}"
Classes="Flat Accent"
Click="SaveSettings_OnClick"
Content="Save"/>
<Button
IsEnabled="True"
Classes="Danger"
Click="CloseWindow_OnClick"
Content="Cancel"/>
</StackPanel>
</StackPanel>
</suki:SukiWindow>

View file

@ -1,11 +1,29 @@
using Avalonia.Controls; using Avalonia.Interactivity;
using SukiUI.Controls;
namespace FreeTubeSyncer; namespace FreeTubeSyncer;
public partial class MainWindow : Window public partial class MainWindow : SukiWindow
{ {
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
this.Closing += (s, e) =>
{
((SukiWindow)s).Hide();
e.Cancel = true;
};
}
private void SaveSettings_OnClick(object? sender, RoutedEventArgs e)
{
App.GetApp().SaveSettings();
Hide();
}
private void CloseWindow_OnClick(object? sender, RoutedEventArgs e)
{
App.GetApp().ResetSettings();
Hide();
} }
} }