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>
This commit is contained in:
@@ -9,6 +9,9 @@ services through `ServiceLocator` (Microsoft.Extensions.DependencyInjection).
|
||||
- `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).
|
||||
- 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, 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).
|
||||
|
||||
168
CategoryWindow.xaml
Normal file
168
CategoryWindow.xaml
Normal file
@@ -0,0 +1,168 @@
|
||||
<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="780" SizeToContent="Height" MaxHeight="720"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
ShowInTaskbar="False"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
MouseLeftButtonDown="Window_MouseLeftButtonDown">
|
||||
<Window.Resources>
|
||||
<SolidColorBrush x:Key="PrimaryBrush" Color="#6366F1"/>
|
||||
<SolidColorBrush x:Key="DangerBrush" Color="#EF4444"/>
|
||||
<SolidColorBrush x:Key="TextPrimaryBrush" Color="#1E293B"/>
|
||||
<SolidColorBrush x:Key="TextSecondaryBrush" Color="#64748B"/>
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#CBD5E1"/>
|
||||
<SolidColorBrush x:Key="CardBrush" Color="#FFFFFF"/>
|
||||
<SolidColorBrush x:Key="InputBackgroundBrush" Color="#F1F5F9"/>
|
||||
<SolidColorBrush x:Key="HoverBrush" Color="#E2E8F0"/>
|
||||
|
||||
<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="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="8,5"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DialogButton" TargetType="Button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="18,8"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="8" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="bd" Property="Opacity" Value="0.85"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="bd" Property="Opacity" Value="0.35"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Border CornerRadius="12" Background="{DynamicResource CardBrush}" Margin="8">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="20" ShadowDepth="5" Opacity="0.25" Direction="270" Color="Black"/>
|
||||
</Border.Effect>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Header -->
|
||||
<Border Background="{DynamicResource PrimaryBrush}" CornerRadius="12,12,0,0" Padding="16,10">
|
||||
<Grid>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="15" Foreground="White" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding [Categories]}" FontSize="14" FontWeight="SemiBold" Foreground="White" VerticalAlignment="Center" Margin="10,0,0,0"/>
|
||||
</StackPanel>
|
||||
<Button Content="" FontFamily="Segoe MDL2 Assets" FontSize="10" HorizontalAlignment="Right" Foreground="White"
|
||||
Background="Transparent" BorderThickness="0" Width="28" Height="28" Cursor="Hand" Click="Cancel_Click" IsCancel="True"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Hint + column titles -->
|
||||
<StackPanel Grid.Row="1" Margin="18,14,18,4">
|
||||
<TextBlock Text="{Binding [CategoriesHint]}" FontSize="12" TextWrapping="Wrap" Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
<Grid Margin="0,12,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="56"/>
|
||||
<ColumnDefinition Width="56"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="170"/>
|
||||
<ColumnDefinition Width="190"/>
|
||||
<ColumnDefinition Width="34"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding [CatIcon]}" FontSize="11" FontWeight="SemiBold" Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding [Color]}" FontSize="11" FontWeight="SemiBold" Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
<TextBlock Grid.Column="2" Text="{Binding [Name]}" FontSize="11" FontWeight="SemiBold" Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
<TextBlock Grid.Column="3" Text="{Binding [CatText]}" FontSize="11" FontWeight="SemiBold" Foreground="{DynamicResource TextSecondaryBrush}" Margin="8,0,0,0"/>
|
||||
<TextBlock Grid.Column="4" Text="{Binding [CatExample]}" FontSize="11" FontWeight="SemiBold" Foreground="{DynamicResource TextSecondaryBrush}" Margin="8,0,0,0"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Rows -->
|
||||
<ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto" Margin="18,0,10,0" MaxHeight="440">
|
||||
<ItemsControl x:Name="Rows" Margin="0,0,8,0">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="0,4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="56"/>
|
||||
<ColumnDefinition Width="56"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="170"/>
|
||||
<ColumnDefinition Width="190"/>
|
||||
<ColumnDefinition Width="34"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ComboBox Grid.Column="0" Width="50" Height="30" HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Glyphs, RelativeSource={RelativeSource AncestorType=Window}}"
|
||||
SelectedItem="{Binding Glyph}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" FontFamily="Segoe MDL2 Assets" FontSize="14"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<ComboBox Grid.Column="1" Width="50" Height="30" HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Palette, RelativeSource={RelativeSource AncestorType=Window}}"
|
||||
SelectedItem="{Binding Color}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Ellipse Width="14" Height="14" Fill="{Binding Converter={StaticResource HexToBrush}}"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBox Grid.Column="2" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource Input}"/>
|
||||
<TextBox Grid.Column="3" Text="{Binding Format, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource Input}" Margin="8,0,0,0"/>
|
||||
|
||||
<TextBlock Grid.Column="4" Margin="8,0,0,0" VerticalAlignment="Center" FontSize="11" TextTrimming="CharacterEllipsis"
|
||||
Foreground="{Binding Color, Converter={StaticResource HexToBrush}}"
|
||||
Loaded="Example_Loaded" Tag="{Binding}"/>
|
||||
|
||||
<Button Grid.Column="5" Content="" FontFamily="Segoe MDL2 Assets" FontSize="12" Width="28" Height="28"
|
||||
Background="Transparent" BorderThickness="0" Cursor="Hand" Foreground="{DynamicResource DangerBrush}"
|
||||
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="18,12,18,18">
|
||||
<Button DockPanel.Dock="Left" Content="{Binding [AddCategory]}" Style="{StaticResource DialogButton}" Click="Add_Click"/>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Content="{Binding [Cancel]}" Style="{StaticResource DialogButton}" Click="Cancel_Click"/>
|
||||
<Button Content="{Binding [Save]}" Style="{StaticResource DialogButton}" Click="Save_Click" IsDefault="True"
|
||||
Background="{DynamicResource PrimaryBrush}" Foreground="White" BorderThickness="0" Margin="8,0,0,0"/>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
119
CategoryWindow.xaml.cs
Normal file
119
CategoryWindow.xaml.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
#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();
|
||||
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_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed && e.OriginalSource is not TextBox) DragMove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,25 @@ namespace ReminderOrganizer.Converters
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Binding.DoNothing;
|
||||
}
|
||||
|
||||
/// <summary>TaskBucket → localized group header ("Overdue", "Today", …).</summary>
|
||||
/// <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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
@@ -28,9 +28,23 @@ namespace ReminderOrganizer.Core
|
||||
};
|
||||
}
|
||||
|
||||
public static bool Matches(ReminderTask t, string? search, TaskFilterMode mode, bool hideDone, DateTime now)
|
||||
/// <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;
|
||||
@@ -38,7 +52,7 @@ namespace ReminderOrganizer.Core
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(search)) return true;
|
||||
var s = search.Trim();
|
||||
return Contains(t.Name, s) || Contains(t.Description, s) || Contains(t.FolderName, s);
|
||||
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) =>
|
||||
@@ -48,11 +62,22 @@ namespace ReminderOrganizer.Core
|
||||
public sealed class Comparer : IComparer
|
||||
{
|
||||
private readonly Func<DateTime> _now;
|
||||
public Comparer(Func<DateTime>? now = null) => _now = now ?? (() => 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;
|
||||
|
||||
@@ -123,13 +123,9 @@
|
||||
"BucketLater": "SPÄTER",
|
||||
"BucketDone": "ERLEDIGT",
|
||||
"TypeAppointment": "Termin",
|
||||
"TypeBirthday": "Geburtstag",
|
||||
"BirthdayDate": "Geburtstag",
|
||||
"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",
|
||||
"NewBirthday": "Neuer Geburtstag",
|
||||
"EditBirthday": "Geburtstag bearbeiten",
|
||||
"RelToday": "heute",
|
||||
"RelTomorrow": "morgen",
|
||||
"RelYesterday": "gestern",
|
||||
@@ -137,5 +133,41 @@
|
||||
"RelDaysAgo": "vor {0} Tagen",
|
||||
"ViewList": "Liste",
|
||||
"ViewCompact": "Kompakt",
|
||||
"ViewCards": "Kacheln"
|
||||
"ViewCards": "Kacheln",
|
||||
"TypeAnniversary": "Jahrestag",
|
||||
"AnniversaryDate": "Datum",
|
||||
"Category": "Kategorie",
|
||||
"Categories": "Kategorien",
|
||||
"CategoriesHint": "Jahrestage wiederholen sich jährlich und haben keine Uhrzeit. Im Text steht {0} für die Anzahl der Jahre und {o} für die Ordnungszahl (10.). Hochzeitstage zeigen zusätzlich den Namen (Silberhochzeit …).",
|
||||
"CatIcon": "Symbol",
|
||||
"CatText": "Text mit Jahr",
|
||||
"CatExample": "Beispiel",
|
||||
"AddCategory": "+ Kategorie",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -123,13 +123,9 @@
|
||||
"BucketLater": "LATER",
|
||||
"BucketDone": "DONE",
|
||||
"TypeAppointment": "Appointment",
|
||||
"TypeBirthday": "Birthday",
|
||||
"BirthdayDate": "Date of birth",
|
||||
"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",
|
||||
"NewBirthday": "New birthday",
|
||||
"EditBirthday": "Edit birthday",
|
||||
"RelToday": "today",
|
||||
"RelTomorrow": "tomorrow",
|
||||
"RelYesterday": "yesterday",
|
||||
@@ -137,5 +133,41 @@
|
||||
"RelDaysAgo": "{0} days ago",
|
||||
"ViewList": "List",
|
||||
"ViewCompact": "Compact",
|
||||
"ViewCards": "Cards"
|
||||
"ViewCards": "Cards",
|
||||
"TypeAnniversary": "Anniversary",
|
||||
"AnniversaryDate": "Date",
|
||||
"Category": "Category",
|
||||
"Categories": "Categories",
|
||||
"CategoriesHint": "Anniversaries repeat every year without a time. In the text, {0} is the number of years and {o} the ordinal (10th). Wedding anniversaries also show the traditional name.",
|
||||
"CatIcon": "Icon",
|
||||
"CatText": "Text with year",
|
||||
"CatExample": "Example",
|
||||
"AddCategory": "+ Category",
|
||||
"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"
|
||||
}
|
||||
|
||||
164
MainWindow.xaml
164
MainWindow.xaml
@@ -100,7 +100,7 @@
|
||||
<ColumnDefinition Width="74"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Ellipse Width="7" Height="7" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Fill="{Binding FolderColor, Converter={StaticResource HexToBrush}}"/>
|
||||
Fill="{Binding AccentColor, Converter={StaticResource HexToBrush}}"/>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<StackPanel.Style>
|
||||
<Style TargetType="StackPanel">
|
||||
@@ -164,10 +164,10 @@
|
||||
|
||||
<!-- calendar sheet -->
|
||||
<Border Grid.RowSpan="2" Width="52" Height="56" CornerRadius="10" VerticalAlignment="Top"
|
||||
Background="{Binding FolderColor, Converter={StaticResource HexToBrush}, ConverterParameter=0.18}">
|
||||
Background="{Binding AccentColor, Converter={StaticResource HexToBrush}, ConverterParameter=0.18}">
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding DayText}" FontSize="22" FontWeight="Bold" HorizontalAlignment="Center"
|
||||
Foreground="{Binding FolderColor, Converter={StaticResource HexToBrush}}"/>
|
||||
Foreground="{Binding AccentColor, Converter={StaticResource HexToBrush}}"/>
|
||||
<TextBlock Text="{Binding MonthText}" FontSize="10" FontWeight="SemiBold" HorizontalAlignment="Center" Margin="0,-2,0,0"
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
</StackPanel>
|
||||
@@ -176,13 +176,11 @@
|
||||
<StackPanel Grid.Column="1" Margin="10,0,0,0">
|
||||
<TextBlock Text="{Binding Name}" FontSize="13.5" FontWeight="SemiBold" TextTrimming="CharacterEllipsis"
|
||||
Foreground="{DynamicResource TextPrimaryBrush}" ToolTip="{Binding Name}"/>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,3,0,0">
|
||||
<Border CornerRadius="8" Padding="7,0" Margin="0,0,6,0" Background="{DynamicResource BadgeBrush}"
|
||||
Visibility="{Binding AgeText, Converter={StaticResource StringToVisibility}}">
|
||||
<TextBlock Text="{Binding AgeText}" FontSize="11" FontWeight="SemiBold" Foreground="{DynamicResource BadgeTextBrush}"/>
|
||||
</Border>
|
||||
<TextBlock Text="{Binding RelativeDate}" Style="{StaticResource RelText}" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<Border CornerRadius="8" Padding="7,0" Margin="0,3,0,0" HorizontalAlignment="Left" Background="{DynamicResource BadgeBrush}"
|
||||
Visibility="{Binding AgeText, Converter={StaticResource StringToVisibility}}" ToolTip="{Binding AgeText}">
|
||||
<TextBlock Text="{Binding AgeText}" FontSize="11" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" Foreground="{DynamicResource BadgeTextBrush}"/>
|
||||
</Border>
|
||||
<TextBlock Text="{Binding RelativeDate}" Style="{StaticResource RelText}" Margin="0,3,0,0"/>
|
||||
<TextBlock Text="{Binding Description}" FontSize="11" Margin="0,4,0,0" TextTrimming="CharacterEllipsis"
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
Visibility="{Binding Description, Converter={StaticResource StringToVisibility}}"/>
|
||||
@@ -256,10 +254,25 @@
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Name}" FontSize="13" FontWeight="SemiBold" TextTrimming="CharacterEllipsis"
|
||||
Foreground="{DynamicResource TextPrimaryBrush}"/>
|
||||
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="11" Margin="8,0,0,0" VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource PrimaryBrush}"
|
||||
Visibility="{Binding IsRecurring, Converter={StaticResource BoolToVisibility}}"
|
||||
ToolTip="{Binding DataContext[RecurringTaskTooltip], RelativeSource={RelativeSource AncestorType=Window}}"/>
|
||||
<!-- recurring icon, or the category icon for anniversaries -->
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="11" Margin="8,0,0,0" VerticalAlignment="Center"
|
||||
Visibility="{Binding IsRecurring, Converter={StaticResource BoolToVisibility}}">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Text" Value=""/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Setter Property="ToolTip" Value="{Binding DataContext[RecurringTaskTooltip], RelativeSource={RelativeSource AncestorType=Window}}"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsAnniversary}" Value="True">
|
||||
<Setter Property="Text" Value="{Binding CategoryGlyph}"/>
|
||||
<Setter Property="FontSize" Value="12.5"/>
|
||||
<Setter Property="Foreground" Value="{Binding AccentColor, Converter={StaticResource HexToBrush}}"/>
|
||||
<Setter Property="ToolTip" Value="{Binding Category.Name}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
<!-- birthday age -->
|
||||
<Border Margin="8,0,0,0" CornerRadius="8" Padding="7,0" VerticalAlignment="Center" Background="{DynamicResource BadgeBrush}"
|
||||
Visibility="{Binding AgeText, Converter={StaticResource StringToVisibility}}">
|
||||
@@ -776,6 +789,11 @@
|
||||
Visibility="{Binding IsAutostartEnabled, Converter={StaticResource BoolToVisibility}}"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="{Binding [EditCategories]}" Command="{Binding EditCategoriesCommand}" Style="{StaticResource DarkMenuItemStyle}">
|
||||
<MenuItem.Icon>
|
||||
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="12" Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="{Binding [PlaySound]}" Command="{Binding TogglePlaySoundCommand}" Style="{StaticResource DarkMenuItemStyle}">
|
||||
<MenuItem.Icon>
|
||||
<TextBlock Text="✓" Foreground="{DynamicResource PrimaryBrush}" FontWeight="Bold"
|
||||
@@ -856,7 +874,7 @@
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource HoverBrush}"/>
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding IsUpcomingMode}" Value="True">
|
||||
<DataTrigger Binding="{Binding IsAllUpcoming}" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Setter Property="TextElement.Foreground" Value="White"/>
|
||||
</DataTrigger>
|
||||
@@ -878,6 +896,49 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Categories: anniversaries across all folders -->
|
||||
<StackPanel DockPanel.Dock="Top" Visibility="{Binding HasCategoryNav, Converter={StaticResource BoolToVisibility}}">
|
||||
<TextBlock Text="{Binding [Categories]}" Foreground="{DynamicResource SidebarSecondaryBrush}"
|
||||
FontSize="11" FontWeight="SemiBold" Margin="28,14,16,4"/>
|
||||
<ItemsControl ItemsSource="{Binding CategoryNav}" Margin="14,0,14,0">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Button Command="{Binding DataContext.ShowCategoryCommand, RelativeSource={RelativeSource AncestorType=Window}}"
|
||||
CommandParameter="{Binding Id}" Cursor="Hand" HorizontalContentAlignment="Stretch">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="bd" Background="Transparent" CornerRadius="8" Padding="10,6" Margin="0,1">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Glyph}" FontFamily="Segoe MDL2 Assets" FontSize="14" Margin="1,0,11,0" VerticalAlignment="Center"
|
||||
Foreground="{Binding Color, Converter={StaticResource HexToBrush}}"/>
|
||||
<TextBlock x:Name="name" Grid.Column="1" Text="{Binding Name}" FontSize="13" VerticalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis" Foreground="{DynamicResource SidebarTextBrush}"/>
|
||||
<TextBlock x:Name="cnt" Grid.Column="2" Text="{Binding Count}" FontSize="11.5" VerticalAlignment="Center" Margin="8,0,4,0"
|
||||
Foreground="{DynamicResource SidebarSecondaryBrush}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding IsActive}" Value="True">
|
||||
<Setter TargetName="bd" Property="Background" Value="{Binding Color, Converter={StaticResource HexToBrush}, ConverterParameter=0.22}"/>
|
||||
<Setter TargetName="name" Property="FontWeight" Value="SemiBold"/>
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Folders Section (fills the remaining height) -->
|
||||
<TextBlock DockPanel.Dock="Top" Text="{Binding [Folders]}"
|
||||
Foreground="{DynamicResource SidebarSecondaryBrush}"
|
||||
@@ -1005,7 +1066,7 @@
|
||||
<ScaleTransform ScaleX="1.2" ScaleY="1.2"/>
|
||||
</Path.LayoutTransform>
|
||||
</Path>
|
||||
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="17" Foreground="White"
|
||||
<TextBlock Text="{Binding HeaderGlyph}" FontFamily="Segoe MDL2 Assets" FontSize="17" Foreground="White"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Visibility="{Binding IsUpcomingMode, Converter={StaticResource BoolToVisibility}}"/>
|
||||
</Grid>
|
||||
@@ -1020,7 +1081,7 @@
|
||||
|
||||
<!-- Search + filters -->
|
||||
<DockPanel Grid.Row="1" Margin="0,0,0,12" LastChildFill="False">
|
||||
<Border DockPanel.Dock="Left" Width="280" Height="34" CornerRadius="8" BorderThickness="1"
|
||||
<Border DockPanel.Dock="Left" Width="220" Height="34" CornerRadius="8" BorderThickness="1"
|
||||
Background="{DynamicResource CardBrush}" BorderBrush="{DynamicResource BorderBrush}">
|
||||
<Grid>
|
||||
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="12" Margin="11,0,0,0" VerticalAlignment="Center"
|
||||
@@ -1091,6 +1152,26 @@
|
||||
<RadioButton GroupName="view" IsChecked="{Binding IsViewList}" Style="{StaticResource ViewToggle}" Content="" ToolTip="{Binding [ViewList]}"/>
|
||||
<RadioButton GroupName="view" IsChecked="{Binding IsViewCompact}" Style="{StaticResource ViewToggle}" Content="" ToolTip="{Binding [ViewCompact]}"/>
|
||||
<RadioButton GroupName="view" IsChecked="{Binding IsViewCards}" Style="{StaticResource ViewToggle}" Content="" ToolTip="{Binding [ViewCards]}"/>
|
||||
<Border Width="1" Margin="4,4" Background="{DynamicResource BorderBrush}"/>
|
||||
<CheckBox IsChecked="{Binding GroupByMonth}" Content="" ToolTip="{Binding [GroupByMonth]}">
|
||||
<CheckBox.Template>
|
||||
<ControlTemplate TargetType="CheckBox">
|
||||
<Border x:Name="bd" Width="30" Height="26" CornerRadius="6" Background="Transparent" Cursor="Hand">
|
||||
<TextBlock x:Name="ic" Text="{TemplateBinding Content}" FontFamily="Segoe MDL2 Assets" FontSize="13"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="bd" Property="Background" Value="{DynamicResource HoverBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter TargetName="bd" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Setter TargetName="ic" Property="Foreground" Value="White"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</CheckBox.Template>
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DockPanel>
|
||||
@@ -1141,17 +1222,46 @@
|
||||
</Style>
|
||||
</ItemsControl.Style>
|
||||
<ItemsControl.GroupStyle>
|
||||
<!-- collapsible groups (buckets or months): click the header to fold -->
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Margin="14,12,0,4">
|
||||
<TextBlock Text="{Binding Name, Converter={StaticResource BucketHeader}}" FontSize="11" FontWeight="Bold"
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
<TextBlock Text="{Binding ItemCount}" FontSize="11" Margin="6,0,0,0" Opacity="0.7"
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
<GroupStyle.ContainerStyle>
|
||||
<Style TargetType="GroupItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupItem">
|
||||
<StackPanel>
|
||||
<ToggleButton x:Name="hdr" IsChecked="True" Cursor="Hand" Margin="6,10,0,2" HorizontalAlignment="Left">
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border Background="Transparent" Padding="8,3" CornerRadius="6">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock x:Name="chev" Text="" FontFamily="Segoe MDL2 Assets" FontSize="9"
|
||||
VerticalAlignment="Center" Margin="0,0,8,0" Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
<ContentPresenter/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="False">
|
||||
<Setter TargetName="chev" Property="Text" Value=""/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Name, Converter={StaticResource BucketHeader}}" FontSize="11" FontWeight="Bold"
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"/>
|
||||
<Border Margin="8,0,0,0" CornerRadius="7" Padding="6,0" Background="{DynamicResource BadgeBrush}">
|
||||
<TextBlock Text="{Binding ItemCount}" FontSize="10.5" FontWeight="SemiBold" Foreground="{DynamicResource BadgeTextBrush}"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ToggleButton>
|
||||
<ItemsPresenter Visibility="{Binding IsChecked, ElementName=hdr, Converter={StaticResource BoolToVisibility}}"/>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</GroupStyle.ContainerStyle>
|
||||
</GroupStyle>
|
||||
</ItemsControl.GroupStyle>
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace ReminderOrganizer
|
||||
|
||||
private void UpcomingEntry_Click(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
_viewModel.IsUpcomingMode = true;
|
||||
_viewModel.ShowUpcomingCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
@@ -145,7 +145,7 @@ namespace ReminderOrganizer
|
||||
{
|
||||
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();
|
||||
|
||||
113
Models/Category.cs
Normal file
113
Models/Category.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using ReminderOrganizer.Core;
|
||||
|
||||
namespace ReminderOrganizer.Models
|
||||
@@ -88,18 +89,48 @@ namespace ReminderOrganizer.Models
|
||||
BirthYear is int y && IsRecurring && RecurrenceType == RecurrenceType.Yearly && ReminderDate.Year > y
|
||||
? ReminderDate.Year - y : null;
|
||||
|
||||
/// <summary>Set once by the app (localized "turns {0}").</summary>
|
||||
public static Func<int, string>? AgeFormatter { get; set; }
|
||||
/// <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(a) ?? a.ToString()) : null;
|
||||
public string? AgeText => UpcomingAge is int a ? (AgeFormatter?.Invoke(this, a) ?? a.ToString()) : null;
|
||||
|
||||
private bool _isBirthday;
|
||||
/// <summary>Birthday: yearly, date only (no time shown), reminded at <see cref="BirthdayHour"/>.</summary>
|
||||
public bool IsBirthday
|
||||
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 => _isBirthday;
|
||||
set { if (SetProperty(ref _isBirthday, value)) RaiseDisplay(); }
|
||||
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;
|
||||
@@ -110,7 +141,7 @@ namespace ReminderOrganizer.Models
|
||||
|
||||
/// <summary>"19. März" for birthdays, otherwise "19.03.2027 09:00".</summary>
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string DisplayDate => IsBirthday
|
||||
public string DisplayDate => IsAnniversary
|
||||
? ReminderDate.ToString(DayMonthPattern(DisplayCulture?.Invoke() ?? CultureInfo.CurrentCulture), DisplayCulture?.Invoke() ?? CultureInfo.CurrentCulture)
|
||||
: ReminderDate.ToString("dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture);
|
||||
|
||||
@@ -137,6 +168,8 @@ namespace ReminderOrganizer.Models
|
||||
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>
|
||||
@@ -154,7 +187,7 @@ namespace ReminderOrganizer.Models
|
||||
|
||||
private string _folderColor = Folder.DefaultColor;
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string FolderColor { get => _folderColor; set => SetProperty(ref _folderColor, value); }
|
||||
public string FolderColor { get => _folderColor; set { if (SetProperty(ref _folderColor, value)) OnPropertyChanged(nameof(AccentColor)); } }
|
||||
|
||||
public DateTime GetNextOccurrence() => GetNextOccurrence(DateTime.Now);
|
||||
|
||||
@@ -298,6 +331,24 @@ namespace ReminderOrganizer.Models
|
||||
public bool HideDone { 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; }
|
||||
|
||||
@@ -308,16 +359,43 @@ namespace ReminderOrganizer.Models
|
||||
/// <summary>Yearly tasks in a "Geburtstage"/"Birthdays" folder become birthday entries (one-time).</summary>
|
||||
public int MigrateBirthdays()
|
||||
{
|
||||
if (BirthdaysMigrated) return 0;
|
||||
BirthdaysMigrated = true;
|
||||
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 (!LooksLikeBirthdayFolder(f.Name)) continue;
|
||||
if (!folderMatches(f.Name)) continue;
|
||||
foreach (var t in f.Tasks)
|
||||
{
|
||||
if (t.IsBirthday || !t.IsRecurring || t.RecurrenceType != RecurrenceType.Yearly) continue;
|
||||
t.IsBirthday = true;
|
||||
if (t.IsAnniversary || !t.IsRecurring || t.RecurrenceType != RecurrenceType.Yearly) continue;
|
||||
t.IsAnniversary = true;
|
||||
t.CategoryId = categoryId;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,11 @@ It runs in the system tray (notification area).
|
||||
- **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)
|
||||
- **Remind in advance** (1, 2 or 3 days, or 1 week before); **birthdays** with year of birth show "turns 40"
|
||||
- **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)
|
||||
- Reminders missed while the app was closed are shown at the next start, with a reminder sound (can be turned off)
|
||||
- **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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
@@ -28,7 +28,7 @@ namespace ReminderOrganizer.Services
|
||||
Line("BEGIN:VEVENT");
|
||||
Line($"UID:{t.Id}@reminder-organizer");
|
||||
Line($"DTSTAMP:{stamp}");
|
||||
if (t.IsBirthday)
|
||||
if (t.IsAnniversary)
|
||||
{
|
||||
// all-day event
|
||||
Line($"DTSTART;VALUE=DATE:{t.ReminderDate.ToString("yyyyMMdd", CultureInfo.InvariantCulture)}");
|
||||
@@ -58,7 +58,7 @@ namespace ReminderOrganizer.Services
|
||||
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.IsBirthday
|
||||
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");
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
<TextBlock Text="{Binding AppointmentText}"/>
|
||||
</StackPanel>
|
||||
</RadioButton>
|
||||
<RadioButton GroupName="type" IsChecked="{Binding IsBirthday}" Style="{StaticResource Segment}">
|
||||
<RadioButton GroupName="type" IsChecked="{Binding IsAnniversary}" Style="{StaticResource Segment}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="12" VerticalAlignment="Center" Margin="0,0,6,0"/>
|
||||
<TextBlock Text="{Binding BirthdayTypeText}"/>
|
||||
@@ -157,7 +157,19 @@
|
||||
Visibility="{Binding HasError, Converter={StaticResource BoolToVisibility}}"/>
|
||||
|
||||
<!-- Birthday: one date field, no time -->
|
||||
<StackPanel Visibility="{Binding IsBirthday, Converter={StaticResource BoolToVisibility}}">
|
||||
<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">
|
||||
|
||||
@@ -14,13 +14,15 @@ namespace ReminderOrganizer
|
||||
|
||||
public ReminderTask TaskResult => _viewModel.TaskResult;
|
||||
|
||||
public TaskWindow(ReminderTask? existingTask, bool darkMode, bool defaultBirthday = false)
|
||||
/// <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();
|
||||
Theme.Apply(Resources, darkMode);
|
||||
|
||||
var localizationService = (ILocalizationService)ServiceLocator.Services.GetService(typeof(ILocalizationService))!;
|
||||
_viewModel = new TaskViewModel(localizationService, existingTask, defaultBirthday);
|
||||
_viewModel = new TaskViewModel(localizationService, existingTask, defaultCategory, categories);
|
||||
_viewModel.RequestClose += OnRequestClose;
|
||||
DataContext = _viewModel;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using ReminderOrganizer.Core;
|
||||
using ReminderOrganizer.Models;
|
||||
using ReminderOrganizer.Services;
|
||||
@@ -64,9 +64,9 @@ namespace ReminderOrganizer.Tests
|
||||
data.Folders.Add(work);
|
||||
|
||||
Assert.Equal(1, data.MigrateBirthdays());
|
||||
Assert.True(bday.Tasks[0].IsBirthday);
|
||||
Assert.False(bday.Tasks[1].IsBirthday);
|
||||
Assert.False(work.Tasks[0].IsBirthday);
|
||||
Assert.True(bday.Tasks[0].IsAnniversary);
|
||||
Assert.False(bday.Tasks[1].IsAnniversary);
|
||||
Assert.False(work.Tasks[0].IsAnniversary);
|
||||
Assert.Equal(0, data.MigrateBirthdays());
|
||||
}
|
||||
|
||||
@@ -74,10 +74,10 @@ namespace ReminderOrganizer.Tests
|
||||
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)) { IsBirthday = true };
|
||||
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.IsBirthday = false;
|
||||
t.IsAnniversary = false;
|
||||
Assert.Equal("19.03.2027 09:00", t.DisplayDate);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace ReminderOrganizer.Tests
|
||||
var data = new AppData();
|
||||
var f = new Folder("Geburtstage");
|
||||
f.Tasks.Add(new ReminderTask("Oma", "", new DateTime(2027, 1, 27, 9, 0, 0))
|
||||
{ IsBirthday = true, IsRecurring = true, RecurrenceType = RecurrenceType.Yearly, LeadDays = 1 });
|
||||
{ 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);
|
||||
|
||||
129
Tests/CategoryTests.cs
Normal file
129
Tests/CategoryTests.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,9 +65,12 @@ namespace ReminderOrganizer.ViewModels
|
||||
bool changed = !ReferenceEquals(_selectedFolder, folder) || _isUpcomingMode;
|
||||
_selectedFolder = folder;
|
||||
_isUpcomingMode = false;
|
||||
_categoryFilter = null;
|
||||
if (!changed) return;
|
||||
OnPropertyChanged(nameof(SelectedFolder));
|
||||
OnPropertyChanged(nameof(IsUpcomingMode));
|
||||
OnPropertyChanged(nameof(CategoryFilter));
|
||||
OnPropertyChanged(nameof(IsAllUpcoming));
|
||||
RebuildView();
|
||||
}
|
||||
|
||||
@@ -79,6 +82,7 @@ namespace ReminderOrganizer.ViewModels
|
||||
if (_isUpcomingMode == value) return;
|
||||
_isUpcomingMode = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(IsAllUpcoming));
|
||||
RebuildView();
|
||||
}
|
||||
}
|
||||
@@ -92,8 +96,8 @@ namespace ReminderOrganizer.ViewModels
|
||||
public bool HasVisibleTasks => VisibleCount > 0;
|
||||
public bool HasSelectedFolder => SelectedFolder != null;
|
||||
|
||||
public string HeaderTitle => IsUpcomingMode ? L("Upcoming") : SelectedFolder?.Name ?? L("Welcome");
|
||||
public string HeaderColor => IsUpcomingMode ? Folder.DefaultColor : SelectedFolder?.Color ?? Folder.DefaultColor;
|
||||
public string HeaderTitle => ActiveCategory?.Name ?? (IsUpcomingMode ? L("Upcoming") : SelectedFolder?.Name ?? L("Welcome"));
|
||||
public string HeaderColor => ActiveCategory?.Color ?? (IsUpcomingMode ? Folder.DefaultColor : SelectedFolder?.Color ?? Folder.DefaultColor);
|
||||
|
||||
public string TaskCountText
|
||||
{
|
||||
@@ -159,7 +163,7 @@ namespace ReminderOrganizer.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsFiltering => !string.IsNullOrWhiteSpace(SearchText) || FilterMode != TaskFilterMode.All || HideDone;
|
||||
private bool IsFiltering => !string.IsNullOrWhiteSpace(SearchText) || FilterMode != TaskFilterMode.All || HideDone || CategoryFilter != null;
|
||||
|
||||
// ---------- settings ----------
|
||||
|
||||
@@ -194,6 +198,92 @@ namespace ReminderOrganizer.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- categories ----------
|
||||
|
||||
public ObservableCollection<Category> Categories => _appData.Categories;
|
||||
|
||||
/// <summary>Sidebar entries: every category that has entries, with count; active one highlighted.</summary>
|
||||
public IReadOnlyList<CategoryNavItem> CategoryNav =>
|
||||
_appData.Categories
|
||||
.Select(c => new CategoryNavItem(c.Id, c.Name, c.Glyph, c.Color,
|
||||
_allTasks.Count(t => t.IsAnniversary && !t.IsNotified && (t.CategoryId ?? Category.BirthdayId) == c.Id),
|
||||
IsUpcomingMode && CategoryFilter == c.Id))
|
||||
.Where(n => n.Count > 0)
|
||||
.ToList();
|
||||
|
||||
public bool HasCategoryNav => CategoryNav.Count > 0;
|
||||
|
||||
private string? _categoryFilter;
|
||||
/// <summary>Category shown in the "Upcoming" view (null = all).</summary>
|
||||
public string? CategoryFilter
|
||||
{
|
||||
get => _categoryFilter;
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _categoryFilter, value)) return;
|
||||
OnPropertyChanged(nameof(HeaderTitle));
|
||||
OnPropertyChanged(nameof(HeaderColor));
|
||||
OnPropertyChanged(nameof(HeaderGlyph));
|
||||
OnPropertyChanged(nameof(IsAllUpcoming));
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
|
||||
private Category? ActiveCategory => IsUpcomingMode && CategoryFilter != null
|
||||
? _appData.Categories.FirstOrDefault(c => c.Id == CategoryFilter) : null;
|
||||
|
||||
/// <summary>"Upcoming" without a category filter (for the sidebar highlight).</summary>
|
||||
public bool IsAllUpcoming => IsUpcomingMode && CategoryFilter == null;
|
||||
|
||||
/// <summary>Icon in the header: category glyph, calendar for "Upcoming", null = folder outline.</summary>
|
||||
public string? HeaderGlyph => ActiveCategory?.Glyph ?? (IsUpcomingMode ? "" : null);
|
||||
|
||||
private void ShowCategory(string? id)
|
||||
{
|
||||
_categoryFilter = id;
|
||||
OnPropertyChanged(nameof(CategoryFilter));
|
||||
OnPropertyChanged(nameof(IsAllUpcoming));
|
||||
if (!IsUpcomingMode) IsUpcomingMode = true; // rebuilds the view
|
||||
else RebuildView();
|
||||
}
|
||||
|
||||
private void EditCategories()
|
||||
{
|
||||
var dialog = new CategoryWindow(_appData.Categories, IsDarkMode,
|
||||
id => _allTasks.Count(t => t.IsAnniversary && (t.CategoryId ?? Category.BirthdayId) == id))
|
||||
{ Owner = Application.Current.MainWindow };
|
||||
if (dialog.ShowDialog() != true) return;
|
||||
|
||||
var result = dialog.Result;
|
||||
var removed = _appData.Categories.Where(c => result.All(r => r.Id != c.Id)).Select(c => c.Id).ToHashSet();
|
||||
_appData.Categories.Clear();
|
||||
foreach (var c in result) _appData.Categories.Add(c);
|
||||
foreach (var t in _allTasks)
|
||||
{
|
||||
if (t.CategoryId != null && removed.Contains(t.CategoryId)) t.CategoryId = null; // back to birthday
|
||||
t.RefreshCategory();
|
||||
}
|
||||
if (CategoryFilter != null && removed.Contains(CategoryFilter)) CategoryFilter = null;
|
||||
UpdateCounts();
|
||||
OnPropertyChanged(nameof(HeaderTitle));
|
||||
_ = SaveAsync();
|
||||
}
|
||||
|
||||
// ---------- month grouping ----------
|
||||
|
||||
public bool GroupByMonth
|
||||
{
|
||||
get => _appData.GroupByMonth;
|
||||
set
|
||||
{
|
||||
if (_appData.GroupByMonth == value) return;
|
||||
_appData.GroupByMonth = value;
|
||||
OnPropertyChanged();
|
||||
RebuildView();
|
||||
_ = SaveAsync();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- view mode ----------
|
||||
|
||||
public string ViewMode
|
||||
@@ -292,6 +382,8 @@ namespace ReminderOrganizer.ViewModels
|
||||
public ICommand ShowUpcomingCommand { get; }
|
||||
public ICommand UndoCommand { get; }
|
||||
public ICommand ClearSearchCommand { get; }
|
||||
public ICommand EditCategoriesCommand { get; }
|
||||
public ICommand ShowCategoryCommand { get; }
|
||||
|
||||
public MainViewModel(
|
||||
IDataService dataService,
|
||||
@@ -304,13 +396,19 @@ namespace ReminderOrganizer.ViewModels
|
||||
_localizationService = localizationService;
|
||||
_autostartService = autostartService;
|
||||
|
||||
ReminderTask.AgeFormatter = age => string.Format(L("TurnsAge"), age);
|
||||
ReminderTask.AgeFormatter = (task, years) =>
|
||||
task.Category?.FormatYears(years, ReminderTask.DisplayCulture!(), L) ?? string.Format(L("TurnsAge"), years);
|
||||
ReminderTask.CategoryLookup = id =>
|
||||
_appData.Categories.FirstOrDefault(c => c.Id == id) ?? _appData.Categories.FirstOrDefault();
|
||||
ReminderTask.DisplayCulture = () => new System.Globalization.CultureInfo(_localizationService.CurrentLanguage == "de" ? "de-DE" : "en-US");
|
||||
ReminderTask.RelativeFormatter = RelativeText;
|
||||
|
||||
// Empty name = refresh every binding (all texts depend on the language).
|
||||
_localizationService.StringsChanged += (s, e) =>
|
||||
{
|
||||
Category.RelocalizePresets(_appData.Categories, L,
|
||||
new[] { LocalizationService.LoadStrings("en"), LocalizationService.LoadStrings("de") });
|
||||
foreach (var t in _allTasks) t.RefreshCategory();
|
||||
OnPropertyChanged(string.Empty);
|
||||
_tasksView?.Refresh(); // group headers + age texts
|
||||
};
|
||||
@@ -339,9 +437,11 @@ namespace ReminderOrganizer.ViewModels
|
||||
ExportCsvCommand = new RelayCommand(ExportCsv);
|
||||
ExportIcsCommand = new RelayCommand(ExportIcs);
|
||||
OpenDiscordCommand = new RelayCommand(OpenDiscord);
|
||||
ShowUpcomingCommand = new RelayCommand(() => IsUpcomingMode = true);
|
||||
ShowUpcomingCommand = new RelayCommand(() => ShowCategory(null));
|
||||
ShowCategoryCommand = new RelayCommand<string>(ShowCategory);
|
||||
UndoCommand = new RelayCommand(Undo);
|
||||
ClearSearchCommand = new RelayCommand(() => { SearchText = ""; FilterMode = TaskFilterMode.All; });
|
||||
ClearSearchCommand = new RelayCommand(() => { SearchText = ""; FilterMode = TaskFilterMode.All; CategoryFilter = null; });
|
||||
EditCategoriesCommand = new RelayCommand(EditCategories);
|
||||
|
||||
_reminderTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(30) };
|
||||
_reminderTimer.Tick += (s, e) => CheckReminders();
|
||||
@@ -362,7 +462,9 @@ namespace ReminderOrganizer.ViewModels
|
||||
if (firstRun)
|
||||
await SaveAsync();
|
||||
|
||||
if (_appData.MigrateBirthdays() > 0) await SaveAsync();
|
||||
bool changed = _appData.EnsureDefaultCategories(L);
|
||||
changed |= _appData.MigrateBirthdays() > 0;
|
||||
if (changed) await SaveAsync();
|
||||
_isDarkMode = _appData.IsDarkMode.Value;
|
||||
_appData.Folders.CollectionChanged += (s, e) => { HookFolders(); ReindexTasks(); };
|
||||
HookFolders();
|
||||
@@ -430,16 +532,19 @@ namespace ReminderOrganizer.ViewModels
|
||||
{
|
||||
var view = new ListCollectionView((System.Collections.IList)source)
|
||||
{
|
||||
CustomSort = new TaskQuery.Comparer(),
|
||||
Filter = o => o is ReminderTask t && TaskQuery.Matches(t, SearchText, FilterMode, HideDone, DateTime.Now)
|
||||
CustomSort = new TaskQuery.Comparer(chronological: GroupByMonth),
|
||||
Filter = o => o is ReminderTask t && TaskQuery.Matches(t, SearchText, FilterMode, HideDone, DateTime.Now, CategoryFilter)
|
||||
};
|
||||
if (IsUpcomingMode)
|
||||
if (GroupByMonth)
|
||||
view.GroupDescriptions.Add(new PropertyGroupDescription(null, new Converters.MonthKeyConverter()));
|
||||
else if (IsUpcomingMode)
|
||||
view.GroupDescriptions.Add(new PropertyGroupDescription(null, new Converters.TaskBucketConverter()));
|
||||
_tasksView = view;
|
||||
}
|
||||
OnPropertyChanged(nameof(TasksView));
|
||||
OnPropertyChanged(nameof(HeaderTitle));
|
||||
OnPropertyChanged(nameof(HeaderColor));
|
||||
OnPropertyChanged(nameof(HeaderGlyph));
|
||||
OnPropertyChanged(nameof(HasSelectedFolder));
|
||||
UpdateCounts();
|
||||
}
|
||||
@@ -461,6 +566,8 @@ namespace ReminderOrganizer.ViewModels
|
||||
OnPropertyChanged(nameof(UpcomingCount));
|
||||
OnPropertyChanged(nameof(EmptyTitle));
|
||||
OnPropertyChanged(nameof(EmptyHint));
|
||||
OnPropertyChanged(nameof(CategoryNav));
|
||||
OnPropertyChanged(nameof(HasCategoryNav));
|
||||
}
|
||||
|
||||
// ---------- dialogs ----------
|
||||
@@ -551,9 +658,15 @@ namespace ReminderOrganizer.ViewModels
|
||||
}
|
||||
|
||||
// Birthday folders (by name or because they mostly hold birthdays) open the birthday form.
|
||||
bool birthday = AppData.LooksLikeBirthdayFolder(folder.Name) ||
|
||||
(folder.Tasks.Count > 0 && folder.Tasks.Count(t => t.IsBirthday) * 2 > folder.Tasks.Count);
|
||||
var taskWindow = new TaskWindow(null, IsDarkMode, birthday) { Owner = Application.Current.MainWindow };
|
||||
// Anniversary folders (by name or because they mostly hold anniversaries) open the anniversary form
|
||||
// with the folder's usual category preselected.
|
||||
string? category = AppData.CategoryHintForFolder(folder.Name);
|
||||
var anniversaries = folder.Tasks.Where(t => t.IsAnniversary).ToList();
|
||||
if (category == null && anniversaries.Count * 2 > folder.Tasks.Count && anniversaries.Count > 0)
|
||||
category = anniversaries.GroupBy(t => t.CategoryId ?? Category.BirthdayId).OrderByDescending(g => g.Count()).First().Key;
|
||||
if (category == null && CategoryFilter is { } cf && cf != TaskQuery.AppointmentsFilter)
|
||||
category = cf;
|
||||
var taskWindow = new TaskWindow(null, IsDarkMode, Categories, category) { Owner = Application.Current.MainWindow };
|
||||
if (taskWindow.ShowDialog() == true)
|
||||
{
|
||||
folder.Tasks.Add(taskWindow.TaskResult);
|
||||
|
||||
@@ -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,7 @@ namespace ReminderOrganizer.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInPast => !IsBirthday && !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 };
|
||||
@@ -211,8 +213,10 @@ namespace ReminderOrganizer.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string WindowTitle => _localizationService.GetString(
|
||||
IsBirthday ? (_isNewTask ? "NewBirthday" : "EditBirthday") : (_isNewTask ? "NewTask" : "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");
|
||||
@@ -238,7 +242,7 @@ namespace ReminderOrganizer.ViewModels
|
||||
// ---------- birthday mode ----------
|
||||
|
||||
private bool _isBirthday;
|
||||
public bool IsBirthday
|
||||
public bool IsAnniversary
|
||||
{
|
||||
get => _isBirthday;
|
||||
set
|
||||
@@ -251,7 +255,7 @@ namespace ReminderOrganizer.ViewModels
|
||||
if (value && _isNewTask && SelectedLeadIndex == 0) SelectedLeadIndex = 1; // birthdays: 1 day before by default
|
||||
}
|
||||
}
|
||||
public bool IsAppointment { get => !IsBirthday; set => IsBirthday = !value; }
|
||||
public bool IsAppointment { get => !IsAnniversary; set => IsAnniversary = !value; }
|
||||
|
||||
private string _birthdayText = "";
|
||||
public string BirthdayText
|
||||
@@ -285,7 +289,9 @@ namespace ReminderOrganizer.ViewModels
|
||||
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) text += " · " + string.Format(_localizationService.GetString("TurnsAge"), next.Year - y);
|
||||
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;
|
||||
@@ -293,23 +299,44 @@ namespace ReminderOrganizer.ViewModels
|
||||
}
|
||||
|
||||
public string AppointmentText => _localizationService.GetString("TypeAppointment");
|
||||
public string BirthdayTypeText => _localizationService.GetString("TypeBirthday");
|
||||
public string BirthdayLabel => _localizationService.GetString("BirthdayDate");
|
||||
public string BirthdayTypeText => _localizationService.GetString("TypeAnniversary");
|
||||
public string BirthdayLabel => _localizationService.GetString("AnniversaryDate");
|
||||
public string CategoryLabel => _localizationService.GetString("Category");
|
||||
public string NoteLabel => _localizationService.GetString("Note");
|
||||
|
||||
public TaskViewModel(ILocalizationService localizationService, ReminderTask? existingTask = null, bool defaultBirthday = false)
|
||||
// ---------- 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 = defaultBirthday;
|
||||
if (defaultBirthday) _selectedLeadIndex = 1;
|
||||
_isBirthday = defaultCategory != null;
|
||||
if (_isBirthday) _selectedLeadIndex = 1;
|
||||
}
|
||||
else if (existingTask!.IsBirthday)
|
||||
else if (existingTask!.IsAnniversary)
|
||||
{
|
||||
_originalTask = existingTask;
|
||||
_isBirthday = true;
|
||||
@@ -348,7 +375,7 @@ namespace ReminderOrganizer.ViewModels
|
||||
}
|
||||
|
||||
private bool CanSave() => !string.IsNullOrWhiteSpace(Name) &&
|
||||
(IsBirthday ? TryBirthday(out _, out _) : !BirthYearError);
|
||||
(IsAnniversary ? TryBirthday(out _, out _) : !BirthYearError);
|
||||
|
||||
private void ValidateInput()
|
||||
{
|
||||
@@ -388,7 +415,7 @@ namespace ReminderOrganizer.ViewModels
|
||||
{
|
||||
if (!CanSave()) return;
|
||||
|
||||
if (IsBirthday && TryBirthday(out var nextBirthday, out var birthYear))
|
||||
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.
|
||||
@@ -396,7 +423,8 @@ namespace ReminderOrganizer.ViewModels
|
||||
nextBirthday = nextBirthday.AddYears(1);
|
||||
if (_isNewTask || _originalTask.ReminderDate != nextBirthday || _originalTask.LeadDays != lead)
|
||||
_originalTask.IsPreNotified = false;
|
||||
_originalTask.IsBirthday = true;
|
||||
_originalTask.IsAnniversary = true;
|
||||
_originalTask.CategoryId = SelectedCategory?.Id ?? Category.BirthdayId;
|
||||
_originalTask.Name = Name.Trim();
|
||||
_originalTask.Description = Description?.Trim() ?? "";
|
||||
_originalTask.IsRecurring = true;
|
||||
@@ -408,7 +436,7 @@ namespace ReminderOrganizer.ViewModels
|
||||
RequestClose?.Invoke(this, true);
|
||||
return;
|
||||
}
|
||||
_originalTask.IsBirthday = false;
|
||||
_originalTask.IsAnniversary = false;
|
||||
|
||||
var leadDays = LeadOptions[SelectedLeadIndex];
|
||||
bool timingChanged = _originalTask.ReminderDate != ReminderDate || _originalTask.LeadDays != leadDays;
|
||||
|
||||
BIN
docs/screenshots/anniversary-dialog.png
Normal file
BIN
docs/screenshots/anniversary-dialog.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
docs/screenshots/categories-months.png
Normal file
BIN
docs/screenshots/categories-months.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
BIN
docs/screenshots/category-editor.png
Normal file
BIN
docs/screenshots/category-editor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
Reference in New Issue
Block a user