- 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>
71 lines
2.9 KiB
C#
71 lines
2.9 KiB
C#
#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>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;
|
|
}
|
|
}
|