Compare commits

...

10 Commits

Author SHA1 Message Date
dbcbc586f0 last update 2026-11-29 20:52:18 +01:00
eb98791c08 README: default language is English
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 20:37:31 +01:00
33459bdec7 Snooze notifications, morning summary, ICS import, data folder sync
- Windows toast notifications with snooze (10 min / 1 h / tomorrow) and
  done buttons; balloon fallback; works when Windows starts the app
- Recurring entries snooze via SnoozedUntil without moving their date;
  lead reminders keep the real date
- Morning summary once a day from a chosen hour (pure DailySummary)
- iCalendar import incl. Google birthday calendar, folded lines, UTC,
  alarms, own export round trip, duplicates skipped by UID, undo
- Data folder selectable (location.json pointer), file watcher reloads
  changes from another PC (own writes ignored)
- Themed date picker calendar, WPF tray menu, arrow/Home/End/Space keys
- 90 tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 20:37:20 +01:00
7486eebd67 Category editor redesign, English as default language
- Category editor: icon tile per category opens an icon + color picker
  (no clipped mini combo boxes), placeholders explained, live preview
- Header glyph removed; dialog follows the shared styles
- Dialogs opened from Settings are owned by the active window
  (category editor could open behind the settings window)
- Default language is English; German via Settings > Language

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 18:20:04 +01:00
3e0b00f11c Professional redesign: native window, settings, calmer UI
- WindowChrome: resizable, snap layouts, native shadow, DWM rounded
  corners; size/position remembered; fade-in after load (no theme flash)
- Menu bar replaced by a settings window (theme system/light/dark,
  language, sound, autostart, categories, data, shortcuts, about)
- Shared styles in Themes/Controls.xaml; neutral palette with one accent
  applied to Application.Resources (context menus/tooltips themed)
- Rows: To-Do style check left, title + details, relative date right,
  actions on hover, visible selection (Enter edits, Del deletes)
- No glow/scale effects; subtle animations (dialogs, snackbar, chevrons)
- Checking a recurring task moves it to the next date (with undo)
- Themed combo box, date picker, check box; neutral dialog headers
- New flat app icon (tools/make_icon.py)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 18:10:45 +01:00
00e9990feb Anniversary categories (wedding, jubilee, own) and month grouping
- Birthday becomes "anniversary" with a category: birthday, wedding
  anniversary (with Silver/Gold/... names), jubilee, memorial day
- Own categories: Settings > Categories (icon, color, text with {0}/{o})
- Sidebar "Categories" lists anniversaries across folders with counts
- Group by month (any view), groups fold with a click
- Folders named Hochzeit/Wedding migrate yearly tasks once
- Old files keep working (JSON "IsBirthday" maps to IsAnniversary)
- 74 tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 15:06:19 +01:00
bb6612420d Birthday entry type, relative dates, list/compact/cards views
- Task dialog: Appointment | Birthday switch. Birthday = name + "19.03." or
  "19.03.1986" (no time), live preview with weekday, age and days left
- Birthday folders open the birthday form; yearly tasks in such folders are
  migrated once
- Birthdays show "19. Maerz" instead of date + time; every task shows
  "in 15 days" / "3 days ago" (red when overdue)
- View switch: list, compact (one line), cards (calendar tiles), persisted
- ICS: birthdays as all-day events
- 59 tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 14:42:16 +01:00
693d79019a Upcoming view, search/filters, lead reminders, birthdays, folder colors, ICS, sound, undo
- Upcoming: all folders grouped by overdue/today/tomorrow/7 days/later/done
- Search (Ctrl+F) + All/Today/Overdue filters + hide done (persisted)
- Lead reminder 1/2/3 days or 1 week before; birth year shows age
- Several due reminders are combined into one balloon
- Folder colors and reordering (drag, context menu)
- iCalendar export with RRULE and VALARM
- Generated reminder chime (ComfyUI / Stable Audio), can be turned off
- Undo snackbar for deleted tasks/folders (Ctrl+Z), Ctrl+N, Del, Esc
- 41 tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 15:03:43 +01:00
90898d7040 App icon; language/theme follow Windows on first run; flush save on exit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:52:25 +01:00
5a8eba836b Compact task list and tighter spacing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:20:19 +01:00
76 changed files with 6183 additions and 1156 deletions

View File

@@ -4,7 +4,16 @@
"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\")",
"PowerShell(Get-ChildItem \"$env:TEMP\\\\.net\\\\ReminderOrganizer\" -Recurse -Filter tasks.json -ErrorAction SilentlyContinue | select FullName,Length,LastWriteTime)",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; if \\(-not \\(Select-String -Path ServiceLocator.cs -Pattern \"using System.Linq\" -Quiet\\)\\) { \\(Get-Content -Raw ServiceLocator.cs\\) -replace \"using System;\",\"using System;`r`nusing System.Linq;\" | Set-Content -Encoding utf8 ServiceLocator.cs }; dotnet build ReminderOrganizer.csproj -nologo -v q 2>&1 | Select-String \"Fehler|error\"; git commit -qam \"Migrate tasks.json from v1.0 single-file extract dir`n`nCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>\"; node D:\\\\Oculusquest\\\\Projekt\\\\_Tools\\\\Library\\\\tools\\\\project-check.mjs \"d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer\")"
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; if \\(-not \\(Select-String -Path ServiceLocator.cs -Pattern \"using System.Linq\" -Quiet\\)\\) { \\(Get-Content -Raw ServiceLocator.cs\\) -replace \"using System;\",\"using System;`r`nusing System.Linq;\" | Set-Content -Encoding utf8 ServiceLocator.cs }; dotnet build ReminderOrganizer.csproj -nologo -v q 2>&1 | Select-String \"Fehler|error\"; git commit -qam \"Migrate tasks.json from v1.0 single-file extract dir`n`nCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>\"; node D:\\\\Oculusquest\\\\Projekt\\\\_Tools\\\\Library\\\\tools\\\\project-check.mjs \"d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer\")",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; cmd /c \"release.bat x\" 2>&1 | Select-String \"FERTIG|FEHLER|Bestanden|Fehler:\" ; Get-Item publish\\\\ReminderOrganizer.exe, ReminderOrganizer.zip | select Name,@{n='MB';e={[math]::Round\\($_.Length/1MB,1\\)}},LastWriteTime; git add -A; git commit -qm \"Compact task list and tighter spacing`n`nCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>\"; git log --oneline -1)",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; Remove-Item -Recurse -Force publish, ReminderOrganizer.zip -ErrorAction SilentlyContinue; dotnet publish ReminderOrganizer.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true -p:DebugType=none -o publish -nologo -v q 2>&1 | Select-String \"error|Fehler\"; Compress-Archive publish\\\\ReminderOrganizer.exe ReminderOrganizer.zip -Force; Get-Item publish\\\\ReminderOrganizer.exe, ReminderOrganizer.zip | select Name,@{n='MB';e={[math]::Round\\($_.Length/1MB,1\\)}},LastWriteTime)",
"PowerShell(Get-Process ReminderOrganizer -ErrorAction SilentlyContinue)",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; if \\(Get-Process ReminderOrganizer -ErrorAction SilentlyContinue\\) { \"LAEUFT NOCH\" } else { Remove-Item -Recurse -Force publish -ErrorAction SilentlyContinue; dotnet publish ReminderOrganizer.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true -p:DebugType=none -o publish -nologo -v q 2>&1 | Select-String \"error|Fehler\"; Compress-Archive publish\\\\ReminderOrganizer.exe ReminderOrganizer.zip -Force; Get-Item publish\\\\ReminderOrganizer.exe, ReminderOrganizer.zip | select Name,@{n='MB';e={[math]::Round\\($_.Length/1MB,1\\)}},LastWriteTime; \\(Get-Item publish\\\\ReminderOrganizer.exe\\).VersionInfo | select CompanyName,LegalCopyright,ProductVersion })",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; $v=\\(Get-Item publish\\\\ReminderOrganizer.exe\\).VersionInfo; \"$\\($v.CompanyName\\) | $\\($v.LegalCopyright\\) | $\\($v.ProductVersion\\)\"; Start-Process publish\\\\ReminderOrganizer.exe; Start-Sleep 3; Get-ChildItem \"$env:APPDATA\\\\ReminderOrganizer\" | select Name,Length,LastWriteTime)",
"PowerShell(Get-Content \"$env:APPDATA\\\\ReminderOrganizer\\\\tasks.json\" -Raw; Get-ChildItem \"$env:APPDATA\\\\ReminderOrganizer\" | select Name,LastWriteTime)",
"PowerShell(& \"d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer\\\\sprite-generator\\\\gen.cmd\" generate icon 2>&1 | Select -Last 8)",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; py -3.12 -I $env:TEMP\\\\mkico.py Assets\\\\Sprites\\\\icon.png Assets\\\\app.ico; Get-ChildItem Assets | select Name,Length)",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; $t=[IO.File]::ReadAllText\\('MainWindow.xaml.cs'\\); if\\($t -notmatch 'using System.Linq;'\\){ $t=$t.Replace\\(\"using System.ComponentModel;\",\"using System.ComponentModel;`r`nusing System.Linq;\"\\); [IO.File]::WriteAllText\\('MainWindow.xaml.cs',$t,\\(New-Object Text.UTF8Encoding $true\\)\\) }; dotnet build ReminderOrganizer.csproj -nologo -v q 2>&1 | Select-String \"error\" | Select -First 10)"
]
}
}

View File

@@ -1,12 +1,14 @@
{
"status": "done",
"status": "archived",
"priority": "medium",
"notes": "",
"description": "",
"tags": [],
"tasks": [],
"thumbnail": "",
"start": "",
"program": "",
"program": "publish\\ReminderOrganizer.exe",
"itch": "",
"updatedAt": "2026-11-11T09:23:52.594Z"
"favorite": true,
"updatedAt": "2026-11-29T17:27:23.604Z"
}

View File

@@ -4,6 +4,11 @@
xmlns:converters="clr-namespace:ReminderOrganizer.Converters"
ShutdownMode="OnExplicitShutdown">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes/Controls.xaml"/>
</ResourceDictionary.MergedDictionaries>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibility"/>
<converters:NullToVisibilityConverter x:Key="NullToVisibility"/>
<converters:ZeroToVisibilityConverter x:Key="ZeroToVisibility"/>
@@ -12,5 +17,9 @@
<converters:DatePassedConverter x:Key="DatePassed"/>
<converters:InverseBoolConverter x:Key="InverseBool"/>
<converters:InverseBoolToVisibilityConverter x:Key="InverseBoolToVisibility"/>
<converters:BucketHeaderConverter x:Key="BucketHeader"/>
<converters:HexToBrushConverter x:Key="HexToBrush"/>
<converters:ReferenceEqualsConverter x:Key="RefEquals"/>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System;
using System.IO;
using System.Threading.Tasks;
@@ -17,7 +17,10 @@ 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);
// Test runs with their own data folder (REMINDER_ORGANIZER_DATA) get their own lock.
var mutexName = "MichaelMedia.ReminderOrganizer" +
(Environment.GetEnvironmentVariable("REMINDER_ORGANIZER_DATA") is { Length: > 0 } d ? "." + d.GetHashCode() : "");
_singleInstance = new System.Threading.Mutex(true, mutexName, out var isFirst);
if (!isFirst)
{
Shutdown();
@@ -27,10 +30,18 @@ namespace ReminderOrganizer
SetupExceptionHandling();
ServiceLocator.Initialize();
// Buttons in Windows notifications (snooze / done / open) – also when Windows started us for it.
Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat.OnActivated += args =>
{
var toastArgs = Microsoft.Toolkit.Uwp.Notifications.ToastArguments.Parse(args.Argument);
Current.Dispatcher.BeginInvoke(new Action(() => (Current.MainWindow as MainWindow)?.HandleToast(toastArgs)));
};
bool fromToast = Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat.WasCurrentProcessToastActivated();
var main = new MainWindow();
MainWindow = main;
// Autostart passes --minimized: start straight into the tray.
if (Array.IndexOf(e.Args, "--minimized") >= 0)
// Autostart passes --minimized: start straight into the tray. A toast button decides itself.
if (Array.IndexOf(e.Args, "--minimized") >= 0 || fromToast)
main.StartHidden();
else
main.Show();
@@ -38,8 +49,16 @@ namespace ReminderOrganizer
private System.Threading.Mutex? _singleInstance;
/// <summary>Really exit (tray menu / "Exit"): the main window otherwise only hides to the tray.</summary>
public static void Quit()
{
(Current.MainWindow as MainWindow)?.AllowClose();
Current.Shutdown();
}
protected override void OnExit(ExitEventArgs e)
{
(MainWindow as MainWindow)?.OnAppExit();
Services.NotificationService.SharedTrayIcon?.Dispose();
_singleInstance?.Dispose();
base.OnExit(e);
@@ -73,8 +92,8 @@ namespace ReminderOrganizer
{
try
{
Directory.CreateDirectory(DataService.DefaultDataDirectory);
var logPath = Path.Combine(DataService.DefaultDataDirectory, "error.log");
Directory.CreateDirectory(DataService.AppDirectory);
var logPath = Path.Combine(DataService.AppDirectory, "error.log");
var logEntry = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [{source}]\n{ex}\n\n";
File.AppendAllText(logPath, logEntry);
}

Binary file not shown.

BIN
Assets/Sprites/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

BIN
Assets/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
Assets/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
Assets/reminder.wav Normal file

Binary file not shown.

View File

@@ -8,10 +8,21 @@ services through `ServiceLocator` (Microsoft.Extensions.DependencyInjection).
`ProcessDue`) is pure and tested.
- `Services/`: `DataService` (JSON in %APPDATA%, atomic + serialized), `LocalizationService` (Locales are
**EmbeddedResource** `Locales.<lang>.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).
(HKCU Run, `"exe" --minimized`), `NotificationService` (Windows toasts via Microsoft.Toolkit.Uwp.Notifications with snooze/done buttons → `App` `OnActivated` → `MainWindow.HandleToast` → `MainViewModel.HandleToastAction`; tray balloon as fallback), `IcsImport`/`IcsExport`.
- Data folder: `DataService.AppDirectory` (pointer `location.json`, error.log, toast logo) vs. `DefaultDataDirectory` (tasks.json,
may be OneDrive). `FileSystemWatcher` + `LastWriteUtc` → `MainViewModel.ReloadFromDiskAsync` when another PC changed the file.
- Morning summary: `Core/DailySummary.cs` (pure), shown from `CheckReminders`.
- Anniversaries: `ReminderTask.IsAnniversary` (stored as JSON `"IsBirthday"` for older files) + `CategoryId`
→ `Models/Category.cs` (presets birthday/wedding/jubilee/memorial + own ones, text with `{0}`/`{o}`).
Filter/sort/group rules are in `Core/TaskQuery.cs` (pure, tested).
- `Core/Theme.cs`: the only light/dark palette (neutral greys + one accent), applied to **Application.Resources**
(so context menus, tooltips and dialogs follow). Theme mode system/light/dark in settings.
- `Themes/Controls.xaml`: all shared styles (menus, tooltips, scrollbars, combo box, date picker, check box,
buttons `PrimaryButton`/`SubtleButton`/`IconButton`, `Segment`, `ToggleSwitch`, `DoneCheck`). Change looks here, not per window.
- `MainWindow.xaml`: `WindowChrome` (native resize/snap/shadow, DWM rounded corners), no menu bar: settings gear
→ `SettingsWindow`. Row actions appear on hover. Icons are Segoe Fluent/MDL2 glyphs or Path geometry, **no emojis**.
- Design rules: no glow, no scaling on hover, animations only 120–200 ms and only where they carry meaning
(dialog open, snackbar, group chevron, toggle knob, window fade-in).
- `Tests/`: xUnit project, excluded from the app csproj via `Compile Remove`.
## Rules
@@ -22,6 +33,9 @@ services through `ServiceLocator` (Microsoft.Extensions.DependencyInjection).
- Run `dotnet test Tests\ReminderOrganizer.Tests.csproj` before each release. `release.bat` does this automatically.
## Graphics
App icon is drawn, not generated: `py -3.12 tools\make_icon.py <out.png>` (rounded square + Fluent bell), then
save as `Assets\app.png` (256) and `Assets\app.ico` (16–256). Older ComfyUI notes below.
`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.

219
CategoryWindow.xaml Normal file
View File

@@ -0,0 +1,219 @@
<Window x:Class="ReminderOrganizer.CategoryWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{Binding [Categories]}"
Width="760" SizeToContent="Height" MaxHeight="760"
WindowStartupLocation="CenterOwner" ResizeMode="NoResize" ShowInTaskbar="False"
WindowStyle="None" AllowsTransparency="True" Background="Transparent"
FontFamily="{StaticResource UiFont}" FontSize="13" Foreground="{DynamicResource TextPrimaryBrush}"
UseLayoutRounding="True"
MouseLeftButtonDown="Window_MouseLeftButtonDown" KeyDown="Window_KeyDown">
<Window.Resources>
<Style x:Key="Input" TargetType="TextBox">
<Setter Property="Background" Value="{DynamicResource InputBackgroundBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="CaretBrush" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Height" Value="34"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Border x:Name="Bd" CornerRadius="6" BorderThickness="1" Background="{TemplateBinding Background}"
BorderBrush="{DynamicResource BorderBrush}" Padding="9,0">
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource TextTertiaryBrush}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ColHead" TargetType="TextBlock">
<Setter Property="FontSize" Value="11.5"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}"/>
</Style>
<Style x:Key="Code" TargetType="Border">
<Setter Property="CornerRadius" Value="4"/>
<Setter Property="Padding" Value="5,0"/>
<Setter Property="Margin" Value="0,0,5,0"/>
<Setter Property="Background" Value="{DynamicResource HoverBrush}"/>
</Style>
<!-- one glyph / color choice inside the picker popup -->
<Style x:Key="PickButton" TargetType="Button">
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="Bd" Width="32" Height="32" CornerRadius="6" Background="Transparent">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Border Margin="12" CornerRadius="10" Background="{DynamicResource CardBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
<Border.Effect>
<DropShadowEffect BlurRadius="24" ShadowDepth="6" Opacity="0.28" Direction="270" Color="Black"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- header -->
<DockPanel Margin="24,18,14,0">
<Button DockPanel.Dock="Right" Content="&#xE8BB;" Style="{StaticResource IconButton}" FontSize="10" Click="Cancel_Click" ToolTip="Esc"/>
<TextBlock Text="{Binding [Categories]}" FontSize="18" FontWeight="SemiBold" VerticalAlignment="Center"/>
</DockPanel>
<!-- explanation + column heads -->
<StackPanel Grid.Row="1" Margin="24,6,24,0">
<TextBlock Text="{Binding [CategoriesIntro]}" FontSize="12.5" TextWrapping="Wrap" Foreground="{DynamicResource TextSecondaryBrush}"/>
<WrapPanel Margin="0,8,0,0" TextElement.FontSize="12" TextElement.Foreground="{DynamicResource TextSecondaryBrush}">
<Border Style="{StaticResource Code}"><TextBlock Text="{}{0}" FontFamily="Consolas" Foreground="{DynamicResource TextPrimaryBrush}"/></Border>
<TextBlock Text="{Binding [CatPlaceholderYears]}" Margin="0,0,16,0" VerticalAlignment="Center"/>
<Border Style="{StaticResource Code}"><TextBlock Text="{}{o}" FontFamily="Consolas" Foreground="{DynamicResource TextPrimaryBrush}"/></Border>
<TextBlock Text="{Binding [CatPlaceholderOrdinal]}" VerticalAlignment="Center"/>
</WrapPanel>
<Grid Margin="0,18,8,6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="52"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="190"/>
<ColumnDefinition Width="34"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="{Binding [Name]}" Style="{StaticResource ColHead}"/>
<TextBlock Grid.Column="2" Text="{Binding [CatText]}" Style="{StaticResource ColHead}" Margin="10,0,0,0"/>
<TextBlock Grid.Column="3" Text="{Binding [CatExample]}" Style="{StaticResource ColHead}" Margin="14,0,0,0"/>
</Grid>
</StackPanel>
<!-- rows -->
<ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto" Margin="24,0,16,0" MaxHeight="420">
<ItemsControl x:Name="Rows" Margin="0,0,8,0">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="52"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="190"/>
<ColumnDefinition Width="34"/>
</Grid.ColumnDefinitions>
<!-- icon tile: click opens icon + color picker -->
<ToggleButton x:Name="Tile" Width="38" Height="34" HorizontalAlignment="Left" Cursor="Hand"
AutomationProperties.Name="{Binding DataContext[CatChangeLook], RelativeSource={RelativeSource AncestorType=Window}}"
ToolTip="{Binding DataContext[CatChangeLook], RelativeSource={RelativeSource AncestorType=Window}}">
<ToggleButton.Template>
<ControlTemplate TargetType="ToggleButton">
<Border x:Name="Bd" CornerRadius="8" BorderThickness="1" BorderBrush="Transparent"
Background="{Binding Color, Converter={StaticResource HexToBrush}, ConverterParameter=0.16}">
<TextBlock Text="{Binding Glyph}" FontFamily="{StaticResource IconFont}" FontSize="15"
HorizontalAlignment="Center" VerticalAlignment="Center"
Foreground="{Binding Color, Converter={StaticResource HexToBrush}}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{Binding Color, Converter={StaticResource HexToBrush}, ConverterParameter=0.6}"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{Binding Color, Converter={StaticResource HexToBrush}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
<Popup IsOpen="{Binding IsChecked, ElementName=Tile, Mode=TwoWay}" PlacementTarget="{Binding ElementName=Tile}" Placement="Bottom"
StaysOpen="False" AllowsTransparency="True" PopupAnimation="Fade" VerticalOffset="4">
<Border Background="{DynamicResource MenuBackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
CornerRadius="8" Padding="10" Margin="6,0,6,10" Width="244">
<Border.Effect>
<DropShadowEffect BlurRadius="14" ShadowDepth="3" Opacity="0.22" Color="Black"/>
</Border.Effect>
<StackPanel>
<TextBlock Text="{Binding DataContext[CatIcon], RelativeSource={RelativeSource AncestorType=Window}}"
FontSize="11.5" FontWeight="SemiBold" Foreground="{DynamicResource TextSecondaryBrush}" Margin="2,0,0,4"/>
<ItemsControl ItemsSource="{Binding Glyphs, RelativeSource={RelativeSource AncestorType=Window}}">
<ItemsControl.ItemsPanel><ItemsPanelTemplate><WrapPanel/></ItemsPanelTemplate></ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Style="{StaticResource PickButton}" Click="PickGlyph_Click" Tag="{Binding}">
<TextBlock Text="{Binding}" FontFamily="{StaticResource IconFont}" FontSize="15"
Foreground="{DynamicResource TextPrimaryBrush}"/>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Text="{Binding DataContext[Color], RelativeSource={RelativeSource AncestorType=Window}}"
FontSize="11.5" FontWeight="SemiBold" Foreground="{DynamicResource TextSecondaryBrush}" Margin="2,10,0,4"/>
<ItemsControl ItemsSource="{Binding Palette, RelativeSource={RelativeSource AncestorType=Window}}">
<ItemsControl.ItemsPanel><ItemsPanelTemplate><WrapPanel/></ItemsPanelTemplate></ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Style="{StaticResource PickButton}" Click="PickColor_Click" Tag="{Binding}">
<Ellipse Width="18" Height="18" Fill="{Binding Converter={StaticResource HexToBrush}}"/>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Border>
</Popup>
<TextBox Grid.Column="1" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource Input}"/>
<TextBox Grid.Column="2" Text="{Binding Format, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource Input}" Margin="10,0,0,0"/>
<TextBlock Grid.Column="3" Margin="14,0,0,0" VerticalAlignment="Center" FontSize="12.5" TextTrimming="CharacterEllipsis"
Foreground="{DynamicResource TextSecondaryBrush}" Loaded="Example_Loaded" Tag="{Binding}"/>
<Button Grid.Column="4" Content="&#xE74D;" Style="{StaticResource IconButton}" HorizontalAlignment="Right"
Click="Delete_Click" Tag="{Binding}"
ToolTip="{Binding DataContext[Delete], RelativeSource={RelativeSource AncestorType=Window}}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<!-- buttons -->
<DockPanel Grid.Row="3" Margin="24,16,24,20">
<Button DockPanel.Dock="Left" Style="{StaticResource SubtleButton}" Click="Add_Click">
<StackPanel Orientation="Horizontal">
<TextBlock Text="&#xE710;" FontFamily="{StaticResource IconFont}" FontSize="11" VerticalAlignment="Center" Margin="0,1,8,0"/>
<TextBlock Text="{Binding [AddCategoryShort]}"/>
</StackPanel>
</Button>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="{Binding [Cancel]}" Style="{StaticResource SubtleButton}" Click="Cancel_Click"/>
<Button Content="{Binding [Save]}" Style="{StaticResource PrimaryButton}" Click="Save_Click" IsDefault="True" Margin="8,0,0,0"/>
</StackPanel>
</DockPanel>
</Grid>
</Border>
</Window>

147
CategoryWindow.xaml.cs Normal file
View File

@@ -0,0 +1,147 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using ReminderOrganizer.Core;
using ReminderOrganizer.Models;
using ReminderOrganizer.Services;
namespace ReminderOrganizer
{
/// <summary>Edit anniversary categories (name, icon, color, text). Works on copies until "Save".</summary>
public partial class CategoryWindow : Window
{
private readonly ObservableCollection<Category> _items;
private readonly Func<string, int> _usage;
private readonly ILocalizationService _loc;
public IReadOnlyList<string> Glyphs => Category.Glyphs;
public IReadOnlyList<string> Palette => Folder.Palette;
/// <summary>The edited list (valid after DialogResult == true).</summary>
public List<Category> Result => _items.ToList();
public CategoryWindow(IEnumerable<Category> categories, bool darkMode, Func<string, int> usageCount)
{
InitializeComponent();
DialogAnimation.Attach(this);
Theme.Apply(Resources, darkMode);
_loc = (ILocalizationService)ServiceLocator.Services.GetService(typeof(ILocalizationService))!;
_usage = usageCount;
_items = new ObservableCollection<Category>(categories.Select(c => c.Clone()));
foreach (var c in _items) c.PropertyChanged += OnCategoryChanged;
Rows.ItemsSource = _items;
DataContext = new LocalizedTexts(_loc);
}
/// <summary>Indexer for {Binding [Key]} in this window.</summary>
private sealed class LocalizedTexts
{
private readonly ILocalizationService _loc;
public LocalizedTexts(ILocalizationService loc) => _loc = loc;
public string this[string key] => _loc.GetString(key);
}
private string Example(Category c)
{
var culture = ReminderTask.DisplayCulture?.Invoke() ?? System.Globalization.CultureInfo.CurrentCulture;
return c.FormatYears(25, culture, _loc.GetString);
}
private void Example_Loaded(object sender, RoutedEventArgs e)
{
if (sender is TextBlock tb && tb.Tag is Category c) tb.Text = Example(c);
}
private void OnCategoryChanged(object? sender, PropertyChangedEventArgs e)
{
// keep the "example" column live while typing
if (sender is not Category c) return;
foreach (var tb in FindVisualChildren<TextBlock>(Rows))
if (ReferenceEquals(tb.Tag, c)) tb.Text = Example(c);
}
private static IEnumerable<T> FindVisualChildren<T>(DependencyObject root) where T : DependencyObject
{
for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(root); i++)
{
var child = System.Windows.Media.VisualTreeHelper.GetChild(root, i);
if (child is T t) yield return t;
foreach (var d in FindVisualChildren<T>(child)) yield return d;
}
}
private void Add_Click(object sender, RoutedEventArgs e)
{
var c = new Category
{
Name = _loc.GetString("NewCategory"),
Glyph = Category.Glyphs[_items.Count % Category.Glyphs.Length],
Color = Folder.Palette[_items.Count % Folder.Palette.Length],
Format = _loc.GetString("CatJubileeFormat")
};
c.PropertyChanged += OnCategoryChanged;
_items.Add(c);
}
private void Delete_Click(object sender, RoutedEventArgs e)
{
if (sender is not FrameworkElement { Tag: Category c }) return;
if (_items.Count <= 1) return;
int used = _usage(c.Id);
if (used > 0 && MessageBox.Show(this, string.Format(_loc.GetString("ConfirmDeleteCategory"), c.Name, used),
_loc.GetString("AppTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
return;
_items.Remove(c);
}
private void Save_Click(object sender, RoutedEventArgs e)
{
foreach (var c in _items)
{
c.Name = string.IsNullOrWhiteSpace(c.Name) ? _loc.GetString("NewCategory") : c.Name.Trim();
if (string.IsNullOrWhiteSpace(c.Format)) c.Format = "{0}";
}
DialogResult = true;
}
private void Cancel_Click(object sender, RoutedEventArgs e) => DialogResult = false;
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape) DialogResult = false;
}
/// <summary>The picker buttons live in a popup; walk up (visual, then logical) to the category row.</summary>
private static Category? CategoryOf(object sender)
{
DependencyObject? d = sender as DependencyObject;
while (d != null)
{
if (d is FrameworkElement { DataContext: Category c }) return c;
d = System.Windows.Media.VisualTreeHelper.GetParent(d) ?? LogicalTreeHelper.GetParent(d);
}
return null;
}
private void PickGlyph_Click(object sender, RoutedEventArgs e)
{
if (sender is FrameworkElement { Tag: string glyph } && CategoryOf(sender) is { } c) c.Glyph = glyph;
}
private void PickColor_Click(object sender, RoutedEventArgs e)
{
if (sender is FrameworkElement { Tag: string color } && CategoryOf(sender) is { } c) c.Color = color;
}
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed && e.OriginalSource is not TextBox) DragMove();
}
}
}

View File

@@ -0,0 +1,80 @@
#nullable enable
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using ReminderOrganizer.Core;
using ReminderOrganizer.Models;
using ReminderOrganizer.Services;
namespace ReminderOrganizer.Converters
{
/// <summary>Task → TaskBucket (group key for the "Upcoming" view).</summary>
public class TaskBucketConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
value is ReminderTask t ? TaskQuery.Bucket(t, DateTime.Now) : TaskBucket.Later;
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Binding.DoNothing;
}
/// <summary>true if both values are the same object (row == selected task).</summary>
public class ReferenceEqualsConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) =>
values.Length == 2 && values[0] != null && ReferenceEquals(values[0], values[1]);
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) =>
throw new NotSupportedException();
}
/// <summary>Task → first day of its month (group key for month grouping).</summary>
public class MonthKeyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
value is ReminderTask t ? TaskQuery.MonthKey(t) : DateTime.MinValue;
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Binding.DoNothing;
}
/// <summary>Group key → header: TaskBucket → "TODAY" …, month → "DECEMBER 2026".</summary>
public class BucketHeaderConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is DateTime month)
{
var c = ReminderTask.DisplayCulture?.Invoke() ?? CultureInfo.CurrentCulture;
return month.ToString("MMMM yyyy", c).ToUpper(c);
}
var loc = ServiceLocator.Services.GetService(typeof(ILocalizationService)) as ILocalizationService;
var key = "Bucket" + value;
return loc?.GetString(key) ?? key;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Binding.DoNothing;
}
/// <summary>"#RRGGBB" → brush; parameter = opacity 0..1 (optional).</summary>
public class HexToBrushConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
var color = (Color)ColorConverter.ConvertFromString(value as string ?? Folder.DefaultColor);
if (parameter is string p && double.TryParse(p, NumberStyles.Float, CultureInfo.InvariantCulture, out var a))
color.A = (byte)(255 * Math.Clamp(a, 0, 1));
var brush = new SolidColorBrush(color);
brush.Freeze();
return brush;
}
catch
{
return Brushes.SlateBlue;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Binding.DoNothing;
}
}

49
Core/BirthdayInput.cs Normal file
View File

@@ -0,0 +1,49 @@
#nullable enable
using System;
using System.Globalization;
using System.Text.RegularExpressions;
namespace ReminderOrganizer.Core
{
/// <summary>Parses quick birthday input: "19.3", "19.03.", "19.03.1986", "19.3.86", "1986-03-19".</summary>
public static class BirthdayInput
{
private static readonly Regex DayMonthYear = new(@"^\s*(\d{1,2})\s*[./\-\s]\s*(\d{1,2})\s*\.?\s*(?:[./\-\s]?\s*(\d{2}|\d{4}))?\s*$");
private static readonly Regex Iso = new(@"^\s*(\d{4})-(\d{1,2})-(\d{1,2})\s*$");
public static bool TryParse(string? text, DateTime today, out int day, out int month, out int? year)
{
day = month = 0;
year = null;
if (string.IsNullOrWhiteSpace(text)) return false;
var m = Iso.Match(text);
if (m.Success)
{
year = int.Parse(m.Groups[1].Value, CultureInfo.InvariantCulture);
month = int.Parse(m.Groups[2].Value, CultureInfo.InvariantCulture);
day = int.Parse(m.Groups[3].Value, CultureInfo.InvariantCulture);
}
else
{
m = DayMonthYear.Match(text);
if (!m.Success) return false;
day = int.Parse(m.Groups[1].Value, CultureInfo.InvariantCulture);
month = int.Parse(m.Groups[2].Value, CultureInfo.InvariantCulture);
if (m.Groups[3].Success)
{
int y = int.Parse(m.Groups[3].Value, CultureInfo.InvariantCulture);
if (m.Groups[3].Value.Length == 2)
y += y > today.Year % 100 ? 1900 : 2000; // "86" → 1986, "05" → 2005
year = y;
}
}
if (month < 1 || month > 12) return false;
if (day < 1 || day > DateTime.DaysInMonth(2000, month)) return false; // 2000: leap year, allows 29.02.
if (year is int yy && (yy < 1900 || yy > today.Year)) return false;
if (year is int y2 && day > DateTime.DaysInMonth(y2, month)) return false;
return true;
}
}
}

35
Core/DailySummary.cs Normal file
View File

@@ -0,0 +1,35 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using ReminderOrganizer.Models;
namespace ReminderOrganizer.Core
{
/// <summary>Content of the morning summary. Null when there is nothing worth showing.</summary>
public sealed record DailySummaryData(
IReadOnlyList<ReminderTask> Today,
IReadOnlyList<ReminderTask> Overdue,
IReadOnlyList<ReminderTask> AnniversariesSoon);
public static class DailySummary
{
/// <summary>Days ahead in which anniversaries are announced (tomorrow … in 3 days).</summary>
public const int AnniversaryDays = 3;
public static DailySummaryData? Build(IEnumerable<ReminderTask> tasks, DateTime now)
{
var open = tasks.Where(t => !t.IsNotified).ToList();
var today = open.Where(t => t.ReminderDate.Date == now.Date).OrderBy(t => t.ReminderDate).ToList();
var overdue = open.Where(t => !t.IsRecurring && t.ReminderDate.Date < now.Date).OrderBy(t => t.ReminderDate).ToList();
var soon = open.Where(t => t.IsAnniversary)
.Where(t => (t.ReminderDate.Date - now.Date).Days is > 0 and <= AnniversaryDays)
.OrderBy(t => t.ReminderDate).ToList();
return today.Count + overdue.Count + soon.Count == 0 ? null : new DailySummaryData(today, overdue, soon);
}
/// <summary>Should the summary be shown now? Once per day, from <paramref name="hour"/> on.</summary>
public static bool IsDue(DateTime now, int hour, DateTime? lastShown) =>
now.Hour >= hour && (lastShown == null || lastShown.Value.Date < now.Date);
}
}

33
Core/DialogAnimation.cs Normal file
View File

@@ -0,0 +1,33 @@
#nullable enable
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace ReminderOrganizer
{
/// <summary>Subtle open animation for dialogs: fade in + 2 % scale, 140 ms, ease-out.</summary>
public static class DialogAnimation
{
public static void Attach(Window window)
{
window.Opacity = 0;
window.Loaded += (_, _) =>
{
var ease = new CubicEase { EasingMode = EasingMode.EaseOut };
var duration = TimeSpan.FromMilliseconds(140);
window.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(0, 1, duration) { EasingFunction = ease });
if (window.Content is FrameworkElement root)
{
var scale = new ScaleTransform(0.98, 0.98);
root.RenderTransformOrigin = new Point(0.5, 0.5);
root.RenderTransform = scale;
var anim = new DoubleAnimation(0.98, 1, duration) { EasingFunction = ease };
scale.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
scale.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
}
};
}
}
}

24
Core/SystemPrefs.cs Normal file
View File

@@ -0,0 +1,24 @@
#nullable enable
using System.Globalization;
using Microsoft.Win32;
namespace ReminderOrganizer.Core
{
/// <summary>Windows settings the app follows until the user picks something (theme).</summary>
public static class SystemPrefs
{
public static bool IsDarkMode()
{
try
{
using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize");
return key?.GetValue("AppsUseLightTheme") is int v && v == 0;
}
catch
{
return true;
}
}
}
}

90
Core/TaskQuery.cs Normal file
View File

@@ -0,0 +1,90 @@
#nullable enable
using System;
using System.Collections;
using System.Globalization;
using ReminderOrganizer.Models;
namespace ReminderOrganizer.Core
{
public enum TaskFilterMode { All, Today, Overdue }
/// <summary>Groups in the "Upcoming" view, in display order.</summary>
public enum TaskBucket { Overdue, Today, Tomorrow, ThisWeek, Later, Done }
/// <summary>Pure filter/sort/group rules for the task list.</summary>
public static class TaskQuery
{
public static TaskBucket Bucket(ReminderTask t, DateTime now)
{
if (t.IsNotified) return TaskBucket.Done;
if (t.ReminderDate < now) return TaskBucket.Overdue;
var days = (t.ReminderDate.Date - now.Date).Days;
return days switch
{
0 => TaskBucket.Today,
1 => TaskBucket.Tomorrow,
< 7 => TaskBucket.ThisWeek,
_ => TaskBucket.Later
};
}
/// <summary>Category filter value for "appointments only" (everything that is not an anniversary).</summary>
public const string AppointmentsFilter = "_appointments";
public static bool MatchesCategory(ReminderTask t, string? categoryFilter) => categoryFilter switch
{
null or "" => true,
AppointmentsFilter => !t.IsAnniversary,
_ => t.IsAnniversary && (t.CategoryId ?? Category.BirthdayId) == categoryFilter
};
/// <summary>Group key for month grouping: first day of the month.</summary>
public static DateTime MonthKey(ReminderTask t) => new(t.ReminderDate.Year, t.ReminderDate.Month, 1);
public static bool Matches(ReminderTask t, string? search, TaskFilterMode mode, bool hideDone, DateTime now, string? categoryFilter = null)
{
if (hideDone && t.IsNotified) return false;
if (!MatchesCategory(t, categoryFilter)) return false;
switch (mode)
{
case TaskFilterMode.Today when t.ReminderDate.Date != now.Date: return false;
case TaskFilterMode.Overdue when t.IsNotified || t.ReminderDate >= now: return false;
}
if (string.IsNullOrWhiteSpace(search)) return true;
var s = search.Trim();
return Contains(t.Name, s) || Contains(t.Description, s) || Contains(t.FolderName, s) || Contains(t.Category?.Name, s);
}
private static bool Contains(string? text, string s) =>
text != null && CultureInfo.CurrentCulture.CompareInfo.IndexOf(text, s, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace) >= 0;
/// <summary>Sort: bucket (overdue, today, … done), then date, then name.</summary>
public sealed class Comparer : IComparer
{
private readonly Func<DateTime> _now;
private readonly bool _chronological;
/// <param name="chronological">true = plain date order (month grouping), false = overdue/today/…/done.</param>
public Comparer(Func<DateTime>? now = null, bool chronological = false)
{
_now = now ?? (() => DateTime.Now);
_chronological = chronological;
}
public int Compare(object? x, object? y)
{
if (x is not ReminderTask a || y is not ReminderTask b) return 0;
if (_chronological)
{
int d = a.ReminderDate.CompareTo(b.ReminderDate);
return d != 0 ? d : string.Compare(a.Name, b.Name, StringComparison.CurrentCultureIgnoreCase);
}
var now = _now();
int c = Bucket(a, now).CompareTo(Bucket(b, now));
if (c != 0) return c;
c = a.IsNotified ? b.ReminderDate.CompareTo(a.ReminderDate) // done: newest first
: a.ReminderDate.CompareTo(b.ReminderDate);
return c != 0 ? c : string.Compare(a.Name, b.Name, StringComparison.CurrentCultureIgnoreCase);
}
}
}
}

View File

@@ -4,53 +4,80 @@ using System.Windows.Media;
namespace ReminderOrganizer.Core
{
/// <summary>One place for the light/dark palette – used by the main window and all dialogs.</summary>
/// <summary>
/// One place for the light/dark palette. Neutral greys + a single muted accent (Fluent-like).
/// Applied to Application.Resources so context menus, tooltips and dialogs all follow the theme.
/// </summary>
public static class Theme
{
private static SolidColorBrush B(uint rgb)
public static bool IsDark { get; private set; } = true;
private static SolidColorBrush B(uint rgb, byte alpha = 255)
{
var b = new SolidColorBrush(Color.FromRgb((byte)(rgb >> 16), (byte)(rgb >> 8), (byte)rgb));
var b = new SolidColorBrush(Color.FromArgb(alpha, (byte)(rgb >> 16), (byte)(rgb >> 8), (byte)rgb));
b.Freeze();
return b;
}
public static void Apply(ResourceDictionary res, bool dark)
{
if (ReferenceEquals(res, Application.Current?.Resources)) IsDark = dark;
// shared
res["PrimaryBrush"] = B(0x5B5BD6);
res["PrimaryHoverBrush"] = B(0x4C4CC4);
res["DangerBrush"] = B(dark ? 0xF0706AU : 0xD93A34U);
res["WarningBrush"] = B(0xE5A00D);
res["SuccessBrush"] = B(dark ? 0x3DD68CU : 0x18A058U);
res["SecondaryBrush"] = res["SuccessBrush"];
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);
res["BackgroundBrush"] = B(0x16161A);
res["SidebarBrush"] = B(0x1C1C21);
res["HeaderBrush"] = B(0x1C1C21);
res["CardBrush"] = B(0x202026);
res["MenuBackgroundBrush"] = B(0x26262D);
res["InputBackgroundBrush"] = B(0x1A1A1F);
res["BorderBrush"] = B(0x2E2E36);
res["DividerBrush"] = B(0x2A2A31);
res["HoverBrush"] = B(0x2A2A31);
res["SelectedBrush"] = B(0x2B2B45);
res["TextPrimaryBrush"] = B(0xEDEDF2);
res["TextSecondaryBrush"] = B(0x9C9CA8);
res["TextTertiaryBrush"] = B(0x6E6E7A);
res["SidebarTextBrush"] = B(0xDCDCE4);
res["SidebarSecondaryBrush"] = B(0x80808C);
res["AccentSubtleBrush"] = B(0x2D2D4C);
res["AccentTextBrush"] = B(0xB9BAFF);
res["PrimaryLightBrush"] = res["AccentSubtleBrush"];
res["BadgeBrush"] = B(0x2D2D4C);
res["BadgeTextBrush"] = B(0xB9BAFF);
res["SnackbarBrush"] = B(0x33333C);
}
else
{
res["SidebarBrush"] = B(0xF8FAFC);
res["BackgroundBrush"] = B(0xF6F7F9);
res["SidebarBrush"] = B(0xEEF0F3);
res["HeaderBrush"] = B(0xEEF0F3);
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);
res["InputBackgroundBrush"] = B(0xFFFFFF);
res["BorderBrush"] = B(0xDDE0E6);
res["DividerBrush"] = B(0xECEEF2);
res["HoverBrush"] = B(0xE6E8EE);
res["SelectedBrush"] = B(0xE9E9FB);
res["TextPrimaryBrush"] = B(0x1B1D23);
res["TextSecondaryBrush"] = B(0x646A78);
res["TextTertiaryBrush"] = B(0x9AA0AC);
res["SidebarTextBrush"] = B(0x2A2D35);
res["SidebarSecondaryBrush"] = B(0x7A7F8C);
res["AccentSubtleBrush"] = B(0xE4E4FA);
res["AccentTextBrush"] = B(0x3F3FB5);
res["PrimaryLightBrush"] = res["AccentSubtleBrush"];
res["BadgeBrush"] = B(0xE8E8FB);
res["BadgeTextBrush"] = B(0x4343B8);
res["SnackbarBrush"] = B(0x2B2D35);
}
}
}

View File

@@ -1,4 +1,4 @@
<Window x:Class="ReminderOrganizer.InputDialog"
<Window x:Class="ReminderOrganizer.InputDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Input"
@@ -19,7 +19,7 @@
<SolidColorBrush x:Key="InputBackgroundBrush" Color="#F1F5F9"/>
</Window.Resources>
<Border CornerRadius="12" Background="{DynamicResource CardBrush}" Margin="8">
<Border CornerRadius="10" Background="{DynamicResource CardBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="10">
<Border.Effect>
<DropShadowEffect BlurRadius="20" ShadowDepth="5" Opacity="0.2" Direction="270" Color="Black"/>
</Border.Effect>
@@ -30,12 +30,11 @@
</Grid.RowDefinitions>
<!-- Header -->
<Border Grid.Row="0" Background="{DynamicResource PrimaryBrush}" CornerRadius="12,12,0,0" Padding="16,10">
<Border Grid.Row="0" Background="Transparent" CornerRadius="12,12,0,0" Padding="20,14,12,6">
<Grid>
<TextBlock Text="&#xE8B7;" FontFamily="Segoe MDL2 Assets" FontSize="16" Foreground="White" VerticalAlignment="Center"/>
<TextBlock x:Name="TxtTitle" FontSize="14" FontWeight="SemiBold" Foreground="White" VerticalAlignment="Center" Margin="28,0,36,0"/>
<Button Content="&#xE8BB;" FontFamily="Segoe MDL2 Assets" FontSize="10" HorizontalAlignment="Right" Foreground="White" Background="Transparent" BorderThickness="0"
Width="28" Height="28" Cursor="Hand" Click="BtnCancel_Click"/>
<TextBlock Text="&#xE8B7;" FontFamily="Segoe MDL2 Assets" FontSize="16" Foreground="{DynamicResource TextPrimaryBrush}" VerticalAlignment="Center"/>
<TextBlock x:Name="TxtTitle" FontSize="16" FontWeight="SemiBold" Foreground="{DynamicResource TextPrimaryBrush}" VerticalAlignment="Center" Margin="0,0,36,0"/>
<Button Content="&#xE8BB;" Style="{StaticResource IconButton}" FontSize="10" HorizontalAlignment="Right" Click="BtnCancel_Click" IsCancel="True"/>
</Grid>
</Border>

View File

@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System.Windows;
using System.Windows.Input;
using ReminderOrganizer.Core;
@@ -13,6 +13,7 @@ namespace ReminderOrganizer
public InputDialog(string title, string prompt, string defaultValue = "", bool? darkMode = null)
{
InitializeComponent();
DialogAnimation.Attach(this);
Title = title;
TxtTitle.Text = title;
TxtPrompt.Text = prompt;

View File

@@ -3,7 +3,7 @@
"File": "Datei",
"Exit": "Beenden",
"Extras": "Extras",
"Autostart": "Autostart",
"Autostart": "Mit Windows starten",
"Settings": "Einstellungen",
"Language": "Sprache",
"German": "Deutsch",
@@ -67,8 +67,8 @@
"DeleteTaskTooltip": "Task löschen",
"Info": "Info",
"Discord": "Discord-Community",
"Import": "Import",
"Export": "Export",
"Import": "Importieren",
"Export": "Exportieren",
"ImportCsv": "CSV Importieren",
"ExportCsv": "CSV Exportieren",
"ImportSuccess": "{0} Tasks erfolgreich importiert!",
@@ -88,5 +88,130 @@
"ConfirmDeleteTask": "Aufgabe \"{0}\" löschen?",
"ImportSkipped": "({0} Zeilen übersprungen)",
"PastDateWarning": "Das Datum liegt in der Vergangenheit – die Erinnerung kommt sofort.",
"MinimizedToTray": "Läuft weiter im Infobereich. Doppelklick aufs Symbol öffnet das Fenster."
"MinimizedToTray": "Läuft weiter im Infobereich. Doppelklick aufs Symbol öffnet das Fenster.",
"Upcoming": "Anstehend",
"CountOfTotal": "{0} von {1} Tasks",
"NoMatches": "Keine passenden Tasks",
"NoMatchesHint": "Andere Suche oder anderen Filter probieren.",
"SearchPlaceholder": "Suchen… (Strg+F)",
"FilterAll": "Alle",
"FilterToday": "Heute",
"FilterOverdue": "Überfällig",
"HideDone": "Erledigte ausblenden",
"PlaySound": "Erinnerungston",
"ExportIcs": "Kalender exportieren (.ics)",
"Color": "Farbe",
"MoveUp": "Nach oben",
"MoveDown": "Nach unten",
"Undo": "Rückgängig",
"DeletedItem": "„{0}“ gelöscht",
"TurnsAge": "wird {0}",
"LeadReminder": "Vorher erinnern",
"LeadNone": "Nein",
"LeadOneDay": "1 Tag vorher",
"LeadDays": "{0} Tage vorher",
"LeadWeek": "1 Woche vorher",
"BirthYear": "Geburtsjahr (optional)",
"TodayAt": "heute {0}",
"TomorrowAt": "morgen {0}",
"InDays": "in {0} Tagen",
"RemindersCount": "{0} Erinnerungen",
"BucketOverdue": "ÜBERFÄLLIG",
"BucketToday": "HEUTE",
"BucketTomorrow": "MORGEN",
"BucketThisWeek": "NÄCHSTE 7 TAGE",
"BucketLater": "SPÄTER",
"BucketDone": "ERLEDIGT",
"TypeAppointment": "Termin",
"BirthdayHint": "z. B. 19.03. oder 19.03.1986 – das Jahr ist optional",
"BirthdayInvalid": "Datum nicht erkannt – bitte TT.MM. oder TT.MM.JJJJ",
"Note": "Notiz",
"RelToday": "heute",
"RelTomorrow": "morgen",
"RelYesterday": "gestern",
"RelInDays": "in {0} Tagen",
"RelDaysAgo": "vor {0} Tagen",
"ViewList": "Liste",
"ViewCompact": "Kompakt",
"ViewCards": "Kacheln",
"TypeAnniversary": "Jahrestag",
"AnniversaryDate": "Datum",
"Category": "Kategorie",
"Categories": "Kategorien",
"CatIcon": "Symbol",
"CatText": "Text mit Jahren",
"CatExample": "Vorschau",
"NewCategory": "Neue Kategorie",
"ConfirmDeleteCategory": "Kategorie „{0}“ löschen? Ihre {1} Einträge werden zu Geburtstagen.",
"EditCategories": "Kategorien…",
"GroupByMonth": "Nach Monaten gruppieren (Klick auf einen Monat klappt ihn zu)",
"Months": "Monate",
"NewAnniversaryOf": "Neu: {0}",
"EditAnniversaryOf": "{0} bearbeiten",
"CatBirthday": "Geburtstag",
"CatBirthdayFormat": "wird {0}",
"CatWedding": "Hochzeitstag",
"CatWeddingFormat": "{o} Hochzeitstag",
"CatJubilee": "Jubiläum",
"CatJubileeFormat": "{0} Jahre",
"CatMemorial": "Gedenktag",
"CatMemorialFormat": "vor {0} Jahren",
"Wedding1": "Papierhochzeit",
"Wedding5": "Hölzerne Hochzeit",
"Wedding10": "Rosenhochzeit",
"Wedding15": "Kristallhochzeit",
"Wedding20": "Porzellanhochzeit",
"Wedding25": "Silberhochzeit",
"Wedding30": "Perlenhochzeit",
"Wedding40": "Rubinhochzeit",
"Wedding50": "Goldene Hochzeit",
"Wedding60": "Diamantene Hochzeit",
"Wedding65": "Eiserne Hochzeit",
"Wedding70": "Gnadenhochzeit",
"NewEntry": "Neu",
"UpcomingBadgeTooltip": "Überfällig oder in den nächsten 7 Tagen",
"Restore": "Wiederherstellen",
"ThemeSystem": "System",
"SetAppearance": "Darstellung",
"SetTheme": "Farbschema",
"SetReminders": "Erinnerungen",
"PlaySoundHint": "Kurzer Ton, wenn eine Erinnerung erscheint.",
"AutostartHint": "Startet unsichtbar im Infobereich, damit keine Erinnerung verpasst wird.",
"TestNotificationHint": "Aussehen einer Erinnerung prüfen",
"CategoriesShort": "Arten von Jahrestagen mit eigenem Symbol, Farbe und Text.",
"EditCategoriesButton": "Bearbeiten…",
"SetData": "Daten",
"SetDataFolder": "Datenordner",
"OpenFolder": "Öffnen",
"SetCalendar": "Kalender (.ics)",
"SetCalendarHint": "Für Outlook, Google und Apple Kalender.",
"SetShortcuts": "Tastenkürzel",
"ShortcutSearch": "Suchen",
"ShortcutEdit": "Markierten Eintrag bearbeiten",
"ShortcutDelete": "Markierten Eintrag löschen",
"ShortcutEsc": "Suche / Auswahl aufheben",
"MovedToNext": "„{0}“ verschoben auf {1}",
"TestNow": "Test senden",
"CategoriesIntro": "Jahrestage wiederholen sich jährlich und haben keine Uhrzeit. Hochzeitstage zeigen zusätzlich den Namen (Silberhochzeit, Goldene Hochzeit …).",
"CatPlaceholderYears": "Anzahl der Jahre",
"CatPlaceholderOrdinal": "Ordnungszahl (25.)",
"CatChangeLook": "Symbol und Farbe ändern",
"AddCategoryShort": "Kategorie",
"Snooze10": "10 Min",
"Snooze60": "1 Std",
"SnoozeTomorrow": "Morgen",
"ToastDone": "Erledigt",
"SummarySetting": "Tagesübersicht",
"SummarySettingHint": "Einmal am Tag: heutige Einträge, nahe Geburtstage und Überfälliges.",
"SummaryTitle": "Dein Tag",
"SummaryToday": "Heute:",
"SummaryOverdue": "{0} überfällig",
"DataFolderHint": "Für mehrere PCs einen synchronisierten Ordner wählen, z. B. in OneDrive.",
"ChangeFolder": "Ändern…",
"ChooseDataFolder": "Datenordner wählen",
"DataFolderHasData": "In diesem Ordner liegen schon Erinnerungen.\n\nJa = die Erinnerungen dort verwenden\nNein = sie durch meine ersetzen",
"ImportIcs": "Kalender importieren (.ics)",
"IcsImported": "{0} Einträge importiert, {1} übersprungen",
"IcsNothingNew": "Keine neuen Einträge gefunden ({0} übersprungen – schon vorhanden oder vergangen).",
"FolderBirthdays": "Geburtstage"
}

View File

@@ -3,7 +3,7 @@
"File": "File",
"Exit": "Exit",
"Extras": "Extras",
"Autostart": "Autostart",
"Autostart": "Start with Windows",
"Settings": "Settings",
"Language": "Language",
"German": "German",
@@ -65,7 +65,7 @@
"NextMonth": "Next Month",
"EditTaskTooltip": "Edit task",
"DeleteTaskTooltip": "Delete task",
"Info": "Info",
"Info": "About",
"Discord": "Discord community",
"Import": "Import",
"Export": "Export",
@@ -88,5 +88,130 @@
"ConfirmDeleteTask": "Delete task \"{0}\"?",
"ImportSkipped": "({0} rows skipped)",
"PastDateWarning": "This date is in the past – the reminder will show right away.",
"MinimizedToTray": "Still running in the tray. Double-click the icon to open."
"MinimizedToTray": "Still running in the tray. Double-click the icon to open.",
"Upcoming": "Upcoming",
"CountOfTotal": "{0} of {1} tasks",
"NoMatches": "No matching tasks",
"NoMatchesHint": "Try a different search or filter.",
"SearchPlaceholder": "Search… (Ctrl+F)",
"FilterAll": "All",
"FilterToday": "Today",
"FilterOverdue": "Overdue",
"HideDone": "Hide done",
"PlaySound": "Reminder sound",
"ExportIcs": "Export calendar (.ics)",
"Color": "Color",
"MoveUp": "Move up",
"MoveDown": "Move down",
"Undo": "Undo",
"DeletedItem": "\"{0}\" deleted",
"TurnsAge": "turns {0}",
"LeadReminder": "Remind in advance",
"LeadNone": "No",
"LeadOneDay": "1 day before",
"LeadDays": "{0} days before",
"LeadWeek": "1 week before",
"BirthYear": "Year of birth (optional)",
"TodayAt": "today {0}",
"TomorrowAt": "tomorrow {0}",
"InDays": "in {0} days",
"RemindersCount": "{0} reminders",
"BucketOverdue": "OVERDUE",
"BucketToday": "TODAY",
"BucketTomorrow": "TOMORROW",
"BucketThisWeek": "NEXT 7 DAYS",
"BucketLater": "LATER",
"BucketDone": "DONE",
"TypeAppointment": "Appointment",
"BirthdayHint": "e.g. 19.03. or 19.03.1986 – the year is optional",
"BirthdayInvalid": "Date not recognized – please use DD.MM. or DD.MM.YYYY",
"Note": "Note",
"RelToday": "today",
"RelTomorrow": "tomorrow",
"RelYesterday": "yesterday",
"RelInDays": "in {0} days",
"RelDaysAgo": "{0} days ago",
"ViewList": "List",
"ViewCompact": "Compact",
"ViewCards": "Cards",
"TypeAnniversary": "Anniversary",
"AnniversaryDate": "Date",
"Category": "Category",
"Categories": "Categories",
"CatIcon": "Icon",
"CatText": "Text with years",
"CatExample": "Preview",
"NewCategory": "New category",
"ConfirmDeleteCategory": "Delete category \"{0}\"? Its {1} entries become birthdays.",
"EditCategories": "Categories…",
"GroupByMonth": "Group by month (click a month to fold it)",
"Months": "Months",
"NewAnniversaryOf": "New {0}",
"EditAnniversaryOf": "Edit {0}",
"CatBirthday": "Birthday",
"CatBirthdayFormat": "turns {0}",
"CatWedding": "Wedding anniversary",
"CatWeddingFormat": "{o} anniversary",
"CatJubilee": "Jubilee",
"CatJubileeFormat": "{0} years",
"CatMemorial": "Memorial day",
"CatMemorialFormat": "{0} years ago",
"Wedding1": "Paper",
"Wedding5": "Wood",
"Wedding10": "Tin",
"Wedding15": "Crystal",
"Wedding20": "China",
"Wedding25": "Silver",
"Wedding30": "Pearl",
"Wedding40": "Ruby",
"Wedding50": "Golden",
"Wedding60": "Diamond",
"Wedding65": "Blue sapphire",
"Wedding70": "Platinum",
"NewEntry": "New",
"UpcomingBadgeTooltip": "Overdue or due within 7 days",
"Restore": "Restore",
"ThemeSystem": "System",
"SetAppearance": "Appearance",
"SetTheme": "Theme",
"SetReminders": "Reminders",
"PlaySoundHint": "A short chime when a reminder is shown.",
"AutostartHint": "Starts hidden in the notification area so no reminder is missed.",
"TestNotificationHint": "Check how a reminder looks",
"CategoriesShort": "Kinds of yearly anniversaries with their own icon, color and text.",
"EditCategoriesButton": "Edit…",
"SetData": "Data",
"SetDataFolder": "Data folder",
"OpenFolder": "Open",
"SetCalendar": "Calendar (.ics)",
"SetCalendarHint": "For Outlook, Google and Apple Calendar.",
"SetShortcuts": "Keyboard shortcuts",
"ShortcutSearch": "Search",
"ShortcutEdit": "Edit selected entry",
"ShortcutDelete": "Delete selected entry",
"ShortcutEsc": "Clear search / selection",
"MovedToNext": "\"{0}\" moved to {1}",
"TestNow": "Send test",
"CategoriesIntro": "Anniversaries repeat every year and have no time. Wedding anniversaries also show the traditional name (Silver, Gold …).",
"CatPlaceholderYears": "number of years",
"CatPlaceholderOrdinal": "ordinal (25th)",
"CatChangeLook": "Change icon and color",
"AddCategoryShort": "Category",
"Snooze10": "10 min",
"Snooze60": "1 hour",
"SnoozeTomorrow": "Tomorrow",
"ToastDone": "Done",
"SummarySetting": "Morning summary",
"SummarySettingHint": "Once a day: today's entries, upcoming birthdays and anything overdue.",
"SummaryTitle": "Your day",
"SummaryToday": "Today:",
"SummaryOverdue": "{0} overdue",
"DataFolderHint": "For several PCs choose a synced folder, e.g. in OneDrive.",
"ChangeFolder": "Change…",
"ChooseDataFolder": "Choose data folder",
"DataFolderHasData": "This folder already contains reminders.\n\nYes = use the reminders in that folder\nNo = replace them with mine",
"ImportIcs": "Import calendar (.ics)",
"IcsImported": "{0} entries imported, {1} skipped",
"IcsNothingNew": "No new entries found ({0} skipped – already there or in the past).",
"FolderBirthdays": "Birthdays"
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,8 @@
#nullable enable
#nullable enable
using System;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -31,11 +33,13 @@ namespace ReminderOrganizer
?? throw new InvalidOperationException("MainViewModel not found");
DataContext = _viewModel;
_viewModel.ThemeChanged += (_, dark) => ApplyTheme(dark, animate: true);
_viewModel.ThemeChanged += (_, dark) => Theme.Apply(Application.Current.Resources, dark);
_viewModel.EditTaskRequested += OnEditTaskRequested;
_viewModel.PropertyChanged += OnViewModelPropertyChanged;
Microsoft.Win32.SystemEvents.UserPreferenceChanged += OnUserPreferenceChanged;
TrySetWindowIcon();
SourceInitialized += (_, _) => UseRoundedCorners();
Loaded += async (_, _) => await InitializeOnceAsync();
StateChanged += MainWindow_StateChanged;
}
@@ -53,8 +57,73 @@ namespace ReminderOrganizer
_initialized = true;
SetupTrayIcon();
await _viewModel.InitializeAsync();
ApplyTheme(_viewModel.IsDarkMode, animate: false);
Theme.Apply(Application.Current.Resources, _viewModel.IsDarkMode);
RestoreWindowPlacement();
SyncTreeSelection();
// The window starts invisible so the user never sees the default theme flash.
BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(160)));
_ready = true;
foreach (var pending in _pendingToasts.ToArray()) HandleToast(pending);
_pendingToasts.Clear();
}
public void OnAppExit()
{
if (!_initialized) return;
RememberWindowPlacement();
Microsoft.Win32.SystemEvents.UserPreferenceChanged -= OnUserPreferenceChanged;
_viewModel.Cleanup();
_viewModel.FlushSave();
}
private void OnUserPreferenceChanged(object? sender, Microsoft.Win32.UserPreferenceChangedEventArgs e)
{
if (e.Category == Microsoft.Win32.UserPreferenceCategory.General)
Dispatcher.BeginInvoke(_viewModel.OnSystemThemeChanged);
}
// ---------- window placement ----------
private void RestoreWindowPlacement()
{
if (_viewModel.SavedWindowBounds is Rect r)
{
// only if the saved rectangle is still (mostly) on a screen
var screen = new Rect(SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop,
SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight);
if (screen.IntersectsWith(new Rect(r.Left + 40, r.Top, Math.Max(1, r.Width - 80), 40)))
{
WindowStartupLocation = WindowStartupLocation.Manual;
Left = r.Left;
Top = r.Top;
Width = Math.Max(MinWidth, r.Width);
Height = Math.Max(MinHeight, r.Height);
}
}
if (_viewModel.SavedWindowMaximized) WindowState = WindowState.Maximized;
}
private void RememberWindowPlacement()
{
var bounds = WindowState == WindowState.Normal ? new Rect(Left, Top, Width, Height) : RestoreBounds;
if (bounds.Width > 0 && bounds.Height > 0)
_viewModel.RememberWindow(bounds, WindowState == WindowState.Maximized);
}
// Windows 11: native rounded corners for our custom-chrome window.
[DllImport("dwmapi.dll")]
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int value, int size);
private void UseRoundedCorners()
{
try
{
int round = 2; // DWMWCP_ROUND
DwmSetWindowAttribute(new WindowInteropHelper(this).Handle, 33, ref round, sizeof(int));
}
catch { /* older Windows */ }
}
private void TrySetWindowIcon()
@@ -65,24 +134,30 @@ namespace ReminderOrganizer
}
catch
{
// no Assets\app.ico yet – Windows default icon
// no Assets\app.ico – Windows default icon
}
}
private void OnViewModelPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(MainViewModel.SelectedFolder))
if (e.PropertyName is nameof(MainViewModel.SelectedFolder) or nameof(MainViewModel.IsUpcomingMode))
SyncTreeSelection();
}
/// <summary>TreeView.SelectedItem is read-only – mirror the view model selection onto the container.</summary>
private void SyncTreeSelection()
{
var folder = _viewModel.SelectedFolder;
if (folder == null) return;
Dispatcher.BeginInvoke(() =>
{
if (FolderTree.ItemContainerGenerator.ContainerFromItem(folder) is TreeViewItem item && !item.IsSelected)
if (_viewModel.IsUpcomingMode)
{
if (FolderTree.SelectedItem != null &&
FolderTree.ItemContainerGenerator.ContainerFromItem(FolderTree.SelectedItem) is TreeViewItem sel)
sel.IsSelected = false;
return;
}
var folder = _viewModel.SelectedFolder;
if (folder != null && FolderTree.ItemContainerGenerator.ContainerFromItem(folder) is TreeViewItem item && !item.IsSelected)
{
item.IsSelected = true;
item.BringIntoView();
@@ -90,40 +165,121 @@ namespace ReminderOrganizer
}, System.Windows.Threading.DispatcherPriority.Loaded);
}
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
{
bool ctrl = (Keyboard.Modifiers & ModifierKeys.Control) != 0;
bool typing = Keyboard.FocusedElement is TextBox;
if (ctrl && e.Key == Key.N)
{
if (_viewModel.AddTaskCommand.CanExecute(null)) _viewModel.AddTaskCommand.Execute(null);
e.Handled = true;
}
else if (ctrl && e.Key == Key.F)
{
SearchBox.Focus();
SearchBox.SelectAll();
e.Handled = true;
}
else if (ctrl && e.Key == Key.OemComma)
{
_viewModel.OpenSettingsCommand.Execute(null);
e.Handled = true;
}
else if (e.Key == Key.Escape && (SearchBox.IsKeyboardFocusWithin || _viewModel.SearchText.Length > 0))
{
_viewModel.ClearSearchCommand.Execute(null);
FolderTree.Focus();
e.Handled = true;
}
else if (e.Key == Key.Escape && _viewModel.SelectedTask != null)
{
_viewModel.SelectedTask = null;
e.Handled = true;
}
else if (ctrl && e.Key == Key.Z && _viewModel.IsUndoVisible && !typing)
{
_viewModel.UndoCommand.Execute(null);
e.Handled = true;
}
else if (e.Key == Key.Delete && !typing && _viewModel.SelectedTask != null)
{
_viewModel.DeleteTaskCommand.Execute(_viewModel.SelectedTask);
_viewModel.SelectedTask = null;
e.Handled = true;
}
else if (e.Key == Key.Enter && !typing && _viewModel.SelectedTask != null)
{
_viewModel.EditTaskCommand.Execute(_viewModel.SelectedTask);
e.Handled = true;
}
// list navigation (the folder tree keeps its own arrow keys)
else if (!typing && !FolderTree.IsKeyboardFocusWithin && e.Key is Key.Down or Key.Up or Key.Home or Key.End)
{
MoveSelection(e.Key);
e.Handled = true;
}
else if (!typing && e.Key == Key.Space && _viewModel.SelectedTask is { } sel)
{
sel.IsNotified = !sel.IsNotified;
_viewModel.ToggleDoneCommand.Execute(sel);
e.Handled = true;
}
}
/// <summary>Arrow keys move the selection in display order (across groups) and keep it visible.</summary>
private void MoveSelection(Key key)
{
var items = _viewModel.TasksView?.Cast<ReminderTask>().ToList();
if (items == null || items.Count == 0) return;
int idx = _viewModel.SelectedTask is { } cur ? items.IndexOf(cur) : -1;
int next = key switch
{
Key.Home => 0,
Key.End => items.Count - 1,
Key.Down => idx < 0 ? 0 : Math.Min(items.Count - 1, idx + 1),
_ => idx < 0 ? items.Count - 1 : Math.Max(0, idx - 1)
};
_viewModel.SelectedTask = items[next];
Dispatcher.BeginInvoke(() => FindContainer(ListScroll, items[next])?.BringIntoView(),
System.Windows.Threading.DispatcherPriority.Loaded);
}
/// <summary>Rows sit inside group containers, so ItemContainerGenerator can't find them – search the tree.</summary>
private static FrameworkElement? FindContainer(DependencyObject root, object item)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
{
var child = VisualTreeHelper.GetChild(root, i);
if (child is ContentPresenter cp && ReferenceEquals(cp.Content, item)) return cp;
if (FindContainer(child, item) is { } found) return found;
}
return null;
}
private void OnEditTaskRequested(object? sender, ReminderTask? task)
{
if (task == null) return;
var taskWindow = new TaskWindow(task, _viewModel.IsDarkMode) { Owner = this };
var taskWindow = new TaskWindow(task, _viewModel.IsDarkMode, _viewModel.Categories) { Owner = this };
if (taskWindow.ShowDialog() == true)
{
_ = _viewModel.SaveAsync();
}
}
private void ApplyTheme(bool isDarkMode, bool animate)
{
Theme.Apply(Resources, isDarkMode);
if (!animate || ThemeTransitionOverlay == null) return;
var overlay = ThemeTransitionOverlay;
overlay.Background = new SolidColorBrush(isDarkMode ? Color.FromRgb(0x12, 0x12, 0x18) : Color.FromRgb(0xF1, 0xF5, 0xF9));
var fadeIn = new DoubleAnimation(0, 0.3, TimeSpan.FromMilliseconds(100));
var fadeOut = new DoubleAnimation(0.3, 0, TimeSpan.FromMilliseconds(200));
fadeIn.Completed += (s, args) => overlay.BeginAnimation(OpacityProperty, fadeOut);
overlay.BeginAnimation(OpacityProperty, fadeIn);
}
// ---------- caption ----------
private void MainWindow_StateChanged(object? sender, EventArgs e)
{
if (WindowState == WindowState.Minimized)
{
HideToTray();
}
// With WindowChrome a maximized window reaches past the screen edge by the resize border.
RootGrid.Margin = WindowState == WindowState.Maximized ? new Thickness(7) : new Thickness(0);
MaximizeButton.Content = WindowState == WindowState.Maximized ? "\uE923" : "\uE922";
MaximizeButton.ToolTip = _viewModel.L(WindowState == WindowState.Maximized ? "Restore" : "Maximize");
}
private void HideToTray()
{
RememberWindowPlacement();
Hide();
if (!_trayHintShown && _notifyIcon != null)
{
@@ -132,50 +288,30 @@ namespace ReminderOrganizer
}
}
private void TitleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 2)
{
MaximizeRestore();
}
else if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
}
private void MinimizeButton_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
private void MinimizeButton_Click(object sender, RoutedEventArgs e) => SystemCommands.MinimizeWindow(this);
private void MaximizeButton_Click(object sender, RoutedEventArgs e)
{
MaximizeRestore();
if (WindowState == WindowState.Maximized) SystemCommands.RestoreWindow(this);
else SystemCommands.MaximizeWindow(this);
}
private void MaximizeRestore()
{
if (WindowState == WindowState.Maximized)
{
WindowState = WindowState.Normal;
MaximizeButton.Content = "";
}
else
{
// WindowStyle=None would cover the taskbar – limit to the work area.
MaxHeight = SystemParameters.WorkArea.Height + 8;
MaxWidth = SystemParameters.WorkArea.Width + 8;
WindowState = WindowState.Maximized;
MaximizeButton.Content = "";
}
}
/// <summary>The window's X keeps the app running in the tray (reminders need it); "Exit" is in the tray menu.</summary>
private void CloseButton_Click(object sender, RoutedEventArgs e) => HideToTray();
private void CloseButton_Click(object sender, RoutedEventArgs e)
protected override void OnClosing(CancelEventArgs e)
{
// Alt+F4 / taskbar "close window": same as the X button unless the app is shutting down.
if (!_shuttingDown)
{
e.Cancel = true;
HideToTray();
}
base.OnClosing(e);
}
private bool _shuttingDown;
public void AllowClose() => _shuttingDown = true;
private void SetupTrayIcon()
{
System.Drawing.Icon icon = System.Drawing.SystemIcons.Information;
@@ -195,18 +331,71 @@ namespace ReminderOrganizer
Services.NotificationService.SharedTrayIcon = _notifyIcon;
var menu = new System.Windows.Forms.ContextMenuStrip();
menu.Items.Add(_viewModel.L("Open"), null, (s, e) => ShowMainWindow());
menu.Items.Add(_viewModel.L("Exit"), null, (s, e) =>
// WPF menu instead of the WinForms one, so it uses the app's theme styles.
_notifyIcon.MouseUp += (s, e) =>
{
_viewModel.Cleanup();
Application.Current.Shutdown();
});
_notifyIcon.ContextMenuStrip = menu;
if (e.Button == System.Windows.Forms.MouseButtons.Right) ShowTrayMenu();
};
_notifyIcon.DoubleClick += (s, e) => ShowMainWindow();
_notifyIcon.BalloonTipClicked += (s, e) => ShowMainWindow();
}
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
private void ShowTrayMenu()
{
MenuItem Item(string key, string glyph, Action onClick)
{
var mi = new MenuItem
{
Header = _viewModel.L(key),
Icon = new TextBlock { Text = glyph, FontFamily = (FontFamily)FindResource("IconFont"), FontSize = 12 }
};
mi.Click += (_, _) => onClick();
return mi;
}
var menu = new ContextMenu { Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint };
menu.Items.Add(Item("Open", "", ShowMainWindow));
menu.Items.Add(Item("NewEntry", "", () =>
{
ShowMainWindow();
if (_viewModel.AddTaskCommand.CanExecute(null)) _viewModel.AddTaskCommand.Execute(null);
}));
var sound = Item("PlaySound", "", () => _viewModel.PlaySound = !_viewModel.PlaySound);
sound.IsChecked = _viewModel.PlaySound;
sound.Icon = null; // the check mark shows the state
menu.Items.Add(sound);
menu.Items.Add(new Separator());
menu.Items.Add(Item("Exit", "", App.Quit));
menu.IsOpen = true;
// A popup from the tray only closes on outside clicks if it owns the foreground.
if (PresentationSource.FromVisual(menu) is HwndSource src) SetForegroundWindow(src.Handle);
}
// ---------- Windows notification buttons ----------
private readonly System.Collections.Generic.List<Microsoft.Toolkit.Uwp.Notifications.ToastArguments> _pendingToasts = new();
private bool _ready;
/// <summary>Snooze / done / open from a toast. Waits until the data is loaded.</summary>
public void HandleToast(Microsoft.Toolkit.Uwp.Notifications.ToastArguments args)
{
if (!_ready)
{
_pendingToasts.Add(args);
return;
}
args.TryGetValue("action", out string? action);
args.TryGetValue("id", out string? id);
args.TryGetValue("min", out string? minutes);
args.TryGetValue("lead", out string? lead);
_viewModel.HandleToastAction(action ?? "open", id, minutes, lead == "1");
if ((action ?? "open") == "open") ShowMainWindow();
}
private void ShowMainWindow()
{
Show();
@@ -217,18 +406,43 @@ namespace ReminderOrganizer
private void FolderTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
if (e.NewValue is Folder folder)
_viewModel.SelectedFolder = folder;
_viewModel.SelectFolder(folder);
}
private void TreeViewItem_RightClick(object sender, MouseButtonEventArgs e)
{
if (sender is TreeViewItem treeViewItem && treeViewItem.DataContext is Folder folder)
{
_viewModel.SelectedFolder = folder;
_viewModel.SelectFolder(folder);
treeViewItem.IsSelected = true;
}
}
// A click on an already selected folder (e.g. coming back from "Upcoming") must switch too.
private Point _folderDragStart;
private Folder? _folderDragCandidate;
private void TreeViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (sender is TreeViewItem item && item.DataContext is Folder folder)
{
_folderDragStart = e.GetPosition(this);
_folderDragCandidate = folder;
if (item.IsSelected) _viewModel.SelectFolder(folder);
}
}
private void TreeViewItem_PreviewMouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton != MouseButtonState.Pressed || _folderDragCandidate == null || sender is not TreeViewItem item) return;
var delta = e.GetPosition(this) - _folderDragStart;
if (Math.Abs(delta.Y) < SystemParameters.MinimumVerticalDragDistance * 2 &&
Math.Abs(delta.X) < SystemParameters.MinimumHorizontalDragDistance * 2) return;
var folder = _folderDragCandidate;
_folderDragCandidate = null;
DragDrop.DoDragDrop(item, folder, DragDropEffects.Move);
}
private void AddTaskToFolder_Click(object sender, RoutedEventArgs e)
{
if (_viewModel.SelectedFolder != null)
@@ -251,42 +465,6 @@ namespace ReminderOrganizer
}
}
private void TaskItem_MouseEnter(object sender, MouseEventArgs e)
{
if (sender is Border border)
{
if (border.RenderTransform is ScaleTransform scaleTransform)
{
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, new DoubleAnimation(1, 1.01, TimeSpan.FromMilliseconds(150)));
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, new DoubleAnimation(1, 1.01, TimeSpan.FromMilliseconds(150)));
}
if (border.Effect is System.Windows.Media.Effects.DropShadowEffect effect)
{
effect.BeginAnimation(System.Windows.Media.Effects.DropShadowEffect.BlurRadiusProperty, new DoubleAnimation(15, TimeSpan.FromMilliseconds(200)));
effect.BeginAnimation(System.Windows.Media.Effects.DropShadowEffect.OpacityProperty, new DoubleAnimation(0.35, TimeSpan.FromMilliseconds(200)));
}
border.SetResourceReference(Border.BackgroundProperty, "HoverBrush");
}
}
private void TaskItem_MouseLeave(object sender, MouseEventArgs e)
{
if (sender is Border border)
{
if (border.RenderTransform is ScaleTransform scaleTransform)
{
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, new DoubleAnimation(1, TimeSpan.FromMilliseconds(150)));
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, new DoubleAnimation(1, TimeSpan.FromMilliseconds(150)));
}
if (border.Effect is System.Windows.Media.Effects.DropShadowEffect effect)
{
effect.BeginAnimation(System.Windows.Media.Effects.DropShadowEffect.BlurRadiusProperty, new DoubleAnimation(0, TimeSpan.FromMilliseconds(150)));
effect.BeginAnimation(System.Windows.Media.Effects.DropShadowEffect.OpacityProperty, new DoubleAnimation(0, TimeSpan.FromMilliseconds(150)));
}
border.Background = Brushes.Transparent;
}
}
private void TaskItem_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton != MouseButtonState.Pressed || sender is not FrameworkElement element || element.DataContext is not ReminderTask task)
@@ -300,17 +478,6 @@ namespace ReminderOrganizer
DragDrop.DoDragDrop(element, task, DragDropEffects.Move);
}
// kept for styles that still reference them
private void SecondaryButton_MouseEnter(object sender, MouseEventArgs e)
{
if (sender is Border border) border.SetResourceReference(Border.BackgroundProperty, "HoverBrush");
}
private void SecondaryButton_MouseLeave(object sender, MouseEventArgs e)
{
if (sender is Border border) border.Background = Brushes.Transparent;
}
private void TreeView_DragOver(object sender, DragEventArgs e)
{
e.Effects = e.Data.GetDataPresent(typeof(ReminderTask)) ? DragDropEffects.Move : DragDropEffects.None;
@@ -322,15 +489,18 @@ namespace ReminderOrganizer
// Drops on a folder are handled by TreeViewItem_Drop; empty space does nothing.
}
private static bool IsOurDrag(DragEventArgs e) =>
e.Data.GetDataPresent(typeof(ReminderTask)) || e.Data.GetDataPresent(typeof(Folder));
private void TreeViewItem_DragOver(object sender, DragEventArgs e)
{
e.Effects = e.Data.GetDataPresent(typeof(ReminderTask)) ? DragDropEffects.Move : DragDropEffects.None;
e.Effects = IsOurDrag(e) ? DragDropEffects.Move : DragDropEffects.None;
e.Handled = true;
}
private void TreeViewItem_DragEnter(object sender, DragEventArgs e)
{
if (sender is TreeViewItem item && e.Data.GetDataPresent(typeof(ReminderTask))) item.Tag = "DropTarget";
if (sender is TreeViewItem item && IsOurDrag(e)) item.Tag = "DropTarget";
}
private void TreeViewItem_DragLeave(object sender, DragEventArgs e)
@@ -343,10 +513,16 @@ namespace ReminderOrganizer
if (sender is TreeViewItem treeViewItem)
{
treeViewItem.Tag = null;
if (e.Data.GetData(typeof(ReminderTask)) is ReminderTask task && treeViewItem.DataContext is Folder targetFolder)
if (treeViewItem.DataContext is not Folder targetFolder) return;
if (e.Data.GetData(typeof(ReminderTask)) is ReminderTask task)
{
_viewModel.MoveTaskToFolderCommand.Execute((task, targetFolder));
}
else if (e.Data.GetData(typeof(Folder)) is Folder dragged && dragged != targetFolder)
{
_viewModel.MoveFolder(dragged, _viewModel.Folders.IndexOf(targetFolder));
_viewModel.SelectFolder(dragged);
}
}
e.Handled = true;
}

113
Models/Category.cs Normal file
View File

@@ -0,0 +1,113 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Globalization;
using ReminderOrganizer.Core;
namespace ReminderOrganizer.Models
{
/// <summary>Sidebar entry for a category (count = open anniversaries).</summary>
public record CategoryNavItem(string Id, string Name, string Glyph, string Color, int Count, bool IsActive);
/// <summary>
/// Kind of anniversary (birthday, wedding, jubilee …). Text uses {0} = years, {o} = ordinal ("10." / "10th").
/// </summary>
public class Category : ViewModelBase
{
public const string BirthdayId = "birthday";
public const string WeddingId = "wedding";
public const string JubileeId = "jubilee";
public const string MemorialId = "memorial";
/// <summary>Segoe MDL2 glyphs offered in the editor (theme-colored, no emojis).</summary>
public static readonly string[] Glyphs =
{
"", // balloon
"", // heart
"", // star
"", // people
"", // message
"", // home
"", // flag
"", // history
"", // calendar
"", // music
"", // pet (dog/paw-like)
"", // light bulb
};
private string _id = Guid.NewGuid().ToString("N");
private string _name = "";
private string _glyph = Glyphs[0];
private string _color = Folder.DefaultColor;
private string _format = "{0}";
private bool _isWedding;
public string Id { get => _id; set => SetProperty(ref _id, value); }
public string Name { get => _name; set => SetProperty(ref _name, value); }
public string Glyph { get => _glyph; set => SetProperty(ref _glyph, value); }
public string Color { get => _color; set => SetProperty(ref _color, value); }
/// <summary>e.g. "turns {0}", "{o} anniversary", "{0} years ago".</summary>
public string Format { get => _format; set => SetProperty(ref _format, value); }
/// <summary>Adds the traditional wedding name (Silver, Gold …).</summary>
public bool IsWedding { get => _isWedding; set => SetProperty(ref _isWedding, value); }
public bool IsPreset => Id is BirthdayId or WeddingId or JubileeId or MemorialId;
public Category Clone() => new()
{
Id = Id, Name = Name, Glyph = Glyph, Color = Color, Format = Format, IsWedding = IsWedding
};
/// <summary>Default categories in the given language.</summary>
public static List<Category> Defaults(Func<string, string> L) => new()
{
new() { Id = BirthdayId, Name = L("CatBirthday"), Glyph = "", Color = "#EC4899", Format = L("CatBirthdayFormat") },
new() { Id = WeddingId, Name = L("CatWedding"), Glyph = "", Color = "#F59E0B", Format = L("CatWeddingFormat"), IsWedding = true },
new() { Id = JubileeId, Name = L("CatJubilee"), Glyph = "", Color = "#3B82F6", Format = L("CatJubileeFormat") },
new() { Id = MemorialId, Name = L("CatMemorial"), Glyph = "", Color = "#64748B", Format = L("CatMemorialFormat") },
};
/// <summary>
/// Presets that still carry a default text of some language get the texts of the new language
/// (user-edited names/formats stay untouched).
/// </summary>
public static void RelocalizePresets(IEnumerable<Category> categories, Func<string, string> L,
IEnumerable<IReadOnlyDictionary<string, string>> allLanguages)
{
var langs = new List<IReadOnlyDictionary<string, string>>(allLanguages);
foreach (var c in categories)
{
if (!c.IsPreset) continue;
var key = c.Id switch { BirthdayId => "CatBirthday", WeddingId => "CatWedding", JubileeId => "CatJubilee", _ => "CatMemorial" };
if (langs.Exists(d => d.TryGetValue(key, out var n) && n == c.Name)) c.Name = L(key);
if (langs.Exists(d => d.TryGetValue(key + "Format", out var f) && f == c.Format)) c.Format = L(key + "Format");
}
}
/// <summary>Years for which a wedding anniversary has a traditional name (key "Wedding{n}").</summary>
public static readonly int[] WeddingYears = { 1, 5, 10, 15, 20, 25, 30, 40, 50, 60, 65, 70 };
/// <summary>"10th" (en) / "10." (de).</summary>
public static string Ordinal(int n, CultureInfo culture)
{
if (culture.TwoLetterISOLanguageName != "en") return n + ".";
var suffix = (n % 100) is 11 or 12 or 13 ? "th" : (n % 10) switch { 1 => "st", 2 => "nd", 3 => "rd", _ => "th" };
return n + suffix;
}
/// <summary>Applies the format; for weddings appends the traditional name if known.</summary>
public string FormatYears(int years, CultureInfo culture, Func<string, string> L)
{
var text = (Format ?? "{0}")
.Replace("{o}", Ordinal(years, culture))
.Replace("{0}", years.ToString(culture));
if (IsWedding && Array.IndexOf(WeddingYears, years) >= 0)
{
var name = L("Wedding" + years);
if (!string.IsNullOrEmpty(name) && name != "Wedding" + years) text += " · " + name;
}
return text;
}
}
}

View File

@@ -1,6 +1,8 @@
#nullable enable
#nullable enable
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using ReminderOrganizer.Core;
namespace ReminderOrganizer.Models
@@ -36,27 +38,189 @@ namespace ReminderOrganizer.Models
public DateTime ReminderDate
{
get => _reminderDate;
set => SetProperty(ref _reminderDate, value);
set { if (SetProperty(ref _reminderDate, value)) RaiseDisplay(); }
}
public bool IsNotified
{
get => _isNotified;
set => SetProperty(ref _isNotified, value);
set { if (SetProperty(ref _isNotified, value)) OnPropertyChanged(nameof(RelativeDate)); }
}
public bool IsRecurring
{
get => _isRecurring;
set => SetProperty(ref _isRecurring, value);
set { if (SetProperty(ref _isRecurring, value)) OnPropertyChanged(nameof(AgeText)); }
}
public RecurrenceType RecurrenceType
{
get => _recurrenceType;
set => SetProperty(ref _recurrenceType, value);
set { if (SetProperty(ref _recurrenceType, value)) OnPropertyChanged(nameof(AgeText)); }
}
private DateTime? _snoozedUntil;
/// <summary>Snoozed reminder for recurring entries (the real date stays unchanged).</summary>
public DateTime? SnoozedUntil
{
get => _snoozedUntil;
set => SetProperty(ref _snoozedUntil, value);
}
/// <summary>
/// "Remind me again later": one-off tasks move their date; recurring tasks and anniversaries keep their
/// date (it already moved to the next occurrence) and get an extra reminder at <c>now + delay</c>.
/// </summary>
/// <param name="keepDate">true for a lead ("in 2 days") reminder: the real date must not move.</param>
public void Snooze(DateTime until, bool keepDate = false)
{
if (IsRecurring || keepDate)
{
SnoozedUntil = until;
}
else
{
ReminderDate = until;
IsNotified = false;
IsPreNotified = true; // the lead reminder is long past
}
}
private int _leadDays;
/// <summary>Extra reminder this many days before the date (0 = none).</summary>
public int LeadDays
{
get => _leadDays;
set => SetProperty(ref _leadDays, Math.Max(0, value));
}
private bool _isPreNotified;
/// <summary>Lead reminder already shown for the current occurrence.</summary>
public bool IsPreNotified
{
get => _isPreNotified;
set => SetProperty(ref _isPreNotified, value);
}
private int? _birthYear;
/// <summary>Optional, for yearly birthdays: shows "turns 40".</summary>
public int? BirthYear
{
get => _birthYear;
set { if (SetProperty(ref _birthYear, value)) OnPropertyChanged(nameof(AgeText)); }
}
/// <summary>Age reached on the next date (yearly tasks with birth year only).</summary>
[System.Text.Json.Serialization.JsonIgnore]
public int? UpcomingAge =>
BirthYear is int y && IsRecurring && RecurrenceType == RecurrenceType.Yearly && ReminderDate.Year > y
? ReminderDate.Year - y : null;
/// <summary>Set once by the app: (task, years) → "turns 40" / "10th anniversary · Tin" …</summary>
public static Func<ReminderTask, int, string>? AgeFormatter { get; set; }
[System.Text.Json.Serialization.JsonIgnore]
public string? AgeText => UpcomingAge is int a ? (AgeFormatter?.Invoke(this, a) ?? a.ToString()) : null;
private bool _isAnniversary;
/// <summary>Anniversary (birthday, wedding …): yearly, date only, reminded at <see cref="BirthdayHour"/>.
/// Stored as "IsBirthday" for compatibility with older files.</summary>
[System.Text.Json.Serialization.JsonPropertyName("IsBirthday")]
public bool IsAnniversary
{
get => _isAnniversary;
set { if (SetProperty(ref _isAnniversary, value)) RaiseDisplay(); }
}
private string? _categoryId;
/// <summary>Anniversary category (see <see cref="Category"/>); null = birthday.</summary>
public string? CategoryId
{
get => _categoryId;
set { if (SetProperty(ref _categoryId, value)) RaiseDisplay(); }
}
/// <summary>Set once by the app: id → category.</summary>
public static Func<string?, Category?>? CategoryLookup { get; set; }
[System.Text.Json.Serialization.JsonIgnore]
public Category? Category => IsAnniversary ? CategoryLookup?.Invoke(CategoryId ?? Category.BirthdayId) : null;
/// <summary>Accent color: category for anniversaries, otherwise folder.</summary>
[System.Text.Json.Serialization.JsonIgnore]
public string AccentColor => Category?.Color ?? FolderColor;
[System.Text.Json.Serialization.JsonIgnore]
public string? CategoryGlyph => Category?.Glyph;
/// <summary>Call after categories were edited.</summary>
public void RefreshCategory()
{
OnPropertyChanged(nameof(Category));
RaiseDisplay();
}
public const int BirthdayHour = 9;
/// <summary>Set once by the app: culture for month names, relative-date formatter.</summary>
public static Func<CultureInfo>? DisplayCulture { get; set; }
public static Func<DateTime, DateTime, string>? RelativeFormatter { get; set; }
public static Func<RecurrenceType, string>? RecurrenceFormatter { get; set; }
/// <summary>"Weekly" etc. for recurring appointments (empty for one-off tasks and anniversaries).</summary>
[System.Text.Json.Serialization.JsonIgnore]
public string RecurrenceText => IsRecurring && !IsAnniversary ? RecurrenceFormatter?.Invoke(RecurrenceType) ?? RecurrenceType.ToString() : "";
/// <summary>"19. März" for birthdays, otherwise "19.03.2027 09:00".</summary>
[System.Text.Json.Serialization.JsonIgnore]
public string DisplayDate => IsAnniversary
? ReminderDate.ToString(DayMonthPattern(DisplayCulture?.Invoke() ?? CultureInfo.CurrentCulture), DisplayCulture?.Invoke() ?? CultureInfo.CurrentCulture)
: ReminderDate.ToString("dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture);
/// <summary>"heute", "morgen", "in 5 Tagen", "vor 2 Tagen".</summary>
[System.Text.Json.Serialization.JsonIgnore]
public string RelativeDate => IsNotified ? "" : RelativeFormatter?.Invoke(ReminderDate, DateTime.Now) ?? "";
[System.Text.Json.Serialization.JsonIgnore]
public int DaysUntil => (ReminderDate.Date - DateTime.Today).Days;
/// <summary>Day number + short month for the card view.</summary>
[System.Text.Json.Serialization.JsonIgnore]
public string DayText => ReminderDate.Day.ToString(CultureInfo.InvariantCulture);
[System.Text.Json.Serialization.JsonIgnore]
public string MonthText => ReminderDate.ToString("MMM", DisplayCulture?.Invoke() ?? CultureInfo.CurrentCulture).TrimEnd('.').ToUpperInvariant();
public static string DayMonthPattern(CultureInfo c) => c.TwoLetterISOLanguageName == "de" ? "d. MMMM" : "MMMM d";
private void RaiseDisplay()
{
OnPropertyChanged(nameof(DisplayDate));
OnPropertyChanged(nameof(RelativeDate));
OnPropertyChanged(nameof(DaysUntil));
OnPropertyChanged(nameof(DayText));
OnPropertyChanged(nameof(MonthText));
OnPropertyChanged(nameof(AgeText));
OnPropertyChanged(nameof(AccentColor));
OnPropertyChanged(nameof(CategoryGlyph));
}
/// <summary>Next birthday on/after <paramref name="today"/> at BirthdayHour (29 Feb → 28 Feb in other years).</summary>
public static DateTime NextBirthday(int day, int month, DateTime today)
{
DateTime For(int year) => new(year, month, Math.Min(day, DateTime.DaysInMonth(year, month)), BirthdayHour, 0, 0);
var d = For(today.Year);
return d.Date >= today.Date ? d : For(today.Year + 1);
}
private string _folderName = "";
/// <summary>Runtime only: name of the folder holding this task (for the "Upcoming" view).</summary>
[System.Text.Json.Serialization.JsonIgnore]
public string FolderName { get => _folderName; set => SetProperty(ref _folderName, value); }
private string _folderColor = Folder.DefaultColor;
[System.Text.Json.Serialization.JsonIgnore]
public string FolderColor { get => _folderColor; set { if (SetProperty(ref _folderColor, value)) OnPropertyChanged(nameof(AccentColor)); } }
public DateTime GetNextOccurrence() => GetNextOccurrence(DateTime.Now);
/// <summary>
@@ -94,22 +258,39 @@ namespace ReminderOrganizer.Models
/// <summary>
/// Marks every due task: one-off tasks become notified, recurring ones move to their next date.
/// Returns the tasks that should be shown as a notification now.
/// Also emits lead reminders (LeadDays before the date) once per occurrence.
/// Returns what should be shown now; for lead reminders <see cref="DueReminder.Date"/> is the upcoming date.
/// </summary>
public static System.Collections.Generic.List<ReminderTask> ProcessDue(System.Collections.Generic.IEnumerable<Folder> folders, DateTime now)
public static System.Collections.Generic.List<DueReminder> ProcessDue(System.Collections.Generic.IEnumerable<Folder> folders, DateTime now)
{
var due = new System.Collections.Generic.List<ReminderTask>();
var due = new System.Collections.Generic.List<DueReminder>();
foreach (var folder in folders)
{
foreach (var task in folder.Tasks)
{
if (task.IsNotified || task.ReminderDate > now) continue;
due.Add(task);
if (task.IsNotified) continue;
// snoozed reminder of a recurring entry: fire once, keep the real date
if (task.SnoozedUntil is DateTime snoozed && snoozed <= now)
{
due.Add(new DueReminder(task, task.ReminderDate, false, task.UpcomingAge));
task.SnoozedUntil = null;
continue;
}
if (task.ReminderDate <= now)
{
due.Add(new DueReminder(task, task.ReminderDate, false, task.UpcomingAge));
task.IsPreNotified = false;
if (task.IsRecurring)
task.ReminderDate = task.GetNextOccurrence(now);
else
task.IsNotified = true;
}
else if (task.LeadDays > 0 && !task.IsPreNotified && now >= task.ReminderDate.AddDays(-task.LeadDays))
{
due.Add(new DueReminder(task, task.ReminderDate, true, task.UpcomingAge));
task.IsPreNotified = true;
}
}
}
return due;
}
@@ -124,6 +305,9 @@ namespace ReminderOrganizer.Models
}
}
/// <summary>One notification to show. Age is the age reached on <paramref name="Date"/> (birthdays).</summary>
public record DueReminder(ReminderTask Task, DateTime Date, bool IsLead, int? Age);
public enum RecurrenceType
{
Daily,
@@ -156,6 +340,17 @@ namespace ReminderOrganizer.Models
set => SetProperty(ref _tasks, value);
}
public const string DefaultColor = "#6366F1";
public static readonly string[] Palette =
{ "#6366F1", "#3B82F6", "#14B8A6", "#22C55E", "#F59E0B", "#F97316", "#EF4444", "#EC4899", "#64748B" };
private string _color = DefaultColor;
public string Color
{
get => _color;
set => SetProperty(ref _color, string.IsNullOrWhiteSpace(value) ? DefaultColor : value);
}
public Folder() { }
public Folder(string name)
@@ -167,7 +362,99 @@ namespace ReminderOrganizer.Models
public class AppData
{
public ObservableCollection<Folder> Folders { get; set; } = new();
public string Language { get; set; } = "en";
public bool IsDarkMode { get; set; } = true;
/// <summary>"de"/"en"; empty = not chosen yet → Windows display language.</summary>
public string Language { get; set; } = "";
/// <summary>null = not chosen yet → Windows app theme.</summary>
public bool? IsDarkMode { get; set; }
public bool PlaySound { get; set; } = true;
public bool HideDone { get; set; }
/// <summary>"system", "light", "dark" (empty = from IsDarkMode of older files).</summary>
public string ThemeMode { get; set; } = "";
/// <summary>Last window position/size (device-independent pixels).</summary>
public double? WindowLeft { get; set; }
public double? WindowTop { get; set; }
public double? WindowWidth { get; set; }
public double? WindowHeight { get; set; }
public bool WindowMaximized { get; set; }
/// <summary>Morning summary: on/off, hour, last day it was shown.</summary>
public bool DailySummary { get; set; } = true;
public int SummaryHour { get; set; } = 8;
public DateTime? LastSummaryDate { get; set; }
/// <summary>"list", "compact" or "cards".</summary>
public string ViewMode { get; set; } = "list";
/// <summary>Group the list by month (collapsible).</summary>
public bool GroupByMonth { get; set; }
/// <summary>Anniversary categories (birthday, wedding, … and own ones). Filled with defaults on first start.</summary>
public ObservableCollection<Category> Categories { get; set; } = new();
/// <summary>Adds missing default categories (keeps user edits of existing ones).</summary>
public bool EnsureDefaultCategories(Func<string, string> L)
{
bool changed = false;
int insertAt = 0;
foreach (var def in Category.Defaults(L))
{
if (Categories.Any(c => c.Id == def.Id)) { insertAt++; continue; }
Categories.Insert(Math.Min(insertAt++, Categories.Count), def);
changed = true;
}
return changed;
}
/// <summary>Folders and yearly tasks were checked for birthdays once.</summary>
public bool BirthdaysMigrated { get; set; }
public static bool LooksLikeBirthdayFolder(string? name) =>
name != null && (name.Contains("geburtstag", StringComparison.OrdinalIgnoreCase) ||
name.Contains("birthday", StringComparison.OrdinalIgnoreCase));
/// <summary>Yearly tasks in a "Geburtstage"/"Birthdays" folder become birthday entries (one-time).</summary>
public int MigrateBirthdays()
{
int n = 0;
if (!BirthdaysMigrated)
{
BirthdaysMigrated = true;
n += MarkYearly(LooksLikeBirthdayFolder, Category.BirthdayId);
}
if (!WeddingsMigrated)
{
WeddingsMigrated = true;
n += MarkYearly(LooksLikeWeddingFolder, Category.WeddingId);
}
return n;
}
public bool WeddingsMigrated { get; set; }
public static bool LooksLikeWeddingFolder(string? name) =>
name != null && (name.Contains("hochzeit", StringComparison.OrdinalIgnoreCase) ||
name.Contains("wedding", StringComparison.OrdinalIgnoreCase) ||
name.Contains("jahrestag", StringComparison.OrdinalIgnoreCase) ||
name.Contains("anniversar", StringComparison.OrdinalIgnoreCase));
/// <summary>Category a new anniversary in this folder should get (null = no hint).</summary>
public static string? CategoryHintForFolder(string? name) =>
LooksLikeBirthdayFolder(name) ? Category.BirthdayId : LooksLikeWeddingFolder(name) ? Category.WeddingId : null;
private int MarkYearly(Func<string?, bool> folderMatches, string categoryId)
{
int n = 0;
foreach (var f in Folders)
{
if (!folderMatches(f.Name)) continue;
foreach (var t in f.Tasks)
{
if (t.IsAnniversary || !t.IsRecurring || t.RecurrenceType != RecurrenceType.Yearly) continue;
t.IsAnniversary = true;
t.CategoryId = categoryId;
n++;
}
}
return n;
}
}
}

View File

@@ -7,17 +7,29 @@ It runs in the system tray (notification area).
## Features
- Folders with tasks (date, time, description), sorted by date: open tasks first
- Folders with tasks (date, time, description), sorted overdue → today → later → done
- **Upcoming** view: every folder in one list, grouped by Overdue, Today, Tomorrow, Next 7 days, Later
- **Search** (Ctrl+F), filters All/Today/Overdue, "Hide done"
- One-off or recurring reminders (daily, weekly, monthly, yearly)
- Reminders missed while the app was closed are shown at the next start
- Drag a task onto a folder to move it
- **Remind in advance** (1, 2 or 3 days, or 1 week before)
- **Anniversaries** without a time: enter "19.03." or "19.03.1986". Categories Birthday ("turns 40"), Wedding anniversary
("25th anniversary · Silver"), Jubilee, Memorial day, plus your own (Settings → Categories: icon, color, text)
- Sidebar **Categories** shows every birthday / wedding … across all folders
- Views **list / compact / cards**; **group by month** (click a month to fold it)
- Windows notifications with **snooze** (10 min, 1 hour, tomorrow) and **Done**; missed reminders are shown at the next start, with a reminder sound (can be turned off)
- **Morning summary** once a day (time adjustable): today's entries, birthdays in the next 3 days, overdue items
- **Folder colors** and order (drag or context menu); drag a task onto a folder to move it
- **Undo** after deleting (Ctrl+Z), shortcuts Ctrl+N (new task), Del, Esc
- CSV import/export (`Folder;Name;Description;Date;IsRecurring;RecurrenceType`, date `yyyy-MM-dd HH:mm`)
- Dark/light theme, German/English
- **Calendar import and export (.ics)** for Outlook, Google and Apple Calendar (recurrence, advance reminder, birthdays incl. Google's birthday calendar; re-importing skips existing entries)
- **Data folder selectable** (e.g. OneDrive) – several PCs share the same reminders; changes from another PC are loaded automatically
- Keyboard: arrow keys / Home / End move through the list, Space marks done
- Dark/light theme (follows Windows by default), English by default, German in Settings
- Autostart with Windows, starting hidden in the tray (`--minimized`)
## Data
Tasks are stored in `%APPDATA%\ReminderOrganizer\tasks.json`. The app keeps `tasks.json.bak` as a backup
Tasks are stored in `%APPDATA%\ReminderOrganizer\tasks.json`, or in the folder chosen under Settings → Data (pointer file `location.json`). The app keeps `tasks.json.bak` as a backup
of the previous save, and saves a broken file as `tasks.json.corrupt-<time>` instead of overwriting it.
`error.log` is in the same folder.
On first start, an older `tasks.json` next to the exe is copied over automatically.

View File

@@ -18,7 +18,7 @@
<Version>1.1.0</Version>
</PropertyGroup>
<PropertyGroup Condition="Exists('Assets\app.ico')">
<PropertyGroup>
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
</PropertyGroup>
@@ -33,11 +33,14 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Locales\*.json" LogicalName="Locales.%(Filename).json" />
<Resource Include="Assets\app.ico" Condition="Exists('Assets\app.ico')" />
<Resource Include="Assets\app.ico" />
<Resource Include="Assets\app.png" />
<Resource Include="Assets\reminder.wav" />
</ItemGroup>
<ItemGroup>

View File

@@ -21,6 +21,8 @@ namespace ReminderOrganizer
services.AddSingleton<IDataService>(_ =>
{
var ds = new DataService();
if (Environment.GetEnvironmentVariable("REMINDER_ORGANIZER_DATA") is { Length: > 0 })
return ds; // isolated test/screenshot run: never pull in real data
// Older versions stored tasks.json next to the exe (or in the single-file extract dir).
ds.MigrateFrom(System.IO.Path.GetDirectoryName(Environment.ProcessPath));
ds.MigrateFrom(AppContext.BaseDirectory);

View File

@@ -23,14 +23,56 @@ namespace ReminderOrganizer.Services
private readonly SemaphoreSlim _writeLock = new(1, 1);
public string DataFilePath { get; }
public string DataFilePath { get; private set; }
public string DataDirectory => Path.GetDirectoryName(DataFilePath)!;
/// <summary>%APPDATA%\ReminderOrganizer – or REMINDER_ORGANIZER_DATA (for tests/screenshots).</summary>
public static string DefaultDataDirectory =>
/// <summary>Time stamp of our own last write – a different one means another PC (sync) changed the file.</summary>
public DateTime LastWriteUtc { get; private set; }
/// <summary>
/// App folder (pointer file, error log): %APPDATA%\ReminderOrganizer – or REMINDER_ORGANIZER_DATA (tests/screenshots).
/// </summary>
public static string AppDirectory =>
Environment.GetEnvironmentVariable("REMINDER_ORGANIZER_DATA") is { Length: > 0 } custom
? custom
: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ReminderOrganizer");
/// <summary>Where tasks.json lives: the folder chosen in Settings (e.g. OneDrive), otherwise the app folder.</summary>
public static string DefaultDataDirectory => ReadPointer(AppDirectory) ?? AppDirectory;
private const string PointerFile = "location.json";
/// <summary>Chosen data folder from location.json, or null (none / folder gone).</summary>
public static string? ReadPointer(string appDirectory)
{
try
{
var file = Path.Combine(appDirectory, PointerFile);
if (!File.Exists(file)) return null;
using var doc = JsonDocument.Parse(File.ReadAllText(file));
var folder = doc.RootElement.TryGetProperty("DataFolder", out var p) ? p.GetString() : null;
return !string.IsNullOrWhiteSpace(folder) && Directory.Exists(folder) ? folder : null;
}
catch
{
return null;
}
}
/// <summary>Stores the data folder; null or the app folder itself removes the pointer.</summary>
public static void WritePointer(string appDirectory, string? folder)
{
Directory.CreateDirectory(appDirectory);
var file = Path.Combine(appDirectory, PointerFile);
if (string.IsNullOrWhiteSpace(folder) ||
string.Equals(Path.GetFullPath(folder).TrimEnd('\\'), Path.GetFullPath(appDirectory).TrimEnd('\\'), StringComparison.OrdinalIgnoreCase))
{
if (File.Exists(file)) File.Delete(file);
return;
}
File.WriteAllText(file, JsonSerializer.Serialize(new { DataFolder = folder }, _jsonOptions));
}
public DataService() : this(DefaultDataDirectory) { }
public DataService(string dataDirectory)
@@ -39,6 +81,62 @@ namespace ReminderOrganizer.Services
DataFilePath = Path.Combine(dataDirectory, "tasks.json");
}
/// <summary>Use another folder from now on (after moving or adopting its tasks.json).</summary>
public void SwitchTo(string dataDirectory)
{
StopWatching();
Directory.CreateDirectory(dataDirectory);
DataFilePath = Path.Combine(dataDirectory, "tasks.json");
LastWriteUtc = File.Exists(DataFilePath) ? File.GetLastWriteTimeUtc(DataFilePath) : default;
}
// ---------- sync: notice changes made by another PC ----------
private FileSystemWatcher? _watcher;
private Timer? _debounce;
/// <summary>Calls <paramref name="onExternalChange"/> (thread pool) when tasks.json changes and it wasn't us.</summary>
public void StartWatching(Action onExternalChange)
{
StopWatching();
if (File.Exists(DataFilePath)) LastWriteUtc = File.GetLastWriteTimeUtc(DataFilePath);
_debounce = new Timer(_ =>
{
try
{
if (IsExternalChange()) onExternalChange();
}
catch { /* file busy – next event */ }
});
_watcher = new FileSystemWatcher(DataDirectory, "tasks.json")
{
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.Size,
EnableRaisingEvents = true
};
FileSystemEventHandler h = (_, _) => _debounce?.Change(1000, Timeout.Infinite); // sync tools write in bursts
_watcher.Changed += h;
_watcher.Created += h;
_watcher.Renamed += (_, _) => _debounce?.Change(1000, Timeout.Infinite);
}
public void StopWatching()
{
_watcher?.Dispose();
_watcher = null;
_debounce?.Dispose();
_debounce = null;
}
/// <summary>True if the file on disk is newer than our own last write.</summary>
public bool IsExternalChange()
{
if (!File.Exists(DataFilePath)) return false;
var stamp = File.GetLastWriteTimeUtc(DataFilePath);
if (Math.Abs((stamp - LastWriteUtc).TotalMilliseconds) < 50) return false;
LastWriteUtc = stamp;
return true;
}
/// <summary>Copies tasks.json from an old location (next to the exe) if no data exists yet.</summary>
public void MigrateFrom(string? legacyDirectory)
{
@@ -84,6 +182,30 @@ namespace ReminderOrganizer.Services
catch { }
}
public void Save(AppData data)
{
_writeLock.Wait();
try
{
var tmp = DataFilePath + ".tmp";
File.WriteAllText(tmp, JsonSerializer.Serialize(data, _jsonOptions));
Commit(tmp);
}
finally
{
_writeLock.Release();
}
}
private void Commit(string tmp)
{
if (File.Exists(DataFilePath))
File.Replace(tmp, DataFilePath, DataFilePath + ".bak");
else
File.Move(tmp, DataFilePath);
LastWriteUtc = File.GetLastWriteTimeUtc(DataFilePath); // our own write is not a "sync change"
}
public async Task SaveAsync(AppData data)
{
await _writeLock.WaitAsync();
@@ -92,10 +214,7 @@ namespace ReminderOrganizer.Services
var json = JsonSerializer.Serialize(data, _jsonOptions);
var tmp = DataFilePath + ".tmp";
await File.WriteAllTextAsync(tmp, json);
if (File.Exists(DataFilePath))
File.Replace(tmp, DataFilePath, DataFilePath + ".bak");
else
File.Move(tmp, DataFilePath);
Commit(tmp);
}
catch (Exception ex)
{

92
Services/IcsExport.cs Normal file
View File

@@ -0,0 +1,92 @@
#nullable enable
using System;
using System.Globalization;
using System.Text;
using ReminderOrganizer.Models;
namespace ReminderOrganizer.Services
{
/// <summary>iCalendar (.ics) export for Outlook, Google Calendar, Apple Calendar.</summary>
public static class IcsExport
{
public static string Build(AppData data, DateTime utcNow)
{
var sb = new StringBuilder();
void Line(string s) => sb.Append(Fold(s)).Append("\r\n");
Line("BEGIN:VCALENDAR");
Line("VERSION:2.0");
Line("PRODID:-//Michael Media//Reminder Organizer//EN");
Line("CALSCALE:GREGORIAN");
var stamp = utcNow.ToUniversalTime().ToString("yyyyMMdd'T'HHmmss'Z'", CultureInfo.InvariantCulture);
foreach (var folder in data.Folders)
{
foreach (var t in folder.Tasks)
{
if (t.IsNotified) continue;
Line("BEGIN:VEVENT");
Line($"UID:{t.Id}@reminder-organizer");
Line($"DTSTAMP:{stamp}");
if (t.IsAnniversary)
{
// all-day event
Line($"DTSTART;VALUE=DATE:{t.ReminderDate.ToString("yyyyMMdd", CultureInfo.InvariantCulture)}");
}
else
{
// floating local time: shows at the same clock time in every calendar
Line($"DTSTART:{t.ReminderDate.ToString("yyyyMMdd'T'HHmmss", CultureInfo.InvariantCulture)}");
Line("DURATION:PT30M");
}
var summary = t.UpcomingAge is int age ? $"{t.Name} ({age})" : t.Name;
Line($"SUMMARY:{Escape(summary)}");
if (!string.IsNullOrWhiteSpace(t.Description)) Line($"DESCRIPTION:{Escape(t.Description)}");
Line($"CATEGORIES:{Escape(folder.Name)}");
if (t.IsRecurring)
{
var freq = t.RecurrenceType switch
{
RecurrenceType.Daily => "DAILY",
RecurrenceType.Weekly => "WEEKLY",
RecurrenceType.Monthly => "MONTHLY",
_ => "YEARLY"
};
Line($"RRULE:FREQ={freq}");
}
Line("BEGIN:VALARM");
Line("ACTION:DISPLAY");
Line($"DESCRIPTION:{Escape(t.Name)}");
// all-day events start at midnight: remind at 09:00 (same day or lead days before)
Line(t.IsAnniversary
? (t.LeadDays > 0 ? $"TRIGGER:-P{t.LeadDays - 1}DT15H" : "TRIGGER:PT9H")
: (t.LeadDays > 0 ? $"TRIGGER:-P{t.LeadDays}D" : "TRIGGER:PT0M"));
Line("END:VALARM");
Line("END:VEVENT");
}
}
Line("END:VCALENDAR");
return sb.ToString();
}
public static string Escape(string s) =>
s.Replace("\\", "\\\\").Replace(";", "\\;").Replace(",", "\\,").Replace("\r\n", "\\n").Replace("\n", "\\n").Replace("\r", "");
/// <summary>RFC 5545: lines longer than 75 octets continue with CRLF + space.</summary>
public static string Fold(string line)
{
var bytes = Encoding.UTF8.GetByteCount(line);
if (bytes <= 75) return line;
var sb = new StringBuilder();
int count = 0;
foreach (var ch in line)
{
int n = Encoding.UTF8.GetByteCount(ch.ToString());
if (count + n > 75) { sb.Append("\r\n "); count = 1; }
sb.Append(ch);
count += n;
}
return sb.ToString();
}
}
}

189
Services/IcsImport.cs Normal file
View File

@@ -0,0 +1,189 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using ReminderOrganizer.Models;
namespace ReminderOrganizer.Services
{
/// <summary>
/// iCalendar (.ics) import – counterpart of <see cref="IcsExport"/>. Reads Outlook, Google (incl. the birthday
/// calendar) and Apple exports. All-day yearly events become anniversaries.
/// </summary>
public static class IcsImport
{
public sealed record Result(List<ReminderTask> Tasks, int Skipped);
/// <param name="existingIds">Ids already in the app – events with the same UID are skipped (safe re-import).</param>
public static Result Parse(string ics, ISet<string> existingIds, DateTime now)
{
var tasks = new List<ReminderTask>();
int skipped = 0;
Dictionary<string, (string Params, string Value)>? ev = null;
bool inAlarm = false;
string? trigger = null;
foreach (var line in Unfold(ics))
{
if (line.Equals("BEGIN:VEVENT", StringComparison.OrdinalIgnoreCase)) { ev = new(StringComparer.OrdinalIgnoreCase); trigger = null; continue; }
if (ev == null) continue;
if (line.Equals("BEGIN:VALARM", StringComparison.OrdinalIgnoreCase)) { inAlarm = true; continue; }
if (line.Equals("END:VALARM", StringComparison.OrdinalIgnoreCase)) { inAlarm = false; continue; }
if (line.Equals("END:VEVENT", StringComparison.OrdinalIgnoreCase))
{
var task = ToTask(ev, trigger, existingIds, now);
if (task == null) skipped++;
else { tasks.Add(task); existingIds.Add(task.Id); }
ev = null;
continue;
}
int colon = line.IndexOf(':');
if (colon <= 0) continue;
var head = line[..colon];
var value = line[(colon + 1)..];
int semi = head.IndexOf(';');
var name = semi < 0 ? head : head[..semi];
var parameters = semi < 0 ? "" : head[(semi + 1)..];
if (inAlarm)
{
if (name.Equals("TRIGGER", StringComparison.OrdinalIgnoreCase)) trigger ??= value;
continue;
}
ev.TryAdd(name, (parameters, value));
}
return new Result(tasks, skipped);
}
private static ReminderTask? ToTask(Dictionary<string, (string Params, string Value)> ev, string? trigger,
ISet<string> existingIds, DateTime now)
{
if (!ev.TryGetValue("SUMMARY", out var summary) || string.IsNullOrWhiteSpace(summary.Value)) return null;
if (!ev.TryGetValue("DTSTART", out var start) || !TryParseDate(start.Params, start.Value, out var date, out bool allDay)) return null;
var uid = ev.TryGetValue("UID", out var u) && !string.IsNullOrWhiteSpace(u.Value) ? u.Value.Trim() : null;
if (uid != null && existingIds.Contains(uid)) return null;
var freq = ev.TryGetValue("RRULE", out var rrule) ? Regex.Match(rrule.Value, @"FREQ=(\w+)", RegexOptions.IgnoreCase).Groups[1].Value.ToUpperInvariant() : "";
var name = Unescape(summary.Value).Trim();
var description = ev.TryGetValue("DESCRIPTION", out var d) ? Unescape(d.Value).Trim() : "";
var task = new ReminderTask { Name = name, Description = description };
if (uid != null) task.Id = uid;
task.LeadDays = LeadDaysFrom(trigger, allDay);
if (allDay && freq == "YEARLY")
{
// anniversary: birthday, wedding, …
task.IsAnniversary = true;
task.IsRecurring = true;
task.RecurrenceType = RecurrenceType.Yearly;
task.CategoryId = GuessCategory(name + " " + description);
if (date.Year < now.Year && date.Year >= 1900) task.BirthYear = date.Year;
// our own export writes "Oma (86)" with the date of the next occurrence → year = date year − age
var age = Regex.Match(name, @"\s*\((\d{1,3})\)\s*$");
if (age.Success)
{
int y = date.Year - int.Parse(age.Groups[1].Value, CultureInfo.InvariantCulture);
if (y >= 1900 && y <= now.Year) task.BirthYear = y;
name = name[..age.Index];
}
task.ReminderDate = ReminderTask.NextBirthday(date.Day, date.Month, now.Date);
task.Name = StripCategoryWords(name);
return task;
}
if (allDay) date = date.Date.AddHours(ReminderTask.BirthdayHour);
task.ReminderDate = date;
if (freq is "DAILY" or "WEEKLY" or "MONTHLY" or "YEARLY")
{
task.IsRecurring = true;
task.RecurrenceType = freq switch
{
"DAILY" => RecurrenceType.Daily,
"WEEKLY" => RecurrenceType.Weekly,
"MONTHLY" => RecurrenceType.Monthly,
_ => RecurrenceType.Yearly
};
if (task.ReminderDate <= now) task.ReminderDate = task.GetNextOccurrence(now);
}
else if (date <= now)
{
return null; // past one-off events are not imported
}
return task;
}
/// <summary>Google's birthday calendar writes "Anna's birthday" / "Geburtstag von Anna" – keep just the name.</summary>
private static string StripCategoryWords(string name)
{
var n = Regex.Replace(name, @"^(Geburtstag von|Geburtstag:)\s*", "", RegexOptions.IgnoreCase);
n = Regex.Replace(n, @"(['’]s)?\s+(birthday|Geburtstag)$", "", RegexOptions.IgnoreCase);
return string.IsNullOrWhiteSpace(n) ? name : n.Trim();
}
public static string GuessCategory(string text)
{
var t = text.ToLowerInvariant();
if (t.Contains("hochzeit") || t.Contains("wedding") || t.Contains("anniversary") || t.Contains("jahrestag")) return Category.WeddingId;
if (t.Contains("jubiläum") || t.Contains("jubilaeum") || t.Contains("jubilee")) return Category.JubileeId;
if (t.Contains("todestag") || t.Contains("gedenk") || t.Contains("memorial")) return Category.MemorialId;
return Category.BirthdayId;
}
/// <summary>
/// "-P2D", "-PT24H", "-P1W" → days before (0 when none or after the start). All-day events start at
/// midnight, so "-PT15H" means "the day before at 09:00" → rounded up; timed events round down.
/// </summary>
public static int LeadDaysFrom(string? trigger, bool allDay = false)
{
if (string.IsNullOrWhiteSpace(trigger) || !trigger.TrimStart().StartsWith("-")) return 0;
var m = Regex.Match(trigger, @"P(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?)?", RegexOptions.IgnoreCase);
if (!m.Success) return 0;
int Val(int g) => m.Groups[g].Success ? int.Parse(m.Groups[g].Value, CultureInfo.InvariantCulture) : 0;
int hours = (Val(1) * 7 + Val(2)) * 24 + Val(3);
int days = allDay ? (hours + 23) / 24 : hours / 24;
return days switch { <= 0 => 0, 1 => 1, 2 => 2, <= 4 => 3, _ => 7 }; // nearest option of the app
}
public static bool TryParseDate(string parameters, string value, out DateTime date, out bool allDay)
{
value = value.Trim();
allDay = parameters.Contains("VALUE=DATE", StringComparison.OrdinalIgnoreCase) && !parameters.Contains("VALUE=DATE-TIME", StringComparison.OrdinalIgnoreCase)
|| value.Length == 8;
if (allDay)
return DateTime.TryParseExact(value[..Math.Min(8, value.Length)], "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out date);
bool utc = value.EndsWith("Z", StringComparison.OrdinalIgnoreCase);
if (!DateTime.TryParseExact(value.TrimEnd('Z', 'z'), new[] { "yyyyMMdd'T'HHmmss", "yyyyMMdd'T'HHmm" },
CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
return false;
if (utc) date = DateTime.SpecifyKind(date, DateTimeKind.Utc).ToLocalTime();
date = DateTime.SpecifyKind(date, DateTimeKind.Unspecified); // TZID / floating: treat as local time
return true;
}
public static IEnumerable<string> Unfold(string ics)
{
var sb = new StringBuilder();
foreach (var raw in ics.Replace("\r\n", "\n").Split('\n'))
{
if (raw.Length > 0 && (raw[0] == ' ' || raw[0] == '\t'))
{
sb.Append(raw, 1, raw.Length - 1);
continue;
}
if (sb.Length > 0) yield return sb.ToString();
sb.Clear().Append(raw.TrimEnd('\r'));
}
if (sb.Length > 0) yield return sb.ToString();
}
public static string Unescape(string s) =>
Regex.Replace(s, @"\\([\\;,nN])", m => m.Groups[1].Value is "n" or "N" ? "\n" : m.Groups[1].Value);
}
}

View File

@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -10,12 +10,19 @@ namespace ReminderOrganizer.Services
{
Task<AppData> LoadAsync();
Task SaveAsync(AppData data);
void Save(AppData data);
string DataFilePath { get; }
string DataDirectory { get; }
void SwitchTo(string dataDirectory);
void StartWatching(Action onExternalChange);
void StopWatching();
}
public interface INotificationService
{
void ShowNotification(string title, string message);
/// <summary>Reminder with snooze/done buttons for one task.</summary>
void ShowReminder(string title, string message, string taskId, bool isLead);
}
public interface ILocalizationService

View File

@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System;
using System.Collections.Generic;
using System.IO;
@@ -57,9 +57,16 @@ namespace ReminderOrganizer.Services
public void Initialize(AppData appData)
{
_appData = appData;
if (!string.IsNullOrEmpty(appData.Language))
// Default language is English; the user switches in Settings.
var lang = string.IsNullOrEmpty(appData.Language) ? "en" : appData.Language;
if (lang == _currentLanguage)
{
SetLanguage(appData.Language);
appData.Language = lang;
StringsChanged?.Invoke(this, EventArgs.Empty);
}
else
{
SetLanguage(lang);
}
}

View File

@@ -1,51 +1,117 @@
#nullable enable
using System;
using System.IO;
using System.Windows;
using System.Windows.Forms;
using Microsoft.Toolkit.Uwp.Notifications;
namespace ReminderOrganizer.Services
{
/// <summary>
/// Windows toast notifications (Action Center) with snooze buttons. Falls back to the tray balloon if toasts
/// are not available (e.g. notifications turned off or an old Windows build).
/// </summary>
public class NotificationService : INotificationService
{
private readonly object _lock = new();
private readonly ILocalizationService _loc;
private string? _logoPath;
public static NotifyIcon? SharedTrayIcon { get; set; }
public NotificationService(ILocalizationService localizationService)
{
_loc = localizationService;
}
public void ShowNotification(string title, string message)
{
try
{
System.Diagnostics.Debug.WriteLine($"[NotificationService] ShowNotification: {title} - {message}");
System.Diagnostics.Debug.WriteLine($"[NotificationService] SharedTrayIcon is null: {SharedTrayIcon == null}");
ShowBalloonTip(title, message);
Builder(title, message).AddArgument("action", "open").Show();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[NotificationService] Error: {ex.Message}");
System.Diagnostics.Debug.WriteLine($"[Toast] {ex.Message}");
ShowBalloon(title, message);
}
}
private void ShowBalloonTip(string title, string message)
public void ShowReminder(string title, string message, string taskId, bool isLead)
{
lock (_lock)
try
{
if (SharedTrayIcon != null)
string lead = isLead ? "1" : "0";
ToastButton Snooze(string label, string minutes) => new ToastButton()
.SetContent(label)
.AddArgument("action", "snooze").AddArgument("min", minutes)
.AddArgument("id", taskId).AddArgument("lead", lead)
.SetBackgroundActivation();
Builder(title, message)
.AddArgument("action", "open").AddArgument("id", taskId)
.AddButton(Snooze(_loc.GetString("Snooze10"), "10"))
.AddButton(Snooze(_loc.GetString("Snooze60"), "60"))
.AddButton(Snooze(_loc.GetString("SnoozeTomorrow"), "tomorrow"))
.AddButton(new ToastButton()
.SetContent(_loc.GetString("ToastDone"))
.AddArgument("action", "done").AddArgument("id", taskId).AddArgument("lead", lead)
.SetBackgroundActivation())
.Show();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[Toast] {ex.Message}");
ShowBalloon(title, message);
}
}
private ToastContentBuilder Builder(string title, string message)
{
var b = new ToastContentBuilder()
.AddText(string.IsNullOrWhiteSpace(title) ? "Reminder Organizer" : title);
if (!string.IsNullOrWhiteSpace(message)) b.AddText(message);
if (LogoPath() is { } logo) b.AddAppLogoOverride(new Uri(logo), ToastGenericAppLogoCrop.Default);
return b;
}
/// <summary>Toasts need the logo as a file – extract it once to the app folder.</summary>
private string? LogoPath()
{
if (_logoPath != null) return _logoPath;
try
{
var path = Path.Combine(DataService.AppDirectory, "toast-logo.png");
if (!File.Exists(path))
{
var res = System.Windows.Application.GetResourceStream(new Uri("pack://application:,,,/Assets/app.png"));
if (res == null) return null;
Directory.CreateDirectory(DataService.AppDirectory);
using var fs = File.Create(path);
res.Stream.CopyTo(fs);
}
return _logoPath = path;
}
catch
{
return null;
}
}
private static void ShowBalloon(string title, string message)
{
try
{
if (SharedTrayIcon == null) return;
// ShowBalloonTip throws on empty text – tasks without description would never notify.
SharedTrayIcon.BalloonTipTitle = string.IsNullOrWhiteSpace(title) ? "Reminder Organizer" : title;
SharedTrayIcon.BalloonTipText = string.IsNullOrWhiteSpace(message) ? " " : message;
SharedTrayIcon.BalloonTipIcon = ToolTipIcon.Info;
SharedTrayIcon.ShowBalloonTip(5000);
System.Diagnostics.Debug.WriteLine("[NotificationService] BalloonTip shown!");
}
else
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("[NotificationService] SharedTrayIcon is null, cannot show balloon tip!");
System.Diagnostics.Debug.WriteLine($"[Balloon] {ex.Message}");
}
}
}
public void Dispose()
{
}
}
}

32
Services/SoundService.cs Normal file
View File

@@ -0,0 +1,32 @@
#nullable enable
using System;
using System.Media;
using System.Windows;
namespace ReminderOrganizer.Services
{
/// <summary>Plays the reminder chime (Assets/reminder.wav, embedded as WPF resource).</summary>
public static class SoundService
{
private static SoundPlayer? _player;
public static void PlayReminder()
{
try
{
if (_player == null)
{
var res = Application.GetResourceStream(new Uri("pack://application:,,,/Assets/reminder.wav"));
if (res == null) { SystemSounds.Asterisk.Play(); return; }
_player = new SoundPlayer(res.Stream);
_player.Load();
}
_player.Play();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[Sound] {ex.Message}");
}
}
}
}

260
SettingsWindow.xaml Normal file
View File

@@ -0,0 +1,260 @@
<Window x:Class="ReminderOrganizer.SettingsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{Binding [Settings]}"
Width="620" Height="680"
WindowStartupLocation="CenterOwner" ResizeMode="NoResize" ShowInTaskbar="False"
WindowStyle="None" AllowsTransparency="True" Background="Transparent"
FontFamily="{StaticResource UiFont}" FontSize="13" Foreground="{DynamicResource TextPrimaryBrush}"
UseLayoutRounding="True"
MouseLeftButtonDown="Window_MouseLeftButtonDown" KeyDown="Window_KeyDown">
<Window.Resources>
<!-- one settings group -->
<Style x:Key="Group" TargetType="Border">
<Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="Margin" Value="0,0,0,18"/>
</Style>
<Style x:Key="GroupTitle" TargetType="TextBlock">
<Setter Property="FontSize" Value="13"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Margin" Value="2,0,0,8"/>
</Style>
<!-- one row inside a group: label left, control right -->
<Style x:Key="Row" TargetType="DockPanel">
<Setter Property="Margin" Value="16,12"/>
<Setter Property="LastChildFill" Value="False"/>
</Style>
<Style x:Key="RowLabel" TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="DockPanel.Dock" Value="Left"/>
</Style>
<Style x:Key="RowHint" TargetType="TextBlock">
<Setter Property="FontSize" Value="12"/>
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Margin" Value="0,2,0,0"/>
</Style>
<Style x:Key="Divider" TargetType="Border">
<Setter Property="Height" Value="1"/>
<Setter Property="Background" Value="{DynamicResource DividerBrush}"/>
</Style>
<Style x:Key="Key" TargetType="Border">
<Setter Property="CornerRadius" Value="4"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Background" Value="{DynamicResource CardBrush}"/>
<Setter Property="Padding" Value="6,1"/>
<Setter Property="Margin" Value="0,0,4,0"/>
</Style>
</Window.Resources>
<Border Margin="10" CornerRadius="10" Background="{DynamicResource CardBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
<Border.Effect>
<DropShadowEffect BlurRadius="24" ShadowDepth="6" Opacity="0.28" Direction="270" Color="Black"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- header -->
<DockPanel Margin="24,18,14,8">
<Button DockPanel.Dock="Right" Content="&#xE8BB;" Style="{StaticResource IconButton}" FontSize="10" Click="Close_Click" ToolTip="Esc"/>
<TextBlock Text="{Binding [Settings]}" FontSize="18" FontWeight="SemiBold" VerticalAlignment="Center"/>
</DockPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" Padding="24,8,20,20">
<StackPanel>
<!-- appearance -->
<TextBlock Text="{Binding [SetAppearance]}" Style="{StaticResource GroupTitle}"/>
<Border Style="{StaticResource Group}">
<StackPanel>
<DockPanel Style="{StaticResource Row}">
<TextBlock Text="{Binding [SetTheme]}" Style="{StaticResource RowLabel}"/>
<Border DockPanel.Dock="Right" Style="{StaticResource SegmentHost}">
<StackPanel Orientation="Horizontal">
<RadioButton GroupName="theme" Content="{Binding [ThemeSystem]}" IsChecked="{Binding IsThemeSystem}" Style="{StaticResource Segment}"/>
<RadioButton GroupName="theme" Content="{Binding [LightMode]}" IsChecked="{Binding IsThemeLight}" Style="{StaticResource Segment}"/>
<RadioButton GroupName="theme" Content="{Binding [DarkMode]}" IsChecked="{Binding IsThemeDark}" Style="{StaticResource Segment}"/>
</StackPanel>
</Border>
</DockPanel>
<Border Style="{StaticResource Divider}"/>
<DockPanel Style="{StaticResource Row}">
<TextBlock Text="{Binding [Language]}" Style="{StaticResource RowLabel}"/>
<Border DockPanel.Dock="Right" Style="{StaticResource SegmentHost}">
<StackPanel Orientation="Horizontal">
<RadioButton GroupName="lang" Content="Deutsch" IsChecked="{Binding IsGerman}" Style="{StaticResource Segment}"/>
<RadioButton GroupName="lang" Content="English" IsChecked="{Binding IsEnglish}" Style="{StaticResource Segment}"/>
</StackPanel>
</Border>
</DockPanel>
</StackPanel>
</Border>
<!-- reminders -->
<TextBlock Text="{Binding [SetReminders]}" Style="{StaticResource GroupTitle}"/>
<Border Style="{StaticResource Group}">
<StackPanel>
<DockPanel Style="{StaticResource Row}">
<StackPanel DockPanel.Dock="Left" MaxWidth="360">
<TextBlock Text="{Binding [PlaySound]}"/>
<TextBlock Text="{Binding [PlaySoundHint]}" Style="{StaticResource RowHint}"/>
</StackPanel>
<CheckBox DockPanel.Dock="Right" Style="{StaticResource ToggleSwitch}" IsChecked="{Binding PlaySound}" VerticalAlignment="Center"/>
</DockPanel>
<Border Style="{StaticResource Divider}"/>
<DockPanel Style="{StaticResource Row}">
<StackPanel DockPanel.Dock="Left" MaxWidth="360">
<TextBlock Text="{Binding [Autostart]}"/>
<TextBlock Text="{Binding [AutostartHint]}" Style="{StaticResource RowHint}"/>
</StackPanel>
<CheckBox DockPanel.Dock="Right" Style="{StaticResource ToggleSwitch}" IsChecked="{Binding IsAutostartEnabled}" VerticalAlignment="Center"/>
</DockPanel>
<Border Style="{StaticResource Divider}"/>
<DockPanel Style="{StaticResource Row}">
<StackPanel DockPanel.Dock="Left" MaxWidth="300">
<TextBlock Text="{Binding [SummarySetting]}"/>
<TextBlock Text="{Binding [SummarySettingHint]}" Style="{StaticResource RowHint}"/>
</StackPanel>
<CheckBox DockPanel.Dock="Right" Style="{StaticResource ToggleSwitch}" IsChecked="{Binding DailySummaryEnabled}" VerticalAlignment="Center"/>
<ComboBox DockPanel.Dock="Right" Width="92" Margin="0,0,16,0" VerticalAlignment="Center"
ItemsSource="{Binding SummaryHours}" SelectedItem="{Binding SummaryHour}"
IsEnabled="{Binding DailySummaryEnabled}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding StringFormat={}{0}:00}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DockPanel>
<Border Style="{StaticResource Divider}"/>
<DockPanel Style="{StaticResource Row}">
<TextBlock Text="{Binding [TestNotificationHint]}" Style="{StaticResource RowLabel}"/>
<Button DockPanel.Dock="Right" Content="{Binding [TestNow]}" Style="{StaticResource SubtleButton}" Command="{Binding TestNotificationCommand}"/>
</DockPanel>
</StackPanel>
</Border>
<!-- categories -->
<TextBlock Text="{Binding [Categories]}" Style="{StaticResource GroupTitle}"/>
<Border Style="{StaticResource Group}">
<DockPanel Style="{StaticResource Row}">
<StackPanel DockPanel.Dock="Left" MaxWidth="360">
<TextBlock Text="{Binding [CategoriesShort]}" TextWrapping="Wrap"/>
<ItemsControl ItemsSource="{Binding Categories}" Margin="0,8,0,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate><WrapPanel/></ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border CornerRadius="10" Padding="8,2" Margin="0,0,6,6" Background="{Binding Color, Converter={StaticResource HexToBrush}, ConverterParameter=0.14}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Glyph}" FontFamily="{StaticResource IconFont}" FontSize="11" VerticalAlignment="Center"
Foreground="{Binding Color, Converter={StaticResource HexToBrush}}"/>
<TextBlock Text="{Binding Name}" FontSize="12" Margin="6,0,0,0"/>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
<Button DockPanel.Dock="Right" Content="{Binding [EditCategoriesButton]}" Style="{StaticResource SubtleButton}"
Command="{Binding EditCategoriesCommand}" VerticalAlignment="Top"/>
</DockPanel>
</Border>
<!-- data -->
<TextBlock Text="{Binding [SetData]}" Style="{StaticResource GroupTitle}"/>
<Border Style="{StaticResource Group}">
<StackPanel>
<DockPanel Style="{StaticResource Row}">
<StackPanel DockPanel.Dock="Left" MaxWidth="300">
<TextBlock Text="{Binding [SetDataFolder]}"/>
<TextBlock Text="{Binding DataFolder}" Style="{StaticResource RowHint}" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap"
ToolTip="{Binding DataFolder}"/>
<TextBlock Text="{Binding [DataFolderHint]}" Style="{StaticResource RowHint}"/>
</StackPanel>
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" VerticalAlignment="Top">
<Button Content="{Binding [OpenFolder]}" Style="{StaticResource SubtleButton}" Command="{Binding OpenDataFolderCommand}" Margin="0,0,8,0"/>
<Button Content="{Binding [ChangeFolder]}" Style="{StaticResource SubtleButton}" Command="{Binding ChangeDataFolderCommand}"/>
</StackPanel>
</DockPanel>
<Border Style="{StaticResource Divider}"/>
<DockPanel Style="{StaticResource Row}">
<TextBlock Text="CSV" Style="{StaticResource RowLabel}"/>
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
<Button Content="{Binding [Import]}" Style="{StaticResource SubtleButton}" Command="{Binding ImportCsvCommand}" Margin="0,0,8,0"/>
<Button Content="{Binding [Export]}" Style="{StaticResource SubtleButton}" Command="{Binding ExportCsvCommand}"/>
</StackPanel>
</DockPanel>
<Border Style="{StaticResource Divider}"/>
<DockPanel Style="{StaticResource Row}">
<StackPanel DockPanel.Dock="Left" MaxWidth="330">
<TextBlock Text="{Binding [SetCalendar]}"/>
<TextBlock Text="{Binding [SetCalendarHint]}" Style="{StaticResource RowHint}"/>
</StackPanel>
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
<Button Content="{Binding [Import]}" Style="{StaticResource SubtleButton}" Command="{Binding ImportIcsCommand}" Margin="0,0,8,0"/>
<Button Content="{Binding [Export]}" Style="{StaticResource SubtleButton}" Command="{Binding ExportIcsCommand}"/>
</StackPanel>
</DockPanel>
</StackPanel>
</Border>
<!-- shortcuts -->
<TextBlock Text="{Binding [SetShortcuts]}" Style="{StaticResource GroupTitle}"/>
<Border Style="{StaticResource Group}" Padding="16,10">
<Grid TextElement.FontSize="12.5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,3"><Border Style="{StaticResource Key}"><TextBlock Text="Ctrl"/></Border><Border Style="{StaticResource Key}"><TextBlock Text="N"/></Border></StackPanel>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding [NewEntry]}" VerticalAlignment="Center"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,3"><Border Style="{StaticResource Key}"><TextBlock Text="Ctrl"/></Border><Border Style="{StaticResource Key}"><TextBlock Text="F"/></Border></StackPanel>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding [ShortcutSearch]}" VerticalAlignment="Center"/>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,3"><Border Style="{StaticResource Key}"><TextBlock Text="Enter"/></Border></StackPanel>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding [ShortcutEdit]}" VerticalAlignment="Center"/>
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,3"><Border Style="{StaticResource Key}"><TextBlock Text="Entf / Del"/></Border></StackPanel>
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding [ShortcutDelete]}" VerticalAlignment="Center"/>
<StackPanel Grid.Row="4" Orientation="Horizontal" Margin="0,3"><Border Style="{StaticResource Key}"><TextBlock Text="Ctrl"/></Border><Border Style="{StaticResource Key}"><TextBlock Text="Z"/></Border></StackPanel>
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding [Undo]}" VerticalAlignment="Center"/>
<StackPanel Grid.Row="5" Orientation="Horizontal" Margin="0,3"><Border Style="{StaticResource Key}"><TextBlock Text="Esc"/></Border></StackPanel>
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding [ShortcutEsc]}" VerticalAlignment="Center"/>
<StackPanel Grid.Row="6" Orientation="Horizontal" Margin="0,3"><Border Style="{StaticResource Key}"><TextBlock Text="Ctrl"/></Border><Border Style="{StaticResource Key}"><TextBlock Text=","/></Border></StackPanel>
<TextBlock Grid.Row="6" Grid.Column="1" Text="{Binding [Settings]}" VerticalAlignment="Center"/>
</Grid>
</Border>
<!-- about -->
<TextBlock Text="{Binding [Info]}" Style="{StaticResource GroupTitle}"/>
<Border Style="{StaticResource Group}" Margin="0">
<DockPanel Margin="16,14">
<Image DockPanel.Dock="Left" Source="/Assets/app.png" Width="40" Height="40" Margin="0,0,14,0" RenderOptions.BitmapScalingMode="HighQuality"/>
<StackPanel VerticalAlignment="Center">
<TextBlock FontWeight="SemiBold">
<Run Text="{Binding [AppTitle], Mode=OneWay}"/>
<Run Text="{Binding VersionText, Mode=OneWay}" FontWeight="Normal" Foreground="{DynamicResource TextSecondaryBrush}"/>
</TextBlock>
<TextBlock FontSize="12" Margin="0,2,0,0" Foreground="{DynamicResource TextSecondaryBrush}">
<Run Text="{Binding CopyrightText, Mode=OneWay}"/>
<Run Text=" · "/>
<Hyperlink Command="{Binding OpenDiscordCommand}" Foreground="{DynamicResource PrimaryBrush}" TextDecorations="None">discord.gg/Ej4JPmCZva</Hyperlink>
</TextBlock>
</StackPanel>
</DockPanel>
</Border>
</StackPanel>
</ScrollViewer>
</Grid>
</Border>
</Window>

31
SettingsWindow.xaml.cs Normal file
View File

@@ -0,0 +1,31 @@
#nullable enable
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using ReminderOrganizer.ViewModels;
namespace ReminderOrganizer
{
/// <summary>All settings in one place (replaces the old File/View menu). Changes apply immediately.</summary>
public partial class SettingsWindow : Window
{
public SettingsWindow(MainViewModel viewModel)
{
InitializeComponent();
DataContext = viewModel;
DialogAnimation.Attach(this);
}
private void Close_Click(object sender, RoutedEventArgs e) => Close();
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape) Close();
}
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed && e.OriginalSource is not TextBox) DragMove();
}
}
}

View File

@@ -1,4 +1,4 @@
<Window x:Class="ReminderOrganizer.TaskWindow"
<Window x:Class="ReminderOrganizer.TaskWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{Binding WindowTitle}"
@@ -20,6 +20,8 @@
<SolidColorBrush x:Key="InputBackgroundBrush" Color="#F1F5F9"/>
<SolidColorBrush x:Key="HoverBrush" Color="#E2E8F0"/>
<Style x:Key="Label" TargetType="TextBlock">
<Setter Property="FontSize" Value="11"/>
<Setter Property="FontWeight" Value="SemiBold"/>
@@ -89,7 +91,7 @@
</Style>
</Window.Resources>
<Border CornerRadius="12" Background="{DynamicResource CardBrush}" Margin="8">
<Border CornerRadius="10" Background="{DynamicResource CardBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="10">
<Border.Effect>
<DropShadowEffect BlurRadius="20" ShadowDepth="5" Opacity="0.25" Direction="270" Color="Black"/>
</Border.Effect>
@@ -100,26 +102,72 @@
</Grid.RowDefinitions>
<!-- Header -->
<Border Grid.Row="0" Background="{DynamicResource PrimaryBrush}" CornerRadius="12,12,0,0" Padding="16,10">
<Border Grid.Row="0" Background="Transparent" CornerRadius="12,12,0,0" Padding="20,14,12,6">
<Grid>
<StackPanel Orientation="Horizontal">
<TextBlock Text="&#xEA8F;" FontFamily="Segoe MDL2 Assets" FontSize="15" Foreground="White" VerticalAlignment="Center"/>
<TextBlock Text="{Binding WindowTitle}" FontSize="14" FontWeight="SemiBold" Foreground="White" VerticalAlignment="Center" Margin="10,0,0,0"/>
<TextBlock Text="{Binding WindowTitle}" FontSize="16" FontWeight="SemiBold" Foreground="{DynamicResource TextPrimaryBrush}" VerticalAlignment="Center"/>
</StackPanel>
<Button Content="&#xE8BB;" FontFamily="Segoe MDL2 Assets" FontSize="10" HorizontalAlignment="Right" Foreground="White" Background="Transparent" BorderThickness="0"
Width="28" Height="28" Cursor="Hand" Command="{Binding CancelCommand}" IsCancel="True"/>
<Button Content="&#xE8BB;" Style="{StaticResource IconButton}" FontSize="10" HorizontalAlignment="Right" Command="{Binding CancelCommand}" IsCancel="True"/>
</Grid>
</Border>
<!-- Content -->
<StackPanel Grid.Row="1" Margin="18,16,18,18">
<!-- Type: appointment / birthday -->
<Border Style="{StaticResource SegmentHost}" Margin="0,0,0,14" HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal">
<RadioButton GroupName="type" IsChecked="{Binding IsAppointment}" Style="{StaticResource Segment}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="&#xE787;" FontFamily="Segoe MDL2 Assets" FontSize="12" VerticalAlignment="Center" Margin="0,0,6,0"/>
<TextBlock Text="{Binding AppointmentText}"/>
</StackPanel>
</RadioButton>
<RadioButton GroupName="type" IsChecked="{Binding IsAnniversary}" Style="{StaticResource Segment}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="&#xED55;" FontFamily="Segoe MDL2 Assets" FontSize="12" VerticalAlignment="Center" Margin="0,0,6,0"/>
<TextBlock Text="{Binding BirthdayTypeText}"/>
</StackPanel>
</RadioButton>
</StackPanel>
</Border>
<TextBlock Text="{Binding NameLabel}" Style="{StaticResource Label}"/>
<TextBox x:Name="NameBox" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource Input}"/>
<TextBlock Text="{Binding ErrorMessage}" Foreground="#EF4444" FontSize="11" Margin="0,4,0,0"
Visibility="{Binding HasError, Converter={StaticResource BoolToVisibility}}"/>
<TextBlock Text="{Binding DateLabel}" Style="{StaticResource Label}" Margin="0,14,0,4"/>
<Grid>
<!-- Birthday: one date field, no time -->
<StackPanel Visibility="{Binding IsAnniversary, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{Binding CategoryLabel}" Style="{StaticResource Label}" Margin="0,14,0,4"/>
<ComboBox ItemsSource="{Binding Categories}" SelectedItem="{Binding SelectedCategory}" Height="34" VerticalContentAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Glyph}" FontFamily="Segoe MDL2 Assets" FontSize="13" VerticalAlignment="Center"
Foreground="{Binding Color, Converter={StaticResource HexToBrush}}"/>
<TextBlock Text="{Binding Name}" FontSize="13" Margin="8,0,0,0" VerticalAlignment="Center"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Text="{Binding BirthdayLabel}" Style="{StaticResource Label}" Margin="0,14,0,4"/>
<TextBox x:Name="BirthdayBox" Text="{Binding BirthdayText, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource Input}" FontSize="15"/>
<TextBlock Text="{Binding BirthdayPreview}" FontSize="12" Margin="0,6,0,0" TextWrapping="Wrap">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding BirthdayInvalid}" Value="True">
<Setter Property="Foreground" Value="#EF4444"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
<!-- Appointment: date, time, recurrence -->
<StackPanel Visibility="{Binding IsAppointment, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{Binding DateLabel}" Style="{StaticResource Label}" Margin="0,14,0,4"/> <Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
@@ -181,6 +229,19 @@
<TextBlock Text="{Binding NextOccurrenceLabel}" FontSize="11" Foreground="{DynamicResource TextSecondaryBrush}"/>
<TextBlock Text="{Binding NextOccurrenceText}" FontSize="11" FontWeight="SemiBold" Foreground="{DynamicResource TextPrimaryBrush}" Margin="4,0,0,0"/>
</StackPanel>
</StackPanel>
<!-- Lead reminder -->
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock Text="{Binding LeadLabel}" FontSize="12" Foreground="{DynamicResource TextPrimaryBrush}" VerticalAlignment="Center" Width="150"/>
<ComboBox Width="120" Height="28" VerticalContentAlignment="Center" SelectedIndex="{Binding SelectedLeadIndex}">
<ComboBoxItem Content="{Binding LeadNone}"/>
<ComboBoxItem Content="{Binding Lead1}"/>
<ComboBoxItem Content="{Binding Lead2}"/>
<ComboBoxItem Content="{Binding Lead3}"/>
<ComboBoxItem Content="{Binding Lead7}"/>
</ComboBox>
</StackPanel>
<TextBlock Text="{Binding DescriptionLabel}" Style="{StaticResource Label}" Margin="0,14,0,4"/>
<TextBox Text="{Binding Description, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource Input}"

View File

@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System.Windows;
using System.Windows.Input;
using ReminderOrganizer.Core;
@@ -14,13 +14,16 @@ namespace ReminderOrganizer
public ReminderTask TaskResult => _viewModel.TaskResult;
public TaskWindow(ReminderTask? existingTask, bool darkMode)
/// <param name="defaultCategory">Opens a new entry as anniversary of this category (null = appointment).</param>
public TaskWindow(ReminderTask? existingTask, bool darkMode,
System.Collections.Generic.IEnumerable<Category> categories, string? defaultCategory = null)
{
InitializeComponent();
DialogAnimation.Attach(this);
Theme.Apply(Resources, darkMode);
var localizationService = (ILocalizationService)ServiceLocator.Services.GetService(typeof(ILocalizationService))!;
_viewModel = new TaskViewModel(localizationService, existingTask);
_viewModel = new TaskViewModel(localizationService, existingTask, defaultCategory, categories);
_viewModel.RequestClose += OnRequestClose;
DataContext = _viewModel;

98
Tests/BirthdayTests.cs Normal file
View File

@@ -0,0 +1,98 @@
using System;
using ReminderOrganizer.Core;
using ReminderOrganizer.Models;
using ReminderOrganizer.Services;
using Xunit;
namespace ReminderOrganizer.Tests
{
public class BirthdayTests
{
private static readonly DateTime Today = new(2026, 11, 29);
[Theory]
[InlineData("19.03.", 19, 3, null)]
[InlineData("19.3", 19, 3, null)]
[InlineData("19.03.1986", 19, 3, 1986)]
[InlineData("19.3.86", 19, 3, 1986)]
[InlineData("1.1.05", 1, 1, 2005)]
[InlineData("1986-03-19", 19, 3, 1986)]
[InlineData(" 29.02. ", 29, 2, null)]
public void Parses_quick_input(string input, int day, int month, int? year)
{
Assert.True(BirthdayInput.TryParse(input, Today, out var d, out var m, out var y));
Assert.Equal((day, month, year), (d, m, y));
}
[Theory]
[InlineData("")]
[InlineData("32.01.")]
[InlineData("10.13.")]
[InlineData("29.02.2023")] // not a leap year
[InlineData("01.01.2030")] // future
[InlineData("abc")]
public void Rejects_bad_input(string input)
{
Assert.False(BirthdayInput.TryParse(input, Today, out _, out _, out _));
}
[Fact]
public void Next_birthday_this_year_or_next()
{
Assert.Equal(new DateTime(2026, 12, 14, 9, 0, 0), ReminderTask.NextBirthday(14, 12, Today));
Assert.Equal(new DateTime(2027, 3, 19, 9, 0, 0), ReminderTask.NextBirthday(19, 3, Today));
Assert.Equal(new DateTime(2026, 11, 29, 9, 0, 0), ReminderTask.NextBirthday(29, 11, Today)); // today counts
}
[Fact]
public void Leap_day_birthday_falls_back_to_28th()
{
Assert.Equal(new DateTime(2027, 2, 28, 9, 0, 0), ReminderTask.NextBirthday(29, 2, Today));
Assert.Equal(new DateTime(2028, 2, 29, 9, 0, 0), ReminderTask.NextBirthday(29, 2, new DateTime(2027, 3, 1)));
}
[Fact]
public void Migration_marks_yearly_tasks_in_birthday_folders_once()
{
var data = new AppData();
var bday = new Folder("Geburtstage");
bday.Tasks.Add(new ReminderTask("Oma", "", new DateTime(2027, 1, 27)) { IsRecurring = true, RecurrenceType = RecurrenceType.Yearly });
bday.Tasks.Add(new ReminderTask("Einmalig", "", new DateTime(2027, 1, 27)));
var work = new Folder("Arbeit");
work.Tasks.Add(new ReminderTask("Jahresbericht", "", new DateTime(2027, 1, 27)) { IsRecurring = true, RecurrenceType = RecurrenceType.Yearly });
data.Folders.Add(bday);
data.Folders.Add(work);
Assert.Equal(1, data.MigrateBirthdays());
Assert.True(bday.Tasks[0].IsAnniversary);
Assert.False(bday.Tasks[1].IsAnniversary);
Assert.False(work.Tasks[0].IsAnniversary);
Assert.Equal(0, data.MigrateBirthdays());
}
[Fact]
public void Birthday_display_has_no_time()
{
ReminderTask.DisplayCulture = () => new System.Globalization.CultureInfo("de-DE");
var t = new ReminderTask("x", "", new DateTime(2027, 3, 19, 9, 0, 0)) { IsAnniversary = true };
Assert.Equal("19. März", t.DisplayDate);
Assert.Equal("MÄR", t.MonthText);
t.IsAnniversary = false;
Assert.Equal("19.03.2027 09:00", t.DisplayDate);
}
[Fact]
public void Ics_birthday_is_all_day()
{
var data = new AppData();
var f = new Folder("Geburtstage");
f.Tasks.Add(new ReminderTask("Oma", "", new DateTime(2027, 1, 27, 9, 0, 0))
{ IsAnniversary = true, IsRecurring = true, RecurrenceType = RecurrenceType.Yearly, LeadDays = 1 });
data.Folders.Add(f);
var ics = IcsExport.Build(data, DateTime.UtcNow);
Assert.Contains("DTSTART;VALUE=DATE:20270127", ics);
Assert.DoesNotContain("DURATION", ics);
Assert.Contains("TRIGGER:-P0DT15H", ics); // 09:00 the day before
}
}
}

129
Tests/CategoryTests.cs Normal file
View File

@@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.Json;
using ReminderOrganizer.Core;
using ReminderOrganizer.Models;
using ReminderOrganizer.Services;
using Xunit;
namespace ReminderOrganizer.Tests
{
public class CategoryTests
{
private static readonly CultureInfo De = new("de-DE");
private static readonly CultureInfo En = new("en-US");
private static readonly Dictionary<string, string> DeStrings = LocalizationService.LoadStrings("de");
private static readonly Dictionary<string, string> EnStrings = LocalizationService.LoadStrings("en");
private static string LDe(string k) => DeStrings.TryGetValue(k, out var v) ? v : k;
private static string LEn(string k) => EnStrings.TryGetValue(k, out var v) ? v : k;
[Fact]
public void Wedding_text_with_traditional_name()
{
var wedding = Category.Defaults(LDe).Single(c => c.Id == Category.WeddingId);
Assert.Equal("25. Hochzeitstag · Silberhochzeit", wedding.FormatYears(25, De, LDe));
Assert.Equal("7. Hochzeitstag", wedding.FormatYears(7, De, LDe));
var weddingEn = Category.Defaults(LEn).Single(c => c.Id == Category.WeddingId);
Assert.Equal("50th anniversary · Golden", weddingEn.FormatYears(50, En, LEn));
}
[Theory]
[InlineData(1, "1st")]
[InlineData(2, "2nd")]
[InlineData(3, "3rd")]
[InlineData(11, "11th")]
[InlineData(12, "12th")]
[InlineData(22, "22nd")]
[InlineData(101, "101st")]
public void English_ordinals(int n, string expected) => Assert.Equal(expected, Category.Ordinal(n, En));
[Fact]
public void Other_presets_format()
{
var defs = Category.Defaults(LDe).ToDictionary(c => c.Id);
Assert.Equal("wird 40", defs[Category.BirthdayId].FormatYears(40, De, LDe));
Assert.Equal("15 Jahre", defs[Category.JubileeId].FormatYears(15, De, LDe));
Assert.Equal("vor 12 Jahren", defs[Category.MemorialId].FormatYears(12, De, LDe));
}
[Fact]
public void Defaults_are_added_once_and_keep_user_edits()
{
var data = new AppData();
Assert.True(data.EnsureDefaultCategories(LDe));
Assert.Equal(4, data.Categories.Count);
data.Categories[0].Name = "Geburtstage Familie";
data.Categories.Add(new Category { Name = "Hund" });
Assert.False(data.EnsureDefaultCategories(LDe));
Assert.Equal("Geburtstage Familie", data.Categories[0].Name);
Assert.Equal(5, data.Categories.Count);
}
[Fact]
public void Presets_follow_language_unless_renamed()
{
var data = new AppData();
data.EnsureDefaultCategories(LDe);
data.Categories.Single(c => c.Id == Category.JubileeId).Name = "Firma";
Category.RelocalizePresets(data.Categories, LEn, new[] { EnStrings, DeStrings });
Assert.Equal("Birthday", data.Categories.Single(c => c.Id == Category.BirthdayId).Name);
Assert.Equal("turns {0}", data.Categories.Single(c => c.Id == Category.BirthdayId).Format);
Assert.Equal("Firma", data.Categories.Single(c => c.Id == Category.JubileeId).Name);
}
[Fact]
public void Old_files_map_IsBirthday_to_anniversary()
{
var t = JsonSerializer.Deserialize<ReminderTask>("{\"Name\":\"Oma\",\"IsBirthday\":true}")!;
Assert.True(t.IsAnniversary);
Assert.Null(t.CategoryId);
Assert.Contains("\"IsBirthday\":true", JsonSerializer.Serialize(t));
}
[Fact]
public void Wedding_folders_are_migrated_to_wedding_category()
{
var data = new AppData { BirthdaysMigrated = true };
var f = new Folder("Hochzeitstage");
f.Tasks.Add(new ReminderTask("Anna & Tom", "", new DateTime(2027, 6, 1)) { IsRecurring = true, RecurrenceType = RecurrenceType.Yearly });
data.Folders.Add(f);
Assert.Equal(1, data.MigrateBirthdays());
Assert.True(f.Tasks[0].IsAnniversary);
Assert.Equal(Category.WeddingId, f.Tasks[0].CategoryId);
Assert.Equal(Category.WeddingId, AppData.CategoryHintForFolder("Hochzeiten"));
Assert.Equal(Category.BirthdayId, AppData.CategoryHintForFolder("Geburtstage"));
Assert.Null(AppData.CategoryHintForFolder("Arbeit"));
}
[Fact]
public void Category_filter()
{
var bday = new ReminderTask("a", "", DateTime.Now) { IsAnniversary = true }; // null id = birthday
var wedding = new ReminderTask("b", "", DateTime.Now) { IsAnniversary = true, CategoryId = Category.WeddingId };
var appt = new ReminderTask("c", "", DateTime.Now);
Assert.True(TaskQuery.MatchesCategory(bday, Category.BirthdayId));
Assert.False(TaskQuery.MatchesCategory(wedding, Category.BirthdayId));
Assert.True(TaskQuery.MatchesCategory(wedding, Category.WeddingId));
Assert.True(TaskQuery.MatchesCategory(appt, TaskQuery.AppointmentsFilter));
Assert.False(TaskQuery.MatchesCategory(bday, TaskQuery.AppointmentsFilter));
Assert.True(TaskQuery.MatchesCategory(appt, null));
}
[Fact]
public void Month_grouping_is_chronological()
{
var now = new DateTime(2026, 11, 29, 12, 0, 0);
var dec = new ReminderTask("dec", "", new DateTime(2026, 12, 14, 9, 0, 0));
var doneNov = new ReminderTask("doneNov", "", new DateTime(2026, 11, 2)) { IsNotified = true };
var jan = new ReminderTask("jan", "", new DateTime(2027, 1, 12, 9, 0, 0));
var list = new List<ReminderTask> { jan, dec, doneNov };
list.Sort((a, b) => new TaskQuery.Comparer(() => now, chronological: true).Compare(a, b));
Assert.Equal(new[] { "doneNov", "dec", "jan" }, list.Select(t => t.Name));
Assert.Equal(new DateTime(2026, 12, 1), TaskQuery.MonthKey(dec));
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -58,7 +58,7 @@ namespace ReminderOrganizer.Tests
var due = ReminderTask.ProcessDue(new[] { f }, now);
Assert.Equal(new[] { "once", "rec" }, due.Select(t => t.Name));
Assert.Equal(new[] { "once", "rec" }, due.Select(d => d.Task.Name));
Assert.True(once.IsNotified);
Assert.False(rec.IsNotified);
Assert.True(rec.ReminderDate > now);
@@ -234,3 +234,4 @@ namespace ReminderOrganizer.Tests
}
}
}

176
Tests/FeatureTests.cs Normal file
View File

@@ -0,0 +1,176 @@
using System;
using System.Linq;
using ReminderOrganizer.Core;
using ReminderOrganizer.Models;
using ReminderOrganizer.Services;
using Xunit;
namespace ReminderOrganizer.Tests
{
public class LeadReminderTests
{
private static Folder FolderWith(params ReminderTask[] tasks)
{
var f = new Folder("f");
foreach (var t in tasks) f.Tasks.Add(t);
return f;
}
[Fact]
public void Lead_reminder_fires_once_then_main_reminder()
{
var date = new DateTime(2026, 12, 24, 18, 0, 0);
var t = new ReminderTask("Xmas", "", date) { LeadDays = 2 };
var f = FolderWith(t);
Assert.Empty(ReminderTask.ProcessDue(new[] { f }, date.AddDays(-3)));
var lead = ReminderTask.ProcessDue(new[] { f }, date.AddDays(-2));
Assert.Single(lead);
Assert.True(lead[0].IsLead);
Assert.Empty(ReminderTask.ProcessDue(new[] { f }, date.AddDays(-1))); // not twice
var main = ReminderTask.ProcessDue(new[] { f }, date);
Assert.Single(main);
Assert.False(main[0].IsLead);
Assert.True(t.IsNotified);
}
[Fact]
public void Recurring_lead_resets_for_next_occurrence()
{
var date = new DateTime(2026, 3, 19, 9, 0, 0);
var t = new ReminderTask("Bday", "", date) { IsRecurring = true, RecurrenceType = RecurrenceType.Yearly, LeadDays = 1 };
var f = FolderWith(t);
ReminderTask.ProcessDue(new[] { f }, date.AddDays(-1)); // lead
ReminderTask.ProcessDue(new[] { f }, date); // main → next year
Assert.Equal(new DateTime(2027, 3, 19, 9, 0, 0), t.ReminderDate);
Assert.False(t.IsPreNotified);
Assert.Single(ReminderTask.ProcessDue(new[] { f }, new DateTime(2027, 3, 18, 9, 0, 0)));
}
[Fact]
public void Birthday_age_is_for_the_reminded_date()
{
var date = new DateTime(2026, 3, 19, 9, 0, 0);
var t = new ReminderTask("Michael", "", date) { IsRecurring = true, RecurrenceType = RecurrenceType.Yearly, BirthYear = 1986 };
Assert.Equal(40, t.UpcomingAge);
var due = ReminderTask.ProcessDue(new[] { FolderWith(t) }, date);
Assert.Equal(40, due[0].Age);
Assert.Equal(41, t.UpcomingAge); // already moved to 2027
}
[Fact]
public void Age_only_for_yearly_recurring()
{
var t = new ReminderTask("x", "", new DateTime(2026, 1, 1)) { BirthYear = 2000, IsRecurring = true, RecurrenceType = RecurrenceType.Monthly };
Assert.Null(t.UpcomingAge);
}
}
public class TaskQueryTests
{
private static readonly DateTime Now = new(2026, 11, 25, 12, 0, 0);
[Theory]
[InlineData(-1, TaskBucket.Overdue)]
[InlineData(2, TaskBucket.Today)]
[InlineData(24, TaskBucket.Tomorrow)]
[InlineData(24 * 5, TaskBucket.ThisWeek)]
[InlineData(24 * 10, TaskBucket.Later)]
public void Buckets_by_date(int hours, TaskBucket expected)
{
Assert.Equal(expected, TaskQuery.Bucket(new ReminderTask("x", "", Now.AddHours(hours)), Now));
}
[Fact]
public void Done_is_its_own_bucket()
{
Assert.Equal(TaskBucket.Done, TaskQuery.Bucket(new ReminderTask("x", "", Now.AddHours(-5)) { IsNotified = true }, Now));
}
[Fact]
public void Search_ignores_case_and_accents_and_matches_folder()
{
var t = new ReminderTask("Zahnärztin", "Kontrolle", Now) { FolderName = "Gesundheit" };
Assert.True(TaskQuery.Matches(t, "zahnarztin", TaskFilterMode.All, false, Now));
Assert.True(TaskQuery.Matches(t, "kontr", TaskFilterMode.All, false, Now));
Assert.True(TaskQuery.Matches(t, "gesund", TaskFilterMode.All, false, Now));
Assert.False(TaskQuery.Matches(t, "auto", TaskFilterMode.All, false, Now));
}
[Fact]
public void Filters_today_overdue_hide_done()
{
var today = new ReminderTask("a", "", Now.AddHours(3));
var overdue = new ReminderTask("b", "", Now.AddDays(-2));
var done = new ReminderTask("c", "", Now.AddDays(-2)) { IsNotified = true };
Assert.True(TaskQuery.Matches(today, "", TaskFilterMode.Today, false, Now));
Assert.False(TaskQuery.Matches(overdue, "", TaskFilterMode.Today, false, Now));
Assert.True(TaskQuery.Matches(overdue, "", TaskFilterMode.Overdue, false, Now));
Assert.False(TaskQuery.Matches(done, "", TaskFilterMode.Overdue, false, Now));
Assert.False(TaskQuery.Matches(done, "", TaskFilterMode.All, true, Now));
}
[Fact]
public void Sort_overdue_first_then_date_done_last()
{
var later = new ReminderTask("later", "", Now.AddDays(20));
var soon = new ReminderTask("soon", "", Now.AddHours(1));
var overdue = new ReminderTask("overdue", "", Now.AddDays(-1));
var done = new ReminderTask("done", "", Now.AddDays(-30)) { IsNotified = true };
var list = new[] { done, later, soon, overdue }.ToList();
list.Sort((a, b) => new TaskQuery.Comparer(() => Now).Compare(a, b));
Assert.Equal(new[] { "overdue", "soon", "later", "done" }, list.Select(t => t.Name));
}
}
public class IcsTests
{
[Fact]
public void Builds_events_with_rrule_alarm_and_escaping()
{
var data = new AppData();
var f = new Folder("Fam, Freunde");
f.Tasks.Add(new ReminderTask("Michael", "Geschenk; Karte", new DateTime(2027, 3, 19, 9, 0, 0))
{ IsRecurring = true, RecurrenceType = RecurrenceType.Yearly, LeadDays = 1, BirthYear = 1986 });
f.Tasks.Add(new ReminderTask("Done", "", new DateTime(2020, 1, 1)) { IsNotified = true });
data.Folders.Add(f);
var ics = IcsExport.Build(data, new DateTime(2026, 11, 25, 12, 0, 0, DateTimeKind.Utc));
Assert.StartsWith("BEGIN:VCALENDAR\r\n", ics);
Assert.EndsWith("END:VCALENDAR\r\n", ics);
Assert.Equal(1, ics.Split("BEGIN:VEVENT").Length - 1);
Assert.Contains("DTSTART:20270319T090000", ics);
Assert.Contains("RRULE:FREQ=YEARLY", ics);
Assert.Contains("TRIGGER:-P1D", ics);
Assert.Contains("SUMMARY:Michael (41)", ics);
Assert.Contains("DESCRIPTION:Geschenk\\; Karte", ics);
Assert.Contains("CATEGORIES:Fam\\, Freunde", ics);
}
[Fact]
public void Long_lines_are_folded()
{
var folded = IcsExport.Fold("DESCRIPTION:" + new string('ä', 80));
Assert.All(folded.Split("\r\n"), l => Assert.True(System.Text.Encoding.UTF8.GetByteCount(l) <= 75));
}
}
public class SettingsTests
{
[Fact]
public void Old_files_without_new_fields_still_load()
{
var json = "{\"Folders\":[{\"Name\":\"F\",\"Tasks\":[{\"Name\":\"T\",\"ReminderDate\":\"2027-01-01T10:00:00\"}]}],\"Language\":\"de\",\"IsDarkMode\":true}";
var data = System.Text.Json.JsonSerializer.Deserialize<AppData>(json)!;
Assert.Equal(Folder.DefaultColor, data.Folders[0].Color);
Assert.Equal(0, data.Folders[0].Tasks[0].LeadDays);
Assert.True(data.PlaySound);
}
}
}

159
Tests/ImportSnoozeTests.cs Normal file
View File

@@ -0,0 +1,159 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ReminderOrganizer.Core;
using ReminderOrganizer.Models;
using ReminderOrganizer.Services;
using Xunit;
namespace ReminderOrganizer.Tests
{
public class SnoozeTests
{
private static readonly DateTime Now = new(2026, 11, 29, 10, 0, 0);
[Fact]
public void One_off_task_moves_its_date()
{
var t = new ReminderTask("Call", "", Now.AddMinutes(-1)) { IsNotified = true };
t.Snooze(Now.AddMinutes(10));
Assert.False(t.IsNotified);
Assert.Equal(Now.AddMinutes(10), t.ReminderDate);
Assert.Null(t.SnoozedUntil);
}
[Fact]
public void Recurring_task_keeps_date_and_fires_once_more()
{
var next = new DateTime(2027, 11, 29, 9, 0, 0);
var t = new ReminderTask("Oma", "", next) { IsRecurring = true, RecurrenceType = RecurrenceType.Yearly, IsAnniversary = true };
var f = new Folder("f");
f.Tasks.Add(t);
t.Snooze(Now.AddHours(1));
Assert.Equal(next, t.ReminderDate);
Assert.Empty(ReminderTask.ProcessDue(new[] { f }, Now.AddMinutes(30)));
var due = ReminderTask.ProcessDue(new[] { f }, Now.AddHours(1));
Assert.Single(due);
Assert.Null(t.SnoozedUntil);
Assert.Equal(next, t.ReminderDate);
Assert.Empty(ReminderTask.ProcessDue(new[] { f }, Now.AddHours(2)));
}
}
public class DailySummaryTests
{
private static readonly DateTime Now = new(2026, 11, 29, 8, 0, 0);
[Fact]
public void Collects_today_overdue_and_upcoming_anniversaries()
{
var tasks = new[]
{
new ReminderTask("Dentist", "", Now.Date.AddHours(10)),
new ReminderTask("Tax", "", Now.AddDays(-2)),
new ReminderTask("Done", "", Now.AddDays(-2)) { IsNotified = true },
new ReminderTask("Oma", "", Now.Date.AddDays(1).AddHours(9)) { IsAnniversary = true, IsRecurring = true },
new ReminderTask("Later", "", Now.Date.AddDays(10).AddHours(9)) { IsAnniversary = true, IsRecurring = true },
};
var s = DailySummary.Build(tasks, Now)!;
Assert.Equal(new[] { "Dentist" }, s.Today.Select(t => t.Name));
Assert.Equal(new[] { "Tax" }, s.Overdue.Select(t => t.Name));
Assert.Equal(new[] { "Oma" }, s.AnniversariesSoon.Select(t => t.Name));
}
[Fact]
public void Nothing_to_say_is_null()
{
Assert.Null(DailySummary.Build(new[] { new ReminderTask("x", "", Now.AddDays(20)) }, Now));
}
[Fact]
public void Once_per_day_from_the_hour()
{
Assert.False(DailySummary.IsDue(Now.Date.AddHours(7), 8, null));
Assert.True(DailySummary.IsDue(Now.Date.AddHours(8), 8, null));
Assert.False(DailySummary.IsDue(Now.Date.AddHours(9), 8, Now.Date.AddHours(8)));
Assert.True(DailySummary.IsDue(Now.Date.AddDays(1).AddHours(9), 8, Now.Date.AddHours(8)));
}
}
public class IcsImportTests
{
private static readonly DateTime Now = new(2026, 11, 29, 10, 0, 0);
[Fact]
public void Round_trip_with_own_export()
{
var data = new AppData();
var f = new Folder("F");
f.Tasks.Add(new ReminderTask("Oma", "Kuchen; Blumen", new DateTime(2027, 1, 27, 9, 0, 0))
{ IsAnniversary = true, IsRecurring = true, RecurrenceType = RecurrenceType.Yearly, BirthYear = 1941, LeadDays = 1 });
f.Tasks.Add(new ReminderTask("Team", "", new DateTime(2026, 12, 7, 9, 30, 0))
{ IsRecurring = true, RecurrenceType = RecurrenceType.Weekly, LeadDays = 2 });
data.Folders.Add(f);
var ics = IcsExport.Build(data, DateTime.UtcNow);
var r = IcsImport.Parse(ics, new HashSet<string>(), Now);
Assert.Equal(0, r.Skipped);
var oma = r.Tasks.Single(t => t.Name == "Oma");
Assert.True(oma.IsAnniversary);
Assert.Equal(1941, oma.BirthYear);
Assert.Equal(1, oma.LeadDays);
Assert.Equal("Kuchen; Blumen", oma.Description);
Assert.Equal(new DateTime(2027, 1, 27, 9, 0, 0), oma.ReminderDate);
var team = r.Tasks.Single(t => t.Name == "Team");
Assert.Equal(RecurrenceType.Weekly, team.RecurrenceType);
Assert.Equal(new DateTime(2026, 12, 7, 9, 30, 0), team.ReminderDate);
Assert.Equal(2, team.LeadDays);
// importing the same file again changes nothing
var ids = new HashSet<string>(r.Tasks.Select(t => t.Id));
var again = IcsImport.Parse(ics, ids, Now);
Assert.Empty(again.Tasks);
Assert.Equal(2, again.Skipped);
}
[Fact]
public void Google_birthday_calendar()
{
var ics = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:19860319\r\nRRULE:FREQ=YEARLY\r\n" +
"SUMMARY:Michael's birthday\r\nUID:abc@google.com\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
var t = IcsImport.Parse(ics, new HashSet<string>(), Now).Tasks.Single();
Assert.Equal("Michael", t.Name);
Assert.True(t.IsAnniversary);
Assert.Equal(Category.BirthdayId, t.CategoryId);
Assert.Equal(1986, t.BirthYear);
Assert.Equal(new DateTime(2027, 3, 19, 9, 0, 0), t.ReminderDate);
}
[Fact]
public void Wedding_folded_lines_utc_and_past_events()
{
var ics = string.Join("\r\n",
"BEGIN:VCALENDAR",
"BEGIN:VEVENT", "DTSTART;VALUE=DATE:20010812", "RRULE:FREQ=YEARLY", "SUMMARY:Hochzeitstag Lea + Max", "END:VEVENT",
"BEGIN:VEVENT", "DTSTART:20261215T130000Z", "SUMMARY:Arzt mit einem sehr langen", " Namen", "END:VEVENT",
"BEGIN:VEVENT", "DTSTART:20200101T100000", "SUMMARY:Alt", "END:VEVENT",
"END:VCALENDAR", "");
var r = IcsImport.Parse(ics, new HashSet<string>(), Now);
Assert.Equal(1, r.Skipped);
Assert.Equal(Category.WeddingId, r.Tasks[0].CategoryId);
Assert.Equal(2001, r.Tasks[0].BirthYear);
// RFC 5545: the continuation's single leading space is removed
Assert.Equal("Arzt mit einem sehr langenNamen", r.Tasks[1].Name);
Assert.Equal(DateTimeKind.Unspecified, r.Tasks[1].ReminderDate.Kind);
Assert.Equal(new DateTime(2026, 12, 15, 13, 0, 0, DateTimeKind.Utc).ToLocalTime().Hour, r.Tasks[1].ReminderDate.Hour);
}
[Theory]
[InlineData("-P1D", false, 1)]
[InlineData("-PT15H", true, 1)]
[InlineData("-PT15H", false, 0)]
[InlineData("-P1W", false, 7)]
[InlineData("PT9H", true, 0)]
public void Lead_days(string trigger, bool allDay, int expected) =>
Assert.Equal(expected, IcsImport.LeadDaysFrom(trigger, allDay));
}
}

66
Tests/SyncTests.cs Normal file
View File

@@ -0,0 +1,66 @@
using System;
using System.IO;
using System.Threading.Tasks;
using ReminderOrganizer.Models;
using ReminderOrganizer.Services;
using Xunit;
namespace ReminderOrganizer.Tests
{
public class SyncTests : IDisposable
{
private readonly string _root = Path.Combine(Path.GetTempPath(), "ro-sync-" + Guid.NewGuid().ToString("N"));
public void Dispose()
{
try { Directory.Delete(_root, true); } catch { }
}
[Fact]
public void Pointer_file_round_trip()
{
var app = Path.Combine(_root, "app");
var cloud = Path.Combine(_root, "OneDrive", "Reminders");
Directory.CreateDirectory(cloud);
Assert.Null(DataService.ReadPointer(app));
DataService.WritePointer(app, cloud);
Assert.Equal(cloud, DataService.ReadPointer(app));
DataService.WritePointer(app, app); // back to the app folder = no pointer
Assert.Null(DataService.ReadPointer(app));
}
[Fact]
public void Pointer_to_missing_folder_is_ignored()
{
var app = Path.Combine(_root, "app");
DataService.WritePointer(app, Path.Combine(_root, "gone"));
Directory.CreateDirectory(Path.Combine(_root, "gone"));
Directory.Delete(Path.Combine(_root, "gone"));
Assert.Null(DataService.ReadPointer(app));
}
[Fact]
public async Task Own_writes_are_not_external_but_other_writes_are()
{
var ds = new DataService(Path.Combine(_root, "data"));
await ds.SaveAsync(new AppData());
Assert.False(ds.IsExternalChange());
await Task.Delay(30);
File.WriteAllText(ds.DataFilePath, "{\"Folders\":[]}"); // "another PC"
File.SetLastWriteTimeUtc(ds.DataFilePath, DateTime.UtcNow.AddSeconds(2));
Assert.True(ds.IsExternalChange());
Assert.False(ds.IsExternalChange()); // reported once
}
[Fact]
public void Switching_folder_uses_new_file()
{
var ds = new DataService(Path.Combine(_root, "a"));
ds.SwitchTo(Path.Combine(_root, "b"));
Assert.Equal(Path.Combine(_root, "b", "tasks.json"), ds.DataFilePath);
}
}
}

866
Themes/Controls.xaml Normal file
View File

@@ -0,0 +1,866 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--
Shared control styles. Colors are DynamicResources set by Core/Theme.cs on Application.Resources,
so everything (also context menus, tooltips, dialogs) follows light/dark.
Design rules: neutral greys, one accent, 4/8 px spacing, 6–10 px radii, no glow, no scaling on hover.
-->
<FontFamily x:Key="UiFont">Segoe UI Variable Text, Segoe UI</FontFamily>
<FontFamily x:Key="IconFont">Segoe Fluent Icons, Segoe MDL2 Assets</FontFamily>
<!-- defaults until Theme.Apply runs (dark) -->
<SolidColorBrush x:Key="PrimaryBrush" Color="#5B5BD6"/>
<SolidColorBrush x:Key="PrimaryHoverBrush" Color="#4C4CC4"/>
<SolidColorBrush x:Key="DangerBrush" Color="#F0706A"/>
<SolidColorBrush x:Key="WarningBrush" Color="#E5A00D"/>
<SolidColorBrush x:Key="SuccessBrush" Color="#3DD68C"/>
<SolidColorBrush x:Key="SecondaryBrush" Color="#3DD68C"/>
<SolidColorBrush x:Key="BackgroundBrush" Color="#16161A"/>
<SolidColorBrush x:Key="SidebarBrush" Color="#1C1C21"/>
<SolidColorBrush x:Key="HeaderBrush" Color="#1C1C21"/>
<SolidColorBrush x:Key="CardBrush" Color="#202026"/>
<SolidColorBrush x:Key="MenuBackgroundBrush" Color="#26262D"/>
<SolidColorBrush x:Key="InputBackgroundBrush" Color="#1A1A1F"/>
<SolidColorBrush x:Key="BorderBrush" Color="#2E2E36"/>
<SolidColorBrush x:Key="DividerBrush" Color="#2A2A31"/>
<SolidColorBrush x:Key="HoverBrush" Color="#2A2A31"/>
<SolidColorBrush x:Key="SelectedBrush" Color="#2B2B45"/>
<SolidColorBrush x:Key="TextPrimaryBrush" Color="#EDEDF2"/>
<SolidColorBrush x:Key="TextSecondaryBrush" Color="#9C9CA8"/>
<SolidColorBrush x:Key="TextTertiaryBrush" Color="#6E6E7A"/>
<SolidColorBrush x:Key="SidebarTextBrush" Color="#DCDCE4"/>
<SolidColorBrush x:Key="SidebarSecondaryBrush" Color="#80808C"/>
<SolidColorBrush x:Key="AccentSubtleBrush" Color="#2D2D4C"/>
<SolidColorBrush x:Key="AccentTextBrush" Color="#B9BAFF"/>
<SolidColorBrush x:Key="PrimaryLightBrush" Color="#2D2D4C"/>
<SolidColorBrush x:Key="BadgeBrush" Color="#2D2D4C"/>
<SolidColorBrush x:Key="BadgeTextBrush" Color="#B9BAFF"/>
<SolidColorBrush x:Key="SnackbarBrush" Color="#33333C"/>
<Geometry x:Key="FolderGeometry">M1.5,3.5 L6,3.5 L7.5,5 L14.5,5 L14.5,13.5 L1.5,13.5 Z</Geometry>
<!-- ========== scrolling ========== -->
<Style TargetType="ScrollBar">
<Setter Property="Width" Value="10"/>
<Setter Property="MinWidth" Value="10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollBar">
<Grid Background="Transparent">
<Track x:Name="PART_Track" IsDirectionReversed="True">
<Track.Thumb>
<Thumb>
<Thumb.Template>
<ControlTemplate TargetType="Thumb">
<Border x:Name="t" Background="{DynamicResource TextTertiaryBrush}" Opacity="0.45"
CornerRadius="3" Width="6" Margin="0,2"/>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="t" Property="Opacity" Value="0.8"/>
</Trigger>
<Trigger Property="IsDragging" Value="True">
<Setter TargetName="t" Property="Opacity" Value="0.9"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Thumb.Template>
</Thumb>
</Track.Thumb>
</Track>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Width" Value="Auto"/>
<Setter Property="Height" Value="10"/>
</Trigger>
</Style.Triggers>
</Style>
<!-- ========== tooltip ========== -->
<Style TargetType="ToolTip">
<Setter Property="Background" Value="{DynamicResource MenuBackgroundBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToolTip">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"
CornerRadius="6" Padding="8,5" Margin="4" SnapsToDevicePixels="True">
<Border.Effect>
<DropShadowEffect BlurRadius="8" ShadowDepth="1" Opacity="0.18" Color="Black"/>
</Border.Effect>
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ========== menus (top menu + context menus) ========== -->
<Style TargetType="Menu">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
</Style>
<Style TargetType="ContextMenu">
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContextMenu">
<Border Background="{DynamicResource MenuBackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
CornerRadius="8" Padding="4" Margin="6">
<Border.Effect>
<DropShadowEffect BlurRadius="14" ShadowDepth="3" Opacity="0.22" Color="Black"/>
</Border.Effect>
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Separator">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Separator">
<Border Height="1" Margin="6,4" Background="{DynamicResource DividerBrush}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="Separator">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Separator">
<Border Height="1" Margin="6,4" Background="{DynamicResource DividerBrush}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="MenuItem">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Padding" Value="10,6"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="MenuItem">
<Border x:Name="Bd" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" CornerRadius="5" MinWidth="40">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="IconCol" Width="26"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ContentPresenter x:Name="Icon" ContentSource="Icon" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock x:Name="Check" Text="&#xE73E;" FontFamily="{StaticResource IconFont}" FontSize="12" VerticalAlignment="Center"
Foreground="{DynamicResource PrimaryBrush}" Visibility="Collapsed"/>
<ContentPresenter Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" VerticalAlignment="Center"/>
<TextBlock Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="24,0,0,0" FontSize="12"
Foreground="{DynamicResource TextTertiaryBrush}" VerticalAlignment="Center"/>
<TextBlock x:Name="Arrow" Grid.Column="3" Text="&#xE76C;" FontFamily="{StaticResource IconFont}" FontSize="9"
Margin="12,0,0,0" VerticalAlignment="Center" Foreground="{DynamicResource TextSecondaryBrush}" Visibility="Collapsed"/>
<Popup x:Name="PART_Popup" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Right" HorizontalOffset="-2" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
<Border Background="{DynamicResource MenuBackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
CornerRadius="8" Padding="4" Margin="6" MinWidth="180">
<Border.Effect>
<DropShadowEffect BlurRadius="14" ShadowDepth="3" Opacity="0.22" Color="Black"/>
</Border.Effect>
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
</Border>
</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Role" Value="TopLevelHeader">
<Setter TargetName="PART_Popup" Property="Placement" Value="Bottom"/>
<Setter TargetName="PART_Popup" Property="HorizontalOffset" Value="-6"/>
<Setter TargetName="IconCol" Property="Width" Value="0"/>
<Setter Property="Padding" Value="10,5"/>
</Trigger>
<Trigger Property="Role" Value="SubmenuHeader">
<Setter TargetName="Arrow" Property="Visibility" Value="Visible"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Check" Property="Visibility" Value="Visible"/>
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
</Trigger>
<Trigger Property="IsSubmenuOpen" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextTertiaryBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ========== buttons ========== -->
<Style x:Key="PrimaryButton" TargetType="Button">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Padding" Value="14,7"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="Bd" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource PrimaryHoverBrush}"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="Bd" Property="Opacity" Value="0.85"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Bd" Property="Opacity" Value="0.4"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SubtleButton" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Padding" Value="14,7"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"
CornerRadius="6" Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Bd" Property="Opacity" Value="0.4"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- small square icon button (glyph as Content) -->
<Style x:Key="IconButton" TargetType="Button">
<Setter Property="FontFamily" Value="{StaticResource IconFont}"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Width" Value="28"/>
<Setter Property="Height" Value="28"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="Bd" Background="{TemplateBinding Background}" CornerRadius="6">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Bd" Property="Opacity" Value="0.35"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- window caption buttons (46 px wide like Windows) -->
<Style x:Key="CaptionButton" TargetType="Button">
<Setter Property="FontFamily" Value="{StaticResource IconFont}"/>
<Setter Property="FontSize" Value="10"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="Width" Value="46"/>
<Setter Property="Height" Value="40"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="Bd" Background="Transparent">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="CloseCaptionButton" TargetType="Button" BasedOn="{StaticResource CaptionButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="Bd" Background="Transparent">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="#C42B1C"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ========== segmented control (radio buttons in a shared container) ========== -->
<Style x:Key="Segment" TargetType="RadioButton">
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="12.5"/>
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}"/>
<Setter Property="Padding" Value="12,4"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border x:Name="Bd" CornerRadius="5" Padding="{TemplateBinding Padding}" Background="Transparent" MinHeight="26">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource CardBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter TargetName="Bd" Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="4" ShadowDepth="1" Opacity="0.15" Color="Black"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="IconSegment" TargetType="RadioButton" BasedOn="{StaticResource Segment}">
<Setter Property="FontFamily" Value="{StaticResource IconFont}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Padding" Value="8,4"/>
</Style>
<Style x:Key="SegmentHost" TargetType="Border">
<Setter Property="Background" Value="{DynamicResource HoverBrush}"/>
<Setter Property="CornerRadius" Value="7"/>
<Setter Property="Padding" Value="2"/>
</Style>
<!-- toggle button with icon, same look as a segment (used for "group by month") -->
<Style x:Key="IconToggle" TargetType="ToggleButton">
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="FontFamily" Value="{StaticResource IconFont}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Border x:Name="Bd" CornerRadius="5" Padding="8,4" Background="Transparent" MinHeight="26">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource CardBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}"/>
<Setter TargetName="Bd" Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="4" ShadowDepth="1" Opacity="0.15" Color="Black"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ========== toggle switch ========== -->
<Style x:Key="ToggleSwitch" TargetType="CheckBox">
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="12.5"/>
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<StackPanel Orientation="Horizontal" Background="Transparent">
<Border x:Name="Track" Width="32" Height="18" CornerRadius="9" BorderThickness="1"
BorderBrush="{DynamicResource TextTertiaryBrush}" Background="Transparent">
<Ellipse x:Name="Knob" Width="10" Height="10" Fill="{DynamicResource TextSecondaryBrush}"
HorizontalAlignment="Left" Margin="3,0">
<Ellipse.RenderTransform>
<TranslateTransform x:Name="KnobX" X="0"/>
</Ellipse.RenderTransform>
</Ellipse>
</Border>
<ContentPresenter Margin="8,0,0,0" VerticalAlignment="Center"/>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Track" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
<Setter TargetName="Track" Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
<Setter TargetName="Knob" Property="Fill" Value="White"/>
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="KnobX" Storyboard.TargetProperty="X" To="14" Duration="0:0:0.12">
<DoubleAnimation.EasingFunction><CubicEase EasingMode="EaseOut"/></DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="KnobX" Storyboard.TargetProperty="X" To="0" Duration="0:0:0.12">
<DoubleAnimation.EasingFunction><CubicEase EasingMode="EaseOut"/></DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ========== round "done" check (To-Do style) ========== -->
<Style x:Key="DoneCheck" TargetType="CheckBox">
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Grid Background="Transparent" Width="22" Height="22">
<Ellipse x:Name="Ring" Width="18" Height="18" StrokeThickness="1.5" Stroke="{DynamicResource TextTertiaryBrush}" Fill="Transparent"/>
<TextBlock x:Name="Mark" Text="&#xE73E;" FontFamily="{StaticResource IconFont}" FontSize="10"
HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource TextSecondaryBrush}" Opacity="0"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Ring" Property="Stroke" Value="{DynamicResource SuccessBrush}"/>
<Setter TargetName="Mark" Property="Opacity" Value="0.7"/>
<Setter TargetName="Mark" Property="Foreground" Value="{DynamicResource SuccessBrush}"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Ring" Property="Fill" Value="{DynamicResource SuccessBrush}"/>
<Setter TargetName="Ring" Property="Stroke" Value="{DynamicResource SuccessBrush}"/>
<Setter TargetName="Mark" Property="Opacity" Value="1"/>
<Setter TargetName="Mark" Property="Foreground" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- row action icon (edit/delete), hidden until the row is hovered or selected -->
<Style x:Key="RowIcon" TargetType="Button" BasedOn="{StaticResource IconButton}">
<Setter Property="Width" Value="26"/>
<Setter Property="Height" Value="26"/>
<Setter Property="CommandParameter" Value="{Binding}"/>
</Style>
<!-- ========== text inputs ========== -->
<Style x:Key="SearchBox" TargetType="TextBox">
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="CaretBrush" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
<!-- ========== combo box (all dialogs) ========== -->
<Style TargetType="ComboBoxItem">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Padding" Value="10,6"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Border x:Name="Bd" Background="Transparent" CornerRadius="5" Padding="{TemplateBinding Padding}" Margin="0,1">
<ContentPresenter VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource AccentSubtleBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="ComboBox">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="Background" Value="{DynamicResource InputBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="MinHeight" Value="32"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<ToggleButton x:Name="Toggle" Focusable="False" ClickMode="Press"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
<ToggleButton.Template>
<ControlTemplate TargetType="ToggleButton">
<Border x:Name="Bd" CornerRadius="6" BorderThickness="1"
Background="{Binding Background, RelativeSource={RelativeSource AncestorType=ComboBox}}"
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType=ComboBox}}">
<TextBlock Text="&#xE70D;" FontFamily="{StaticResource IconFont}" FontSize="10" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,0,10,0" Foreground="{DynamicResource TextSecondaryBrush}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource TextTertiaryBrush}"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
<ContentPresenter Margin="11,0,30,0" VerticalAlignment="Center" HorizontalAlignment="Left" IsHitTestVisible="False"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"/>
<Popup x:Name="PART_Popup" IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" AllowsTransparency="True"
Focusable="False" PopupAnimation="Fade" VerticalOffset="2">
<Border Background="{DynamicResource MenuBackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
CornerRadius="8" Padding="4" Margin="6,0,6,8"
MinWidth="{Binding ActualWidth, RelativeSource={RelativeSource TemplatedParent}}" MaxHeight="320">
<Border.Effect>
<DropShadowEffect BlurRadius="14" ShadowDepth="3" Opacity="0.22" Color="Black"/>
</Border.Effect>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>
</ScrollViewer>
</Border>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.45"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ========== calendar (popup of the date picker) ========== -->
<Style x:Key="CalendarNavButton" TargetType="Button" BasedOn="{StaticResource IconButton}">
<Setter Property="FontSize" Value="10"/>
<Setter Property="Width" Value="28"/>
<Setter Property="Height" Value="28"/>
</Style>
<Style x:Key="CalendarHeaderButton" TargetType="Button">
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="Bd" Background="Transparent" CornerRadius="6" Padding="10,4">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="AppCalendarDayButton" TargetType="CalendarDayButton">
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="12.5"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CalendarDayButton">
<Border x:Name="Bd" Width="32" Height="30" Margin="1" CornerRadius="6" BorderThickness="1"
Background="Transparent" BorderBrush="Transparent">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsInactive" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextTertiaryBrush}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
</Trigger>
<Trigger Property="IsToday" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
<Trigger Property="IsBlackedOut" Value="True">
<Setter Property="Opacity" Value="0.35"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="AppCalendarButton" TargetType="CalendarButton">
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="FontSize" Value="12.5"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CalendarButton">
<Border x:Name="Bd" Width="52" Height="44" Margin="2" CornerRadius="6" Background="Transparent">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsInactive" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextTertiaryBrush}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
</Trigger>
<Trigger Property="HasSelectedDays" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource AccentSubtleBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="AppCalendarItem" TargetType="CalendarItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CalendarItem">
<ControlTemplate.Resources>
<DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
<TextBlock Text="{Binding}" FontFamily="{StaticResource UiFont}" FontSize="11" FontWeight="SemiBold"
HorizontalAlignment="Center" Margin="0,2,0,6" Foreground="{DynamicResource TextTertiaryBrush}"/>
</DataTemplate>
</ControlTemplate.Resources>
<Grid x:Name="PART_Root">
<Border Background="{DynamicResource MenuBackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
CornerRadius="8" Padding="10" Margin="6,2,6,10">
<Border.Effect>
<DropShadowEffect BlurRadius="14" ShadowDepth="3" Opacity="0.22" Color="Black"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Margin="0,0,0,6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button x:Name="PART_PreviousButton" Content="&#xE76B;" Style="{StaticResource CalendarNavButton}" Focusable="False"/>
<Button x:Name="PART_HeaderButton" Grid.Column="1" Style="{StaticResource CalendarHeaderButton}" Focusable="False"/>
<Button x:Name="PART_NextButton" Grid.Column="2" Content="&#xE76C;" Style="{StaticResource CalendarNavButton}" Focusable="False"/>
</Grid>
<Grid x:Name="PART_MonthView" Grid.Row="1" Visibility="Visible">
<Grid.RowDefinitions>
<RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/><ColumnDefinition/><ColumnDefinition/><ColumnDefinition/><ColumnDefinition/><ColumnDefinition/><ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
<Grid x:Name="PART_YearView" Grid.Row="1" Visibility="Hidden">
<Grid.RowDefinitions>
<RowDefinition/><RowDefinition/><RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/><ColumnDefinition/><ColumnDefinition/><ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
</Grid>
</Border>
<Rectangle x:Name="PART_DisabledVisual" Fill="Transparent" Visibility="Collapsed"/>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource AncestorType=Calendar}}" Value="Year">
<Setter TargetName="PART_MonthView" Property="Visibility" Value="Hidden"/>
<Setter TargetName="PART_YearView" Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource AncestorType=Calendar}}" Value="Decade">
<Setter TargetName="PART_MonthView" Property="Visibility" Value="Hidden"/>
<Setter TargetName="PART_YearView" Property="Visibility" Value="Visible"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="AppCalendar" TargetType="Calendar">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="CalendarItemStyle" Value="{StaticResource AppCalendarItem}"/>
<Setter Property="CalendarDayButtonStyle" Value="{StaticResource AppCalendarDayButton}"/>
<Setter Property="CalendarButtonStyle" Value="{StaticResource AppCalendarButton}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Calendar">
<StackPanel x:Name="PART_Root" HorizontalAlignment="Center">
<CalendarItem x:Name="PART_CalendarItem" Style="{TemplateBinding CalendarItemStyle}"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ========== date picker (text field + calendar button) ========== -->
<Style TargetType="DatePickerTextBox">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="CaretBrush" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DatePickerTextBox">
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" Margin="10,0,0,0"
HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Calendar" BasedOn="{StaticResource AppCalendar}"/>
<Style TargetType="DatePicker">
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="CalendarStyle" Value="{StaticResource AppCalendar}"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="MinHeight" Value="32"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DatePicker">
<Border x:Name="Bd" CornerRadius="6" BorderThickness="1"
Background="{DynamicResource InputBackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}">
<Grid x:Name="PART_Root">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<DatePickerTextBox x:Name="PART_TextBox" Grid.Column="0"/>
<Button x:Name="PART_Button" Grid.Column="1" Content="&#xE787;" Style="{StaticResource IconButton}"
Width="28" Height="26" Margin="0,0,3,0" Focusable="False"/>
<Popup x:Name="PART_Popup" PlacementTarget="{Binding ElementName=PART_TextBox}" Placement="Bottom"
StaysOpen="False" AllowsTransparency="True"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource TextTertiaryBrush}"/>
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ========== check box (default look) ========== -->
<Style TargetType="CheckBox">
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
<Setter Property="FontFamily" Value="{StaticResource UiFont}"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<StackPanel Orientation="Horizontal" Background="Transparent">
<Border x:Name="Box" Width="18" Height="18" CornerRadius="4" BorderThickness="1.5" VerticalAlignment="Center"
BorderBrush="{DynamicResource TextTertiaryBrush}" Background="Transparent">
<TextBlock x:Name="Mark" Text="&#xE73E;" FontFamily="{StaticResource IconFont}" FontSize="11" Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed"/>
</Border>
<ContentPresenter Margin="8,0,0,0" VerticalAlignment="Center"/>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Box" Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Box" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
<Setter TargetName="Box" Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
<Setter TargetName="Mark" Property="Visibility" Value="Visible"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SectionLabel" TargetType="TextBlock">
<Setter Property="FontSize" Value="11"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Foreground" Value="{DynamicResource SidebarSecondaryBrush}"/>
</Style>
</ResourceDictionary>

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,7 @@
#nullable enable
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using ReminderOrganizer.Core;
using ReminderOrganizer.Models;
@@ -69,7 +71,35 @@ namespace ReminderOrganizer.ViewModels
}
}
public bool IsInPast => !IsRecurring && ReminderDate <= DateTime.Now;
public bool IsInPast => !IsAnniversary && !IsRecurring && ReminderDate <= DateTime.Now;
// lead reminder: index into LeadOptions
public static readonly int[] LeadOptions = { 0, 1, 2, 3, 7 };
private int _selectedLeadIndex;
public int SelectedLeadIndex
{
get => _selectedLeadIndex;
set => SetProperty(ref _selectedLeadIndex, Math.Clamp(value, 0, LeadOptions.Length - 1));
}
public string LeadLabel => _localizationService.GetString("LeadReminder");
public string LeadNone => _localizationService.GetString("LeadNone");
public string Lead1 => _localizationService.GetString("LeadOneDay");
public string Lead2 => string.Format(_localizationService.GetString("LeadDays"), 2);
public string Lead3 => string.Format(_localizationService.GetString("LeadDays"), 3);
public string Lead7 => _localizationService.GetString("LeadWeek");
// birthday
private string _birthYearText = "";
public string BirthYearText
{
get => _birthYearText;
set { if (SetProperty(ref _birthYearText, value ?? "")) OnPropertyChanged(nameof(BirthYearError)); }
}
public int? ParsedBirthYear =>
int.TryParse(BirthYearText.Trim(), out var y) && y >= 1900 && y <= DateTime.Now.Year ? y : null;
public bool BirthYearError => BirthYearText.Trim().Length > 0 && ParsedBirthYear == null;
public bool IsYearly => IsRecurring && SelectedRecurrenceIndex == (int)RecurrenceType.Yearly;
public string BirthYearLabel => _localizationService.GetString("BirthYear");
public string PastDateWarning => _localizationService.GetString("PastDateWarning");
public string NextOccurrenceLabel => _localizationService.GetString("NextOccurrence");
public string QuickLabel => _localizationService.GetString("Quick");
@@ -121,6 +151,7 @@ namespace ReminderOrganizer.ViewModels
{
// Only copied to the task in Save() – Cancel must not change anything.
SetProperty(ref _isRecurring, value);
OnPropertyChanged(nameof(IsYearly));
OnPropertyChanged(nameof(NextOccurrenceText));
OnPropertyChanged(nameof(IsInPast));
}
@@ -133,6 +164,7 @@ namespace ReminderOrganizer.ViewModels
{
if (value < 0) return;
SetProperty(ref _selectedRecurrenceIndex, value);
OnPropertyChanged(nameof(IsYearly));
OnPropertyChanged(nameof(IsDailySelected));
OnPropertyChanged(nameof(IsWeeklySelected));
OnPropertyChanged(nameof(IsMonthlySelected));
@@ -181,9 +213,10 @@ namespace ReminderOrganizer.ViewModels
}
}
public string WindowTitle => _isNewTask
? _localizationService.GetString("NewTask")
: _localizationService.GetString("EditTask");
/// <summary>"New birthday", "Edit wedding anniversary", "New task" …</summary>
public string WindowTitle => IsAnniversary && SelectedCategory != null
? string.Format(_localizationService.GetString(_isNewTask ? "NewAnniversaryOf" : "EditAnniversaryOf"), SelectedCategory.Name)
: _localizationService.GetString(_isNewTask ? "NewTask" : "EditTask");
public string NameLabel => _localizationService.GetString("Name");
public string DescriptionLabel => _localizationService.GetString("Description");
@@ -206,15 +239,115 @@ namespace ReminderOrganizer.ViewModels
public event EventHandler<bool>? RequestClose;
public TaskViewModel(ILocalizationService localizationService, ReminderTask? existingTask = null)
// ---------- birthday mode ----------
private bool _isBirthday;
public bool IsAnniversary
{
get => _isBirthday;
set
{
if (!SetProperty(ref _isBirthday, value)) return;
OnPropertyChanged(nameof(IsAppointment));
OnPropertyChanged(nameof(WindowTitle));
OnPropertyChanged(nameof(IsInPast));
OnPropertyChanged(nameof(BirthdayPreview));
if (value && _isNewTask && SelectedLeadIndex == 0) SelectedLeadIndex = 1; // birthdays: 1 day before by default
}
}
public bool IsAppointment { get => !IsAnniversary; set => IsAnniversary = !value; }
private string _birthdayText = "";
public string BirthdayText
{
get => _birthdayText;
set
{
if (!SetProperty(ref _birthdayText, value ?? "")) return;
OnPropertyChanged(nameof(BirthdayPreview));
OnPropertyChanged(nameof(BirthdayInvalid));
}
}
private bool TryBirthday(out DateTime next, out int? year)
{
next = default;
if (!BirthdayInput.TryParse(BirthdayText, DateTime.Today, out var d, out var m, out year)) return false;
next = ReminderTask.NextBirthday(d, m, DateTime.Today);
return true;
}
/// <summary>Red only once the input could be complete ("1.1" = 3 chars) – no error after the first digit.</summary>
public bool BirthdayInvalid => BirthdayText.Trim().Length >= 3 && !TryBirthday(out _, out _);
/// <summary>"Next: Thu, 19 March 2027 · turns 41 · in 110 days"</summary>
public string BirthdayPreview
{
get
{
if (!TryBirthday(out var next, out var year))
return _localizationService.GetString(BirthdayInvalid ? "BirthdayInvalid" : "BirthdayHint");
var culture = ReminderTask.DisplayCulture?.Invoke() ?? System.Globalization.CultureInfo.CurrentCulture;
var text = next.ToString("ddd, " + ReminderTask.DayMonthPattern(culture) + " yyyy", culture);
if (year is int y && next.Year > y)
text += " · " + (SelectedCategory?.FormatYears(next.Year - y, culture, _localizationService.GetString)
?? string.Format(_localizationService.GetString("TurnsAge"), next.Year - y));
var rel = ReminderTask.RelativeFormatter?.Invoke(next, DateTime.Now);
if (!string.IsNullOrEmpty(rel)) text += " · " + rel;
return text;
}
}
public string AppointmentText => _localizationService.GetString("TypeAppointment");
public string BirthdayTypeText => _localizationService.GetString("TypeAnniversary");
public string BirthdayLabel => _localizationService.GetString("AnniversaryDate");
public string CategoryLabel => _localizationService.GetString("Category");
public string NoteLabel => _localizationService.GetString("Note");
// ---------- category ----------
public IReadOnlyList<Category> Categories { get; }
private Category? _selectedCategory;
public Category? SelectedCategory
{
get => _selectedCategory;
set
{
if (!SetProperty(ref _selectedCategory, value)) return;
OnPropertyChanged(nameof(BirthdayPreview));
OnPropertyChanged(nameof(WindowTitle));
}
}
public TaskViewModel(ILocalizationService localizationService, ReminderTask? existingTask = null,
string? defaultCategory = null, IEnumerable<Category>? categories = null)
{
_localizationService = localizationService;
_isNewTask = existingTask == null;
Categories = (categories ?? Category.Defaults(localizationService.GetString)).ToList();
var wantedCategory = existingTask?.IsAnniversary == true ? existingTask.CategoryId ?? Category.BirthdayId : defaultCategory;
_selectedCategory = Categories.FirstOrDefault(c => c.Id == wantedCategory) ?? Categories.FirstOrDefault();
if (_isNewTask)
{
_originalTask = new ReminderTask();
_reminderDate = DateTime.Now.AddHours(1);
_isBirthday = defaultCategory != null;
if (_isBirthday) _selectedLeadIndex = 1;
}
else if (existingTask!.IsAnniversary)
{
_originalTask = existingTask;
_isBirthday = true;
_name = existingTask.Name;
_description = existingTask.Description;
_reminderDate = existingTask.ReminderDate;
_isRecurring = true;
_selectedRecurrenceIndex = (int)RecurrenceType.Yearly;
_selectedLeadIndex = Math.Max(0, Array.IndexOf(LeadOptions, existingTask.LeadDays));
_birthdayText = existingTask.ReminderDate.ToString("dd.MM.", System.Globalization.CultureInfo.InvariantCulture)
+ (existingTask.BirthYear?.ToString() ?? "");
}
else
{
@@ -224,6 +357,8 @@ namespace ReminderOrganizer.ViewModels
_reminderDate = existingTask.ReminderDate;
_isRecurring = existingTask.IsRecurring;
_selectedRecurrenceIndex = (int)existingTask.RecurrenceType;
_selectedLeadIndex = Math.Max(0, Array.IndexOf(LeadOptions, existingTask.LeadDays));
_birthYearText = existingTask.BirthYear?.ToString() ?? "";
}
SaveCommand = new RelayCommand(Save, CanSave);
@@ -239,7 +374,8 @@ namespace ReminderOrganizer.ViewModels
OnPropertyChanged(nameof(SelectedMinuteIndex));
}
private bool CanSave() => !string.IsNullOrWhiteSpace(Name);
private bool CanSave() => !string.IsNullOrWhiteSpace(Name) &&
(IsAnniversary ? TryBirthday(out _, out _) : !BirthYearError);
private void ValidateInput()
{
@@ -279,6 +415,35 @@ namespace ReminderOrganizer.ViewModels
{
if (!CanSave()) return;
if (IsAnniversary && TryBirthday(out var nextBirthday, out var birthYear))
{
var lead = LeadOptions[SelectedLeadIndex];
// Editing on the birthday itself after it was already reminded: keep next year's date.
if (!_isNewTask && nextBirthday <= DateTime.Now && _originalTask.ReminderDate > DateTime.Now)
nextBirthday = nextBirthday.AddYears(1);
if (_isNewTask || _originalTask.ReminderDate != nextBirthday || _originalTask.LeadDays != lead)
_originalTask.IsPreNotified = false;
_originalTask.IsAnniversary = true;
_originalTask.CategoryId = SelectedCategory?.Id ?? Category.BirthdayId;
_originalTask.Name = Name.Trim();
_originalTask.Description = Description?.Trim() ?? "";
_originalTask.IsRecurring = true;
_originalTask.RecurrenceType = RecurrenceType.Yearly;
_originalTask.BirthYear = birthYear;
_originalTask.LeadDays = lead;
_originalTask.ReminderDate = nextBirthday;
_originalTask.IsNotified = false;
RequestClose?.Invoke(this, true);
return;
}
_originalTask.IsAnniversary = false;
var leadDays = LeadOptions[SelectedLeadIndex];
bool timingChanged = _originalTask.ReminderDate != ReminderDate || _originalTask.LeadDays != leadDays;
_originalTask.LeadDays = leadDays;
_originalTask.BirthYear = IsYearly ? ParsedBirthYear : null;
if (timingChanged || _isNewTask) _originalTask.IsPreNotified = false;
_originalTask.Name = Name.Trim();
_originalTask.Description = Description?.Trim() ?? "";
_originalTask.IsRecurring = IsRecurring;

55
docs/itchio/README.md Normal file
View File

@@ -0,0 +1,55 @@
# itch.io-Seite: Reminder Organizer
Alles für die Seite liegt in diesem Ordner. Neu erzeugen:
- Motive: `cd sprite-generator` → `gen generate itch_keyart` / `gen generate itch_cover` (Prompts in `prompts.py`)
- Bilder: `py -3.12 ..\..\..\_Tools\Itch\itch_images.py --title "Reminder Organizer" --tagline "Never forget a date again" --backdrop ..\..\sprite-generator\output\itch_keyart_raw_00003_.png --cover-art ..\..\sprite-generator\output\itch_cover_raw_00004_.png --out . --font C:\Windows\Fonts\segoeuib.ttf --color "#C7D2FE"`
- Screenshots: echte App, 1600×1000, Englisch, mit Beispieldaten in eigenem Datenordner (`REMINDER_ORGANIZER_DATA`), hell + dunkel
## Dateien
| Datei | Wofür |
|---|---|
| `cover.png` (630×500) | Cover image |
| `screenshots\01_upcoming.png` … `06_recurring.png` (1600×1000) | Screenshots – Reihenfolge so lassen (01 Upcoming dunkel, 02 Geburtstage hell, 03 Ordner, 04 Neuer Task, 05 helles Theme, 06 wiederkehrend) |
| `banner_960x256.png` / `banner_1920x512.png` | Edit theme → Banner |
| `background_1920x1200.jpg` | Edit theme → Background (oben mittig, nicht wiederholen) |
| `description.html` | Description (im Browser öffnen, Strg+A, kopieren, einfügen) |
| `install.html` | Download & install instructions (genauso einfügen) |
| `..\..\publish\ReminderOrganizer.exe` (≈ 78 MB) | Upload (Windows, ganze App in einer Datei) – vorher `release.bat` |
## Felder unter „Edit game“
| Feld | Eintrag |
|---|---|
| Title | `Reminder Organizer` |
| Project URL | `reminder-organizer` → `https://sn09.itch.io/reminder-organizer` |
| Short description or tagline | `Folders, recurring reminders and birthdays – a small Windows tray app that never lets you forget a date.` |
| Classification | **Tools** |
| Kind of project | **Downloadable** |
| Release status | **Released** |
| Pricing | **No payments** + Haken „Donate“ → *Suggested donation* z. B. $2 (kostenlos, Spende freiwillig) |
| Uploads | `publish\ReminderOrganizer.exe` → Haken **Windows** (Anzeigename z. B. „Reminder Organizer 1.1.0 (Windows, 64-bit)“) |
| Genre | – (bei Tools kein Genre) |
| Tags (max. 10) | `reminder`, `productivity`, `to-do-list`, `calendar`, `organizer`, `notifications`, `birthday`, `system-tray`, `windows`, `dark-mode` |
| AI generation disclosure | **Yes** – Grafik: App-Icon, Cover, Banner, Hintergrund (Flux/ComfyUI); Sound: Erinnerungston (Stable Audio). Screenshots und App-Oberfläche sind echt. |
| App store links | – |
| Custom noun | `app` |
| Community | **Comments** einschalten; Discord-Link steht in der Description |
| Visibility | erst **Draft** (Vorschau prüfen), dann **Public** |
| Languages | English, German |
| Inputs | Keyboard, Mouse |
| Accessibility | – (nichts Passendes; Dark/Light-Theme steht in der Description) |
| Multiplayer | – |
| Average session | A few minutes |
| Links | Discord: `https://discord.gg/Ej4JPmCZva` |
| Gameplay video or trailer | – (kein Trailer, App hat keine Musik) |
| Download & install instructions | Inhalt von `install.html` |
## Seiten-Design („Edit theme“)
- Hintergrund `#121218`, Text `#F5F5F5`, Links/Akzente `#6366F1` (wie Dark-Theme der App), Schrift: „Inter“ oder „Lato“
- Banner `banner_960x256.png`, Background `background_1920x1200.jpg` (oben mittig, nicht wiederholen)
## Vor dem Hochladen prüfen
- [ ] `release.bat` (Tests laufen mit) → frische `publish\ReminderOrganizer.exe`, Version 1.1.0
- [ ] EXE in einen leeren Ordner kopieren und starten: Fenster, Tray-Icon, Testerinnerung erscheint als Windows-Benachrichtigung
- [ ] Description in der Vorschau ansehen (Emojis, Links Discord/E-Mail klickbar)
- [ ] Spenden-Einstellung: Payout-Konto (PayPal/Stripe) auf itch.io eingerichtet
- [ ] Nach dem Veröffentlichen: Projekt-Dashboard erkennt die Seite automatisch (sonst Bearbeiten → itch.io-Seite)

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

BIN
docs/itchio/cover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

View File

@@ -0,0 +1,28 @@
<h2>🔔 Never forget a date again</h2>
<p><strong>Reminder Organizer</strong> is a small Windows app that keeps your reminders in folders and pops them up as Windows notifications at the right time. It sits quietly in the system tray, starts with Windows if you like, and even catches up on reminders you missed while the PC was off. Birthdays, bills, appointments, chores – all in one tidy list.</p>
<h3>✨ Features</h3>
<ul>
<li>📅 <strong>Upcoming view</strong> – every folder in one list, grouped into Overdue, Today, Tomorrow, Next 7 days and Later</li>
<li>🔁 <strong>Recurring reminders</strong> – daily, weekly, monthly or yearly, or just once</li>
<li>⏰ <strong>Remind in advance</strong> – get a heads-up 1, 2 or 3 days or a week before the date</li>
<li>🎂 <strong>Birthdays</strong> – add the year of birth and the app shows "turns 40"</li>
<li>📁 <strong>Coloured folders</strong> – sort by drag and drop, drag a task onto a folder to move it</li>
<li>🔍 <strong>Search and filters</strong> – All, Today, Overdue, plus "Hide done"</li>
<li>📤 <strong>Import &amp; export</strong> – CSV import/export and a calendar export (.ics) for Outlook, Google and Apple Calendar</li>
<li>🌙 <strong>Dark and light theme</strong>, reminder sound (can be turned off), undo after deleting</li>
</ul>
<h3>🕹️ Controls</h3>
<p>🖱️ <strong>Mouse:</strong> click, drag and drop, right-click menus · ⌨️ <strong>Keyboard:</strong> Ctrl+N new task · Ctrl+F search · Del delete · Ctrl+Z undo · Esc clear search</p>
<h3>🌍 Languages</h3>
<p>English and German – the first start follows your Windows language and theme.</p>
<h3>💻 Requirements</h3>
<p>Windows 10 or 11 (64-bit) · about 80 MB · <strong>one file, no install</strong>, no .NET needed. Your reminders are saved in <code>%APPDATA%\ReminderOrganizer</code> with an automatic backup.</p>
<h3>💬 Community</h3>
<p>Ideas, bugs or questions? Join the <a href="https://discord.gg/Ej4JPmCZva">Discord community</a> or write to <a href="mailto:infomichaelmedia1@gmail.com">infomichaelmedia1@gmail.com</a>.</p>
<p><em>© 2026 Michael Media. The icon, artwork and reminder sound were created with the help of AI tools.</em></p>

28
docs/itchio/install.html Normal file
View File

@@ -0,0 +1,28 @@
<h3>Windows (64-bit)</h3>
<ol>
<li>Download <strong>ReminderOrganizer.exe</strong> and put it in a folder of your choice (for example <code>Documents\Tools</code>).</li>
<li>Double-click it. That's all – the whole app is in this one file, <strong>no installation needed</strong>.</li>
</ol>
<p>The very first start takes a few seconds longer while the app unpacks itself. Closing the window keeps the app running in the <strong>system tray</strong> (notification area) so your reminders still pop up – double-click the tray icon to open it again, right-click it to quit. Turn on <strong>File → Settings → Autostart</strong> to start it hidden with Windows.</p>
<h3>Windows SmartScreen</h3>
<p>Because the app is new and not signed, Windows may show <em>"Windows protected your PC"</em>. Click <strong>More info → Run anyway</strong>.</p>
<h3>Your reminders</h3>
<p>Everything is saved automatically in <code>%APPDATA%\ReminderOrganizer\tasks.json</code>, together with a backup of the previous save (<code>tasks.json.bak</code>). To move to another PC, use <strong>File → Export CSV</strong> and import it there.</p>
<h3>Update</h3>
<p>Quit the app (tray icon → right-click → Exit), download the new <strong>ReminderOrganizer.exe</strong> and replace the old one. Your reminders stay in <code>%APPDATA%\ReminderOrganizer</code> and are kept.</p>
<h3>Uninstall</h3>
<ol>
<li>If Autostart is on, turn it off first (File → Settings → Autostart).</li>
<li>Quit the app and delete <strong>ReminderOrganizer.exe</strong>.</li>
<li>To also remove your reminders, delete <code>%APPDATA%\ReminderOrganizer</code>. The unpacked app files are in <code>%TEMP%\.net\ReminderOrganizer</code>.</li>
</ol>
<h3>Problems?</h3>
<ul>
<li><strong>No notifications:</strong> check that Windows notifications and Focus assist / Do not disturb allow them.</li>
<li>Still stuck? Ask in the <a href="https://discord.gg/Ej4JPmCZva">Discord community</a> or write to <a href="mailto:infomichaelmedia1@gmail.com">infomichaelmedia1@gmail.com</a>. Please attach <code>%APPDATA%\ReminderOrganizer\error.log</code> if there is one.</li>
</ul>

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
docs/screenshots/cards.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

View File

@@ -1,11 +1,11 @@
"""Musik und Effekte für generate_audio.py (Stable Audio). Mindestlänge 1 s.
"""Effekte für generate_audio.py (Stable Audio). Mindestlänge 1 s.
CLIPS = [(name, prompt, sekunden, negative)]
"""
NEG_MUSIC = "vocals, singing, speech, harsh noise, distortion, abrupt ending, low quality"
NEG_SFX = "music, melody, vocals, speech, reverb tail, background ambience, low quality"
NEG_SFX = "music, melody, vocals, speech, long reverb tail, background ambience, noise, low quality"
CLIPS = [
("sfx_click", "short soft UI button click", 1, NEG_SFX),
("music_menu", "calm looping menu music, light synth pads", 30, NEG_MUSIC),
("sfx_reminder",
"short pleasant notification chime, two soft bell tones rising, clean, gentle, modern app alert",
2, NEG_SFX),
]

View File

@@ -1,18 +1,29 @@
"""Was generate.py erzeugt.
PROMPTS = [(name, positive)] oder [(name, positive, negative)]
SIZES = {name: (breite, höhe)} optional, sonst Größe des Workflows (1024x1024)
Immer "plain solid black background" verlangen, nie "transparent": cutout.py/adopt.py
stellen den schwarzen Hintergrund deterministisch frei.
"""
_STYLE = (
"game sprite, clean outline, bold colours, soft shading, "
"centred single subject, plain solid black background"
)
"""Was generate.py erzeugt. Immer "plain solid black background", nie "transparent"."""
PROMPTS = [
("example_coin", f"a shiny gold coin, {_STYLE}"),
("icon",
"app icon, a friendly rounded bell with a small green checkmark badge at the lower right, "
"indigo #6366F1 and white, soft gradient, glossy modern flat style, thick clean shapes, "
"readable at small size, centred single subject, plain solid black background"),
]
SIZES = {}
SIZES = {"icon": (1024, 1024)}
STYLE_ITCH = "glossy modern 3D illustration, soft gradients, rounded friendly shapes, indigo #6366F1 as main colour with blue, green, pink and teal accents, calm evening light, clean and cosy, high detail"
PROMPTS += [
("itch_keyart",
"wide scene, a tidy desk by a window at dusk, a large friendly glossy indigo bell with a small green "
"checkmark badge stands on the right, around it neat stacks of blank calendar cards, coloured folders "
"in blue, green, pink and teal, a small wrapped birthday gift and a round clock, soft glow, "
"the left half is a calm dark indigo gradient with empty space, " + STYLE_ITCH +
", no text, no letters, no numbers, no logo, no watermark"),
("itch_cover",
"a large friendly glossy indigo bell with a small green checkmark badge in the lower centre, "
"surrounded by floating blank calendar pages, coloured folders in blue, green, pink and teal, "
"a small wrapped gift box and a round clock, the upper third is a calm smooth indigo-to-violet "
"gradient sky with nothing in it, " + STYLE_ITCH +
", no text, no letters, no numbers, no logo, no watermark"),
]
SIZES.update({"itch_keyart": (1920, 1088), "itch_cover": (1264, 1008)})

29
tools/make_icon.py Normal file
View File

@@ -0,0 +1,29 @@
import sys
from PIL import Image, ImageDraw, ImageFont
out = sys.argv[1]
S = 1024
# background: rounded square, calm vertical gradient (no gloss)
grad = Image.new("RGBA", (S, S))
top, bot = (112, 112, 236), (78, 78, 206)
gd = ImageDraw.Draw(grad)
for y in range(S):
t = y / (S - 1)
gd.line([(0, y), (S, y)], fill=tuple(int(top[i] + (bot[i] - top[i]) * t) for i in range(3)) + (255,))
mask = Image.new("L", (S, S), 0)
m = 56
ImageDraw.Draw(mask).rounded_rectangle([m, m, S - m, S - m], radius=int(S * 0.21), fill=255)
img = Image.new("RGBA", (S, S), (0, 0, 0, 0))
img.paste(grad, (0, 0), mask)
# solid bell: render outline glyph, flood-fill the outside, everything else = bell
font = ImageFont.truetype(r"C:\Windows\Fonts\SegoeIcons.ttf", 520)
g = Image.new("L", (S, S), 0)
gdraw = ImageDraw.Draw(g)
bbox = gdraw.textbbox((0, 0), "\uEA8F", font=font)
w, h = bbox[2] - bbox[0], bbox[3] - bbox[1]
gdraw.text(((S - w) / 2 - bbox[0], (S - h) / 2 - bbox[1] + 6), "\uEA8F", font=font, fill=255)
ImageDraw.floodfill(g, (2, 2), 128)
solid = g.point(lambda v: 0 if v == 128 else 255)
img.paste(Image.new("RGBA", (S, S), (255, 255, 255, 255)), (0, 0), solid)
img.save(out)