diff --git a/.claude/settings.json b/.claude/settings.json index 311eb5d..620636a 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -1,7 +1,8 @@ { "permissions": { "allow": [ - "PowerShell(node D:\\\\Oculusquest\\\\Projekt\\\\_Tools\\\\Library\\\\tools\\\\project-check.mjs \"d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer\")" + "PowerShell(node D:\\\\Oculusquest\\\\Projekt\\\\_Tools\\\\Library\\\\tools\\\\project-check.mjs \"d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer\")", + "PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; git rm -q --cached tasks.json docs/screenshots/1.png; Remove-Item tasks.json, docs\\\\screenshots\\\\1.png; Add-Content .gitignore \"tasks.json\"; Get-ChildItem bin -Recurse -Filter tasks.json | Remove-Item; dotnet build ReminderOrganizer.csproj -nologo -v q 2>&1 | Select-String \"Fehler|error\" ; Test-Path \"$env:APPDATA\\\\ReminderOrganizer\")" ] } } diff --git a/.gitignore b/.gitignore index 2e4f0d4..f94f943 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ publish/ error.log nul Tests/TestResults/ +tasks.json +sprite-generator/output/ +__pycache__/ diff --git a/App.xaml b/App.xaml index 5eb0a96..e3e73f1 100644 --- a/App.xaml +++ b/App.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:converters="clr-namespace:ReminderOrganizer.Converters" - StartupUri="MainWindow.xaml"> + ShutdownMode="OnExplicitShutdown"> diff --git a/App.xaml.cs b/App.xaml.cs index 1c0cc4f..66b5216 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -16,8 +16,33 @@ namespace ReminderOrganizer { base.OnStartup(e); + // Only one instance: a second start would show duplicate reminders and race on tasks.json. + _singleInstance = new System.Threading.Mutex(true, "MichaelMedia.ReminderOrganizer", out var isFirst); + if (!isFirst) + { + Shutdown(); + return; + } + SetupExceptionHandling(); ServiceLocator.Initialize(); + + var main = new MainWindow(); + MainWindow = main; + // Autostart passes --minimized: start straight into the tray. + if (Array.IndexOf(e.Args, "--minimized") >= 0) + main.StartHidden(); + else + main.Show(); + } + + private System.Threading.Mutex? _singleInstance; + + protected override void OnExit(ExitEventArgs e) + { + Services.NotificationService.SharedTrayIcon?.Dispose(); + _singleInstance?.Dispose(); + base.OnExit(e); } private void SetupExceptionHandling() @@ -48,7 +73,8 @@ namespace ReminderOrganizer { try { - var logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "error.log"); + Directory.CreateDirectory(DataService.DefaultDataDirectory); + var logPath = Path.Combine(DataService.DefaultDataDirectory, "error.log"); var logEntry = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [{source}]\n{ex}\n\n"; File.AppendAllText(logPath, logEntry); } diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..221ed9f --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,27 @@ +# ReminderOrganizer – notes for Claude + +WPF (.NET 8, `net8.0-windows10.0.19041.0`), MVVM without a framework (`Core/ViewModelBase`, `RelayCommand`), +services through `ServiceLocator` (Microsoft.Extensions.DependencyInjection). + +## Layout +- `Models/ReminderModels.cs`: `ReminderTask`, `Folder`, `AppData`. The recurrence logic (`GetNextOccurrence(now)`, + `ProcessDue`) is pure and tested. +- `Services/`: `DataService` (JSON in %APPDATA%, atomic + serialized), `LocalizationService` (Locales are + **EmbeddedResource** `Locales..json`), `TaskCsv` + `Core/Csv` (import/export), `AutostartService` + (HKCU Run, `"exe" --minimized`), `NotificationService` (tray balloon). +- `Core/Theme.cs`: the only light/dark palette, used by MainWindow and the dialogs (`Theme.Apply(Resources, dark)`). +- `MainWindow.xaml`: custom chrome (WindowStyle=None). Icons are Segoe MDL2 glyphs or Path geometry, **no emojis** + (they don't follow the theme). +- `Tests/`: xUnit project, excluded from the app csproj via `Compile Remove`. + +## Rules +- Every new UI text goes in **both** `Locales/en.json` and `de.json`. The test `All_keys_used_in_code_exist` checks this. +- Never write data next to the exe (single-file/Program Files) – always use `DataService.DefaultDataDirectory`. + For screenshots/tests: set the environment variable `REMINDER_ORGANIZER_DATA` to a temp folder. +- Credits: "© year Michael Media" + Discord link (sidebar footer, File menu, csproj Company/Copyright). +- Run `dotnet test Tests\ReminderOrganizer.Tests.csproj` before each release. `release.bat` does this automatically. + +## Graphics +`sprite-generator\` = ComfyGen template (`_Tools\ComfyGen`). App icon: `gen generate icon` → `gen adopt --size 512 icon` +→ convert `Assets\Sprites\icon.png` to `Assets\app.ico` (Pillow, sizes 16–256). The csproj and MainWindow pick up +`Assets\app.ico` automatically (window, tray, exe). Without the file, the default icon is used. diff --git a/Core/Csv.cs b/Core/Csv.cs new file mode 100644 index 0000000..84bfb20 --- /dev/null +++ b/Core/Csv.cs @@ -0,0 +1,49 @@ +#nullable enable +using System.Collections.Generic; +using System.Text; + +namespace ReminderOrganizer.Core +{ + /// Minimal CSV for ';'-separated files with "quoted" fields (quotes doubled, newlines allowed). + public static class Csv + { + public const char Separator = ';'; + + public static string Escape(string? value) + { + if (string.IsNullOrEmpty(value)) return ""; + if (value.IndexOfAny(new[] { Separator, '"', '\n', '\r' }) >= 0) + return "\"" + value.Replace("\"", "\"\"") + "\""; + return value; + } + + public static List> Parse(string text) + { + var rows = new List>(); + var row = new List(); + var field = new StringBuilder(); + bool inQuotes = false; + + for (int i = 0; i < text.Length; i++) + { + char c = text[i]; + if (inQuotes) + { + if (c == '"') + { + if (i + 1 < text.Length && text[i + 1] == '"') { field.Append('"'); i++; } + else inQuotes = false; + } + else field.Append(c); + } + else if (c == '"') inQuotes = true; + else if (c == Separator) { row.Add(field.ToString()); field.Clear(); } + else if (c == '\r') { } + else if (c == '\n') { row.Add(field.ToString()); field.Clear(); rows.Add(row); row = new List(); } + else field.Append(c); + } + if (field.Length > 0 || row.Count > 0) { row.Add(field.ToString()); rows.Add(row); } + return rows; + } + } +} diff --git a/Core/Theme.cs b/Core/Theme.cs new file mode 100644 index 0000000..03c6b82 --- /dev/null +++ b/Core/Theme.cs @@ -0,0 +1,57 @@ +#nullable enable +using System.Windows; +using System.Windows.Media; + +namespace ReminderOrganizer.Core +{ + /// One place for the light/dark palette – used by the main window and all dialogs. + public static class Theme + { + private static SolidColorBrush B(uint rgb) + { + var b = new SolidColorBrush(Color.FromRgb((byte)(rgb >> 16), (byte)(rgb >> 8), (byte)rgb)); + b.Freeze(); + return b; + } + + public static void Apply(ResourceDictionary res, bool dark) + { + if (dark) + { + res["SidebarBrush"] = B(0x1A1A24); + res["CardBrush"] = B(0x22222E); + res["TextPrimaryBrush"] = B(0xF5F5F5); + res["TextSecondaryBrush"] = B(0xA8A8BC); + res["BorderBrush"] = B(0x3A3A4A); + res["BackgroundBrush"] = B(0x121218); + res["HoverBrush"] = B(0x2A2A3A); + res["SidebarTextBrush"] = B(0xF5F5F5); + res["SidebarSecondaryBrush"] = B(0x9999AA); + res["MenuBackgroundBrush"] = B(0x22222E); + res["PrimaryLightBrush"] = B(0x37345F); + res["HeaderBrush"] = B(0x22222E); + res["InputBackgroundBrush"] = B(0x2A2A38); + res["BadgeBrush"] = B(0x37345F); + res["BadgeTextBrush"] = B(0xC7C8FF); + } + else + { + res["SidebarBrush"] = B(0xF8FAFC); + res["CardBrush"] = B(0xFFFFFF); + res["TextPrimaryBrush"] = B(0x1E293B); + res["TextSecondaryBrush"] = B(0x64748B); + res["BorderBrush"] = B(0xE2E8F0); + res["BackgroundBrush"] = B(0xF1F5F9); + res["HoverBrush"] = B(0xE2E8F0); + res["SidebarTextBrush"] = B(0x1E293B); + res["SidebarSecondaryBrush"] = B(0x64748B); + res["MenuBackgroundBrush"] = B(0xFFFFFF); + res["PrimaryLightBrush"] = B(0xEEF2FF); + res["HeaderBrush"] = B(0xFFFFFF); + res["InputBackgroundBrush"] = B(0xF1F5F9); + res["BadgeBrush"] = B(0xE0E7FF); + res["BadgeTextBrush"] = B(0x4338CA); + } + } + } +} diff --git a/InputDialog.xaml b/InputDialog.xaml index d48e055..9971bf0 100644 --- a/InputDialog.xaml +++ b/InputDialog.xaml @@ -1,8 +1,8 @@ - @@ -27,32 +26,34 @@ - + - + - - - -