Files
ReminderOrganizer/Converters/TaskConverters.cs
Michi 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

81 lines
3.4 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>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;
}
}