Neuer Dialog "Deckblätter…" bei Klausuren, Punktetabelle als Drawing mit festen Spaltenbreiten, FLOWDRAWBOX-Attribut fit=content, Stapel-Rendering mit Seitenzahl je Datensatz, Kursbezeichnung und konfigurierbares Kürzel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using System.Text.Json;
|
|
|
|
namespace LehrerApp.Desktop.Services;
|
|
|
|
internal sealed class TeacherSettingsConfig
|
|
{
|
|
public string Abbreviation { get; set; } = "";
|
|
}
|
|
|
|
/// <summary>Angaben zur Lehrkraft, die auf Formularen erscheinen (bisher nur das Kürzel fürs
|
|
/// Klausur-Deckblatt) — aus der Konfiguration statt fest in der Vorlage, damit eine weitergegebene
|
|
/// Vorlage nicht das Kürzel ihres Erstellers trägt.</summary>
|
|
public sealed class TeacherSettingsService
|
|
{
|
|
private readonly string _configPath;
|
|
|
|
public TeacherSettingsService(string appDataPath) =>
|
|
_configPath = Path.Combine(appDataPath, "teachersettings.json");
|
|
|
|
public string LoadAbbreviation()
|
|
{
|
|
try
|
|
{
|
|
if (File.Exists(_configPath))
|
|
return JsonSerializer.Deserialize<TeacherSettingsConfig>(File.ReadAllText(_configPath))
|
|
?.Abbreviation ?? "";
|
|
}
|
|
catch { /* beschädigte Konfiguration -> leer */ }
|
|
return "";
|
|
}
|
|
|
|
public void SaveAbbreviation(string abbreviation)
|
|
{
|
|
try
|
|
{
|
|
File.WriteAllText(_configPath,
|
|
JsonSerializer.Serialize(new TeacherSettingsConfig { Abbreviation = abbreviation.Trim() }));
|
|
}
|
|
catch { /* Einstellung ist Komfort — Fehler beim Schreiben nicht an die UI durchreichen */ }
|
|
}
|
|
}
|