feat(settings): add the settings page and speaking reminders

The main window shows a dialog, optionally with a bing sound, shortly before
a news or moderator item goes on air. The settings page sits in the footer
of the navigation; the empty home page is gone and the app starts on the
schedule. Pages switch off the navigation view's outer scrolling so their
lists stay virtualized.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
fraujulianandClaude Fable 5.2 committed 2026-11-23 14:22:52 +01:00
1 parent 80292ac90b
commit 54b02c3fd6
6 files changed
+279 -28

No files matched your search

-11
View File
@@ -1,11 +0,0 @@
<Page x:Class="Radiosender.Views.Pages.HomePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="Home">
<StackPanel Margin="24">
<ui:TextBlock FontTypography="Title" Text="Radiosender" />
<ui:TextBlock Margin="0,8,0,0" TextWrapping="Wrap"
Text="Add music on the Import page, then plan and start a broadcast on the Schedule page." />
</StackPanel>
</Page>
@@ -1,11 +0,0 @@
using System.Windows.Controls;
namespace Radiosender.Views.Pages;
public partial class HomePage : Page
{
public HomePage()
{
InitializeComponent();
}
}
@@ -0,0 +1,136 @@
<Page x:Class="Radiosender.Views.Pages.SettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="Einstellungen"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Loaded="OnLoaded">
<Page.Resources>
<Style x:Key="Card" TargetType="Border">
<Setter Property="Margin" Value="0,0,0,12" />
<Setter Property="Padding" Value="16" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="{DynamicResource CardStrokeColorDefaultBrush}" />
<Setter Property="Background" Value="{DynamicResource CardBackgroundFillColorDefaultBrush}" />
</Style>
<Style x:Key="Seconds" TargetType="ui:NumberBox" BasedOn="{StaticResource {x:Type ui:NumberBox}}">
<Setter Property="Width" Value="130" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Minimum" Value="5" />
<Setter Property="Maximum" Value="300" />
<Setter Property="SmallChange" Value="5" />
<Setter Property="MaxDecimalPlaces" Value="0" />
<Setter Property="ClearButtonEnabled" Value="False" />
</Style>
<Style x:Key="Minutes" TargetType="ui:NumberBox" BasedOn="{StaticResource {x:Type ui:NumberBox}}">
<Setter Property="Width" Value="130" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Minimum" Value="0" />
<Setter Property="Maximum" Value="60" />
<Setter Property="SmallChange" Value="1" />
<Setter Property="MaxDecimalPlaces" Value="0" />
<Setter Property="ClearButtonEnabled" Value="False" />
</Style>
</Page.Resources>
<StackPanel MaxWidth="640" Margin="24" HorizontalAlignment="Left">
<ui:InfoBar x:Name="Message" Margin="0,0,0,12" IsClosable="True" IsOpen="False" />
<!-- Speaking alerts: one block per kind -->
<Border Style="{StaticResource Card}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ui:ToggleSwitch x:Name="NewsAlertSwitch" Grid.ColumnSpan="2" Content="Hinweis vor Nachrichten" />
<Label Grid.Row="1" Margin="0,12,0,0" VerticalAlignment="Center"
Content="Sekunden vor dem Start"
Target="{Binding ElementName=NewsSecondsBox}"
IsEnabled="{Binding IsChecked, ElementName=NewsAlertSwitch}" />
<ui:NumberBox x:Name="NewsSecondsBox" Grid.Row="1" Grid.Column="1" Margin="0,12,0,0"
Style="{StaticResource Seconds}"
AutomationProperties.Name="Sekunden vor Nachrichten"
IsEnabled="{Binding IsChecked, ElementName=NewsAlertSwitch}" />
<CheckBox x:Name="NewsSoundBox" Grid.Row="2" Grid.ColumnSpan="2" Margin="0,8,0,0"
Content="Bing-Ton abspielen"
IsEnabled="{Binding IsChecked, ElementName=NewsAlertSwitch}" />
</Grid>
</Border>
<Border Style="{StaticResource Card}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ui:ToggleSwitch x:Name="ModeratorAlertSwitch" Grid.ColumnSpan="2" Content="Hinweis vor Moderation" />
<Label Grid.Row="1" Margin="0,12,0,0" VerticalAlignment="Center"
Content="Sekunden vor dem Start"
Target="{Binding ElementName=ModeratorSecondsBox}"
IsEnabled="{Binding IsChecked, ElementName=ModeratorAlertSwitch}" />
<ui:NumberBox x:Name="ModeratorSecondsBox" Grid.Row="1" Grid.Column="1" Margin="0,12,0,0"
Style="{StaticResource Seconds}"
AutomationProperties.Name="Sekunden vor Moderation"
IsEnabled="{Binding IsChecked, ElementName=ModeratorAlertSwitch}" />
<CheckBox x:Name="ModeratorSoundBox" Grid.Row="2" Grid.ColumnSpan="2" Margin="0,8,0,0"
Content="Bing-Ton abspielen"
IsEnabled="{Binding IsChecked, ElementName=ModeratorAlertSwitch}" />
</Grid>
</Border>
<!-- Minutes per hour -->
<Border Style="{StaticResource Card}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ui:TextBlock Grid.ColumnSpan="2" FontTypography="BodyStrong" Text="Minuten pro Stunde" />
<Label Grid.Row="1" Margin="0,12,0,0" VerticalAlignment="Center"
Content="Nachrichten" Target="{Binding ElementName=NewsMinutesBox}" />
<ui:NumberBox x:Name="NewsMinutesBox" Grid.Row="1" Grid.Column="1" Margin="0,12,0,0"
Style="{StaticResource Minutes}" Minimum="2"
AutomationProperties.Name="Nachrichten-Minuten pro Stunde" />
<Label Grid.Row="2" Margin="0,8,0,0" VerticalAlignment="Center"
Content="Moderation" Target="{Binding ElementName=ModeratorMinutesBox}" />
<ui:NumberBox x:Name="ModeratorMinutesBox" Grid.Row="2" Grid.Column="1" Margin="0,8,0,0"
Style="{StaticResource Minutes}"
AutomationProperties.Name="Moderations-Minuten pro Stunde" />
<Label Grid.Row="3" Margin="0,8,0,0" VerticalAlignment="Center"
Content="Werbung" Target="{Binding ElementName=AdMinutesBox}" />
<ui:NumberBox x:Name="AdMinutesBox" Grid.Row="3" Grid.Column="1" Margin="0,8,0,0"
Style="{StaticResource Minutes}"
AutomationProperties.Name="Werbe-Minuten pro Stunde" />
<ui:TextBlock Grid.Row="4" Grid.ColumnSpan="2" Margin="0,12,0,0" TextWrapping="Wrap"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="Sollwerte, zusammen höchstens 60 Minuten. Gilt für den nächsten Plan." />
</Grid>
</Border>
<StackPanel Margin="0,4,0,0" Orientation="Horizontal">
<ui:Button Appearance="Primary" MinWidth="110" Content="Speichern" Icon="{ui:SymbolIcon Save24}" Click="OnSave" />
<ui:Button Margin="8,0,0,0" MinWidth="110" Content="Zurücksetzen" Icon="{ui:SymbolIcon ArrowReset24}"
ToolTip="Setzt die Standardwerte ins Formular. Mit Speichern übernehmen."
Click="OnReset" />
</StackPanel>
</StackPanel>
</Page>
@@ -0,0 +1,79 @@
using System.IO;
using System.Windows;
using System.Windows.Controls;
using Radiosender.Services;
using Wpf.Ui.Controls;
namespace Radiosender.Views.Pages;
/// <summary>Edits <see cref="AppSettings"/>. Nothing changes until Save.</summary>
public partial class SettingsPage : Page
{
public SettingsPage() => InitializeComponent();
// Loaded fires on every navigation to the page, so unsaved edits from an earlier visit are dropped.
private void OnLoaded(object sender, RoutedEventArgs e) => Show(App.Settings);
private void Show(AppSettings settings)
{
NewsAlertSwitch.IsChecked = settings.NewsAlert;
NewsSecondsBox.Value = settings.NewsAlertSeconds;
NewsSoundBox.IsChecked = settings.NewsAlertSound;
ModeratorAlertSwitch.IsChecked = settings.ModeratorAlert;
ModeratorSecondsBox.Value = settings.ModeratorAlertSeconds;
ModeratorSoundBox.IsChecked = settings.ModeratorAlertSound;
NewsMinutesBox.Value = settings.NewsMinutesPerHour;
ModeratorMinutesBox.Value = settings.ModeratorMinutesPerHour;
AdMinutesBox.Value = settings.AdMinutesPerHour;
}
// An emptied number box counts as its default.
private static AppSettings Defaults { get; } = new();
private AppSettings Read() => new()
{
NewsAlert = NewsAlertSwitch.IsChecked == true,
NewsAlertSeconds = (int)(NewsSecondsBox.Value ?? Defaults.NewsAlertSeconds),
NewsAlertSound = NewsSoundBox.IsChecked == true,
ModeratorAlert = ModeratorAlertSwitch.IsChecked == true,
ModeratorAlertSeconds = (int)(ModeratorSecondsBox.Value ?? Defaults.ModeratorAlertSeconds),
ModeratorAlertSound = ModeratorSoundBox.IsChecked == true,
NewsMinutesPerHour = (int)(NewsMinutesBox.Value ?? Defaults.NewsMinutesPerHour),
ModeratorMinutesPerHour = (int)(ModeratorMinutesBox.Value ?? Defaults.ModeratorMinutesPerHour),
AdMinutesPerHour = (int)(AdMinutesBox.Value ?? Defaults.AdMinutesPerHour),
};
private void OnSave(object sender, RoutedEventArgs e)
{
var settings = Read();
if (settings.Validate() is { } problem)
{
ShowMessage(InfoBarSeverity.Error, "Nicht gespeichert", problem);
return;
}
try
{
App.SaveSettings(settings);
ShowMessage(InfoBarSeverity.Success, "Gespeichert", "Minuten pro Stunde gelten für den nächsten Plan.");
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
ShowMessage(InfoBarSeverity.Error, "Nicht gespeichert", ex.Message);
}
}
private void OnReset(object sender, RoutedEventArgs e)
{
Show(Defaults);
ShowMessage(InfoBarSeverity.Informational, "Standardwerte eingesetzt", "Mit Speichern übernehmen.");
}
private void ShowMessage(InfoBarSeverity severity, string title, string text)
{
Message.Severity = severity;
Message.Title = title;
Message.Message = text;
Message.IsOpen = true;
}
}