feat(settings): store alert and minutes-per-hour settings
Settings live in settings.json next to the database. News, moderator talk and ads together can take at most 60 minutes per hour. The app also follows the Windows light, dark or high-contrast theme at startup. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
65c0e39e47
commit
f0726bc9fa
3 files changed
+180
-1
No files matched your search
@@ -11,11 +11,29 @@ public partial class App : Application
|
||||
/// <summary>App-wide, so a running broadcast keeps going while the user switches pages.</summary>
|
||||
public static ScheduleController Schedule { get; private set; } = null!;
|
||||
|
||||
public static AppSettings Settings { get; private set; } = new();
|
||||
|
||||
private static readonly ScheduleGenerator Generator = new();
|
||||
|
||||
/// <summary>Stores the settings and applies them: alerts at once, minutes per hour from the next plan on.</summary>
|
||||
/// <exception cref="System.IO.IOException">The settings file cannot be written.</exception>
|
||||
/// <exception cref="UnauthorizedAccessException">The settings file cannot be written.</exception>
|
||||
public static void SaveSettings(AppSettings settings)
|
||||
{
|
||||
settings.Save(AppSettings.DefaultPath);
|
||||
Settings = settings;
|
||||
Generator.Options = settings.ToScheduleOptions();
|
||||
}
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
Settings = AppSettings.Load(AppSettings.DefaultPath);
|
||||
Generator.Options = Settings.ToScheduleOptions();
|
||||
// Creates the database file and table on first start.
|
||||
Songs = new SongRepository(SongRepository.DefaultDatabasePath);
|
||||
Schedule = new ScheduleController(Songs, new ScheduleGenerator(), new PlaybackEngine(), () => DateTime.Now);
|
||||
Schedule = new ScheduleController(Songs, Generator, new PlaybackEngine(), () => DateTime.Now);
|
||||
// Follow the Windows setting: light, dark or a high-contrast theme.
|
||||
Wpf.Ui.Appearance.ApplicationThemeManager.ApplySystemTheme();
|
||||
base.OnStartup(e);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user