Dunkelmodus über neuen Einstellungen-Tab "Darstellung" (Systemvorgabe/Hell/Dunkel), Fenstergröße/Maximiert-Status wird über Sitzungen hinweg gemerkt (bewusst ohne Fensterposition), und ein generischer Snapshot-basierter Papierkorb (30 Tage) für Sitzpläne, Noten, Notenschlüssel-Vorlagen, Aufgaben und Zeiteinträge. Details und bewusste Scope-Entscheidungen (Spaltenbreiten zurückgestellt, Farb-Audit für Dunkelmodus offen, welche Entitäten der Papierkorb abdeckt) in TODO.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System.Text.Json;
|
|
|
|
namespace LehrerApp.Desktop.Services;
|
|
|
|
/// <summary>Systemvorgabe folgt <see cref="Avalonia.Styling.ThemeVariant.Default"/> (bisheriges,
|
|
/// unverändertes Verhalten); Hell/Dunkel erzwingen die jeweilige Variante unabhängig vom
|
|
/// Betriebssystem.</summary>
|
|
public enum AppTheme { System, Light, Dark }
|
|
|
|
internal sealed class AppearanceSettingsConfig
|
|
{
|
|
public AppTheme Theme { get; set; } = AppTheme.System;
|
|
}
|
|
|
|
/// <summary>Merkt sich die gewählte Darstellung (12.4) über Sitzungen hinweg.</summary>
|
|
public sealed class AppearanceSettingsService
|
|
{
|
|
private readonly string _configPath;
|
|
|
|
public AppearanceSettingsService(string appDataPath) =>
|
|
_configPath = Path.Combine(appDataPath, "appearancesettings.json");
|
|
|
|
public AppTheme Load()
|
|
{
|
|
try
|
|
{
|
|
if (File.Exists(_configPath))
|
|
return JsonSerializer.Deserialize<AppearanceSettingsConfig>(File.ReadAllText(_configPath))
|
|
?.Theme ?? AppTheme.System;
|
|
}
|
|
catch { /* beschädigte Konfiguration -> Systemvorgabe */ }
|
|
return AppTheme.System;
|
|
}
|
|
|
|
public void Save(AppTheme theme) =>
|
|
File.WriteAllText(_configPath, JsonSerializer.Serialize(new AppearanceSettingsConfig { Theme = theme }));
|
|
}
|
|
|
|
// ComboBox-Anzeige: deutsche Beschriftung statt des rohen Enum-Namens (etabliertes Muster, siehe
|
|
// z.B. NiveauDisplay/GradeCategoryDisplay).
|
|
public static class AppThemeDisplay
|
|
{
|
|
public static string Label(AppTheme theme) => theme switch
|
|
{
|
|
AppTheme.Light => "Hell",
|
|
AppTheme.Dark => "Dunkel",
|
|
_ => "Systemvorgabe",
|
|
};
|
|
|
|
public static string[] Options { get; } = Enum.GetValues<AppTheme>().Select(Label).ToArray();
|
|
|
|
public static AppTheme FromLabel(string? label) =>
|
|
Enum.GetValues<AppTheme>().FirstOrDefault(t => Label(t) == label, AppTheme.System);
|
|
}
|