2026-11-29 15:06:19 +01:00
|
|
|
|
#nullable enable
|
2026-11-25 13:44:02 +01:00
|
|
|
|
using System;
|
2026-11-29 15:06:19 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
2026-11-25 13:44:02 +01:00
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
using ReminderOrganizer.Core;
|
|
|
|
|
|
using ReminderOrganizer.Models;
|
|
|
|
|
|
using ReminderOrganizer.Services;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ReminderOrganizer.ViewModels
|
|
|
|
|
|
{
|
|
|
|
|
|
public class TaskViewModel : ViewModelBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ILocalizationService _localizationService;
|
|
|
|
|
|
private readonly ReminderTask _originalTask;
|
|
|
|
|
|
private readonly bool _isNewTask;
|
|
|
|
|
|
private string _name = "";
|
|
|
|
|
|
private string _description = "";
|
|
|
|
|
|
private DateTime _reminderDate = DateTime.Now.AddHours(1);
|
|
|
|
|
|
private string _errorMessage = "";
|
|
|
|
|
|
private bool _hasError = false;
|
|
|
|
|
|
private bool _isRecurring = false;
|
|
|
|
|
|
private int _selectedRecurrenceIndex = 3;
|
|
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _name;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _name, value);
|
|
|
|
|
|
ValidateInput();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string Description
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _description;
|
|
|
|
|
|
set => SetProperty(ref _description, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DateTime ReminderDate
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _reminderDate;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _reminderDate, value);
|
|
|
|
|
|
UpdateHourMinuteIndices();
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
OnDateChanged();
|
2026-11-25 13:44:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
private void OnDateChanged()
|
|
|
|
|
|
{
|
|
|
|
|
|
OnPropertyChanged(nameof(ReminderDate));
|
|
|
|
|
|
OnPropertyChanged(nameof(SelectedDay));
|
|
|
|
|
|
OnPropertyChanged(nameof(NextOccurrenceText));
|
|
|
|
|
|
OnPropertyChanged(nameof(IsInPast));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-25 13:44:02 +01:00
|
|
|
|
public DateTime MinDate => DateTime.Now.AddMinutes(-1);
|
|
|
|
|
|
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
/// <summary>Date part for the DatePicker – keeps the chosen hour/minute (DatePicker returns 00:00).</summary>
|
|
|
|
|
|
public DateTime? SelectedDay
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _reminderDate.Date;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value == null) return;
|
|
|
|
|
|
var d = value.Value.Date;
|
|
|
|
|
|
ReminderDate = new DateTime(d.Year, d.Month, d.Day, _reminderDate.Hour, _reminderDate.Minute, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-29 15:06:19 +01:00
|
|
|
|
public bool IsInPast => !IsAnniversary && !IsRecurring && ReminderDate <= DateTime.Now;
|
Upcoming view, search/filters, lead reminders, birthdays, folder colors, ICS, sound, undo
- Upcoming: all folders grouped by overdue/today/tomorrow/7 days/later/done
- Search (Ctrl+F) + All/Today/Overdue filters + hide done (persisted)
- Lead reminder 1/2/3 days or 1 week before; birth year shows age
- Several due reminders are combined into one balloon
- Folder colors and reordering (drag, context menu)
- iCalendar export with RRULE and VALARM
- Generated reminder chime (ComfyUI / Stable Audio), can be turned off
- Undo snackbar for deleted tasks/folders (Ctrl+Z), Ctrl+N, Del, Esc
- 41 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 15:03:36 +01:00
|
|
|
|
|
|
|
|
|
|
// lead reminder: index into LeadOptions
|
|
|
|
|
|
public static readonly int[] LeadOptions = { 0, 1, 2, 3, 7 };
|
|
|
|
|
|
private int _selectedLeadIndex;
|
|
|
|
|
|
public int SelectedLeadIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _selectedLeadIndex;
|
|
|
|
|
|
set => SetProperty(ref _selectedLeadIndex, Math.Clamp(value, 0, LeadOptions.Length - 1));
|
|
|
|
|
|
}
|
|
|
|
|
|
public string LeadLabel => _localizationService.GetString("LeadReminder");
|
|
|
|
|
|
public string LeadNone => _localizationService.GetString("LeadNone");
|
|
|
|
|
|
public string Lead1 => _localizationService.GetString("LeadOneDay");
|
|
|
|
|
|
public string Lead2 => string.Format(_localizationService.GetString("LeadDays"), 2);
|
|
|
|
|
|
public string Lead3 => string.Format(_localizationService.GetString("LeadDays"), 3);
|
|
|
|
|
|
public string Lead7 => _localizationService.GetString("LeadWeek");
|
|
|
|
|
|
|
|
|
|
|
|
// birthday
|
|
|
|
|
|
private string _birthYearText = "";
|
|
|
|
|
|
public string BirthYearText
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _birthYearText;
|
|
|
|
|
|
set { if (SetProperty(ref _birthYearText, value ?? "")) OnPropertyChanged(nameof(BirthYearError)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
public int? ParsedBirthYear =>
|
|
|
|
|
|
int.TryParse(BirthYearText.Trim(), out var y) && y >= 1900 && y <= DateTime.Now.Year ? y : null;
|
|
|
|
|
|
public bool BirthYearError => BirthYearText.Trim().Length > 0 && ParsedBirthYear == null;
|
|
|
|
|
|
public bool IsYearly => IsRecurring && SelectedRecurrenceIndex == (int)RecurrenceType.Yearly;
|
|
|
|
|
|
public string BirthYearLabel => _localizationService.GetString("BirthYear");
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
public string PastDateWarning => _localizationService.GetString("PastDateWarning");
|
|
|
|
|
|
public string NextOccurrenceLabel => _localizationService.GetString("NextOccurrence");
|
|
|
|
|
|
public string QuickLabel => _localizationService.GetString("Quick");
|
|
|
|
|
|
public string TomorrowText => _localizationService.GetString("Tomorrow");
|
|
|
|
|
|
public string NextWeekText => _localizationService.GetString("NextWeek");
|
|
|
|
|
|
public string NextMonthText => _localizationService.GetString("NextMonth");
|
|
|
|
|
|
public string NamePlaceholder => _localizationService.GetString("NewTask");
|
|
|
|
|
|
|
2026-11-25 13:44:02 +01:00
|
|
|
|
public int SelectedHourIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _reminderDate.Hour;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
if (value < 0) return;
|
2026-11-25 13:44:02 +01:00
|
|
|
|
var newDate = new DateTime(_reminderDate.Year, _reminderDate.Month, _reminderDate.Day, value, _reminderDate.Minute, 0);
|
|
|
|
|
|
SetProperty(ref _reminderDate, newDate);
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
OnDateChanged();
|
2026-11-25 13:44:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int SelectedMinuteIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _reminderDate.Minute / 5;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
if (value < 0) return;
|
2026-11-25 13:44:02 +01:00
|
|
|
|
var newDate = new DateTime(_reminderDate.Year, _reminderDate.Month, _reminderDate.Day, _reminderDate.Hour, value * 5, 0);
|
|
|
|
|
|
SetProperty(ref _reminderDate, newDate);
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
OnDateChanged();
|
2026-11-25 13:44:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string ErrorMessage
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _errorMessage;
|
|
|
|
|
|
set => SetProperty(ref _errorMessage, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool HasError
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _hasError;
|
|
|
|
|
|
set => SetProperty(ref _hasError, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsRecurring
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _isRecurring;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
// Only copied to the task in Save() – Cancel must not change anything.
|
2026-11-25 13:44:02 +01:00
|
|
|
|
SetProperty(ref _isRecurring, value);
|
Upcoming view, search/filters, lead reminders, birthdays, folder colors, ICS, sound, undo
- Upcoming: all folders grouped by overdue/today/tomorrow/7 days/later/done
- Search (Ctrl+F) + All/Today/Overdue filters + hide done (persisted)
- Lead reminder 1/2/3 days or 1 week before; birth year shows age
- Several due reminders are combined into one balloon
- Folder colors and reordering (drag, context menu)
- iCalendar export with RRULE and VALARM
- Generated reminder chime (ComfyUI / Stable Audio), can be turned off
- Undo snackbar for deleted tasks/folders (Ctrl+Z), Ctrl+N, Del, Esc
- 41 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 15:03:36 +01:00
|
|
|
|
OnPropertyChanged(nameof(IsYearly));
|
2026-11-25 13:44:02 +01:00
|
|
|
|
OnPropertyChanged(nameof(NextOccurrenceText));
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
OnPropertyChanged(nameof(IsInPast));
|
2026-11-25 13:44:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int SelectedRecurrenceIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _selectedRecurrenceIndex;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
if (value < 0) return;
|
2026-11-25 13:44:02 +01:00
|
|
|
|
SetProperty(ref _selectedRecurrenceIndex, value);
|
Upcoming view, search/filters, lead reminders, birthdays, folder colors, ICS, sound, undo
- Upcoming: all folders grouped by overdue/today/tomorrow/7 days/later/done
- Search (Ctrl+F) + All/Today/Overdue filters + hide done (persisted)
- Lead reminder 1/2/3 days or 1 week before; birth year shows age
- Several due reminders are combined into one balloon
- Folder colors and reordering (drag, context menu)
- iCalendar export with RRULE and VALARM
- Generated reminder chime (ComfyUI / Stable Audio), can be turned off
- Undo snackbar for deleted tasks/folders (Ctrl+Z), Ctrl+N, Del, Esc
- 41 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 15:03:36 +01:00
|
|
|
|
OnPropertyChanged(nameof(IsYearly));
|
2026-11-25 13:44:02 +01:00
|
|
|
|
OnPropertyChanged(nameof(IsDailySelected));
|
|
|
|
|
|
OnPropertyChanged(nameof(IsWeeklySelected));
|
|
|
|
|
|
OnPropertyChanged(nameof(IsMonthlySelected));
|
|
|
|
|
|
OnPropertyChanged(nameof(IsYearlySelected));
|
|
|
|
|
|
OnPropertyChanged(nameof(NextOccurrenceText));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsDailySelected
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _selectedRecurrenceIndex == 0;
|
|
|
|
|
|
set { if (value) { SelectedRecurrenceIndex = 0; } }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsWeeklySelected
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _selectedRecurrenceIndex == 1;
|
|
|
|
|
|
set { if (value) { SelectedRecurrenceIndex = 1; } }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsMonthlySelected
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _selectedRecurrenceIndex == 2;
|
|
|
|
|
|
set { if (value) { SelectedRecurrenceIndex = 2; } }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsYearlySelected
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _selectedRecurrenceIndex == 3;
|
|
|
|
|
|
set { if (value) { SelectedRecurrenceIndex = 3; } }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string NextOccurrenceText
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!IsRecurring) return "";
|
|
|
|
|
|
|
|
|
|
|
|
var tempTask = new ReminderTask
|
|
|
|
|
|
{
|
|
|
|
|
|
ReminderDate = ReminderDate,
|
|
|
|
|
|
RecurrenceType = (RecurrenceType)_selectedRecurrenceIndex
|
|
|
|
|
|
};
|
|
|
|
|
|
var next = tempTask.GetNextOccurrence();
|
|
|
|
|
|
return next.ToString("dd.MM.yyyy HH:mm");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-29 15:06:19 +01:00
|
|
|
|
/// <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");
|
2026-11-25 13:44:02 +01:00
|
|
|
|
|
|
|
|
|
|
public string NameLabel => _localizationService.GetString("Name");
|
|
|
|
|
|
public string DescriptionLabel => _localizationService.GetString("Description");
|
|
|
|
|
|
public string DateLabel => _localizationService.GetString("Date");
|
|
|
|
|
|
public string SaveText => _localizationService.GetString("Save");
|
|
|
|
|
|
public string CancelText => _localizationService.GetString("Cancel");
|
|
|
|
|
|
public string RecurringLabel => _localizationService.GetString("Recurring");
|
|
|
|
|
|
public string DailyText => _localizationService.GetString("Daily");
|
|
|
|
|
|
public string WeeklyText => _localizationService.GetString("Weekly");
|
|
|
|
|
|
public string MonthlyText => _localizationService.GetString("Monthly");
|
|
|
|
|
|
public string YearlyText => _localizationService.GetString("Yearly");
|
|
|
|
|
|
|
|
|
|
|
|
public ICommand SaveCommand { get; }
|
|
|
|
|
|
public ICommand CancelCommand { get; }
|
|
|
|
|
|
public ICommand SetTomorrowCommand { get; }
|
|
|
|
|
|
public ICommand SetNextWeekCommand { get; }
|
|
|
|
|
|
public ICommand SetNextMonthCommand { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public ReminderTask TaskResult => _originalTask;
|
|
|
|
|
|
|
|
|
|
|
|
public event EventHandler<bool>? RequestClose;
|
|
|
|
|
|
|
2026-11-29 14:42:16 +01:00
|
|
|
|
// ---------- birthday mode ----------
|
|
|
|
|
|
|
|
|
|
|
|
private bool _isBirthday;
|
2026-11-29 15:06:19 +01:00
|
|
|
|
public bool IsAnniversary
|
2026-11-29 14:42:16 +01:00
|
|
|
|
{
|
|
|
|
|
|
get => _isBirthday;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!SetProperty(ref _isBirthday, value)) return;
|
|
|
|
|
|
OnPropertyChanged(nameof(IsAppointment));
|
|
|
|
|
|
OnPropertyChanged(nameof(WindowTitle));
|
|
|
|
|
|
OnPropertyChanged(nameof(IsInPast));
|
|
|
|
|
|
OnPropertyChanged(nameof(BirthdayPreview));
|
|
|
|
|
|
if (value && _isNewTask && SelectedLeadIndex == 0) SelectedLeadIndex = 1; // birthdays: 1 day before by default
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-11-29 15:06:19 +01:00
|
|
|
|
public bool IsAppointment { get => !IsAnniversary; set => IsAnniversary = !value; }
|
2026-11-29 14:42:16 +01:00
|
|
|
|
|
|
|
|
|
|
private string _birthdayText = "";
|
|
|
|
|
|
public string BirthdayText
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _birthdayText;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!SetProperty(ref _birthdayText, value ?? "")) return;
|
|
|
|
|
|
OnPropertyChanged(nameof(BirthdayPreview));
|
|
|
|
|
|
OnPropertyChanged(nameof(BirthdayInvalid));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool TryBirthday(out DateTime next, out int? year)
|
|
|
|
|
|
{
|
|
|
|
|
|
next = default;
|
|
|
|
|
|
if (!BirthdayInput.TryParse(BirthdayText, DateTime.Today, out var d, out var m, out year)) return false;
|
|
|
|
|
|
next = ReminderTask.NextBirthday(d, m, DateTime.Today);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Red only once the input could be complete ("1.1" = 3 chars) – no error after the first digit.</summary>
|
|
|
|
|
|
public bool BirthdayInvalid => BirthdayText.Trim().Length >= 3 && !TryBirthday(out _, out _);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>"Next: Thu, 19 March 2027 · turns 41 · in 110 days"</summary>
|
|
|
|
|
|
public string BirthdayPreview
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!TryBirthday(out var next, out var year))
|
|
|
|
|
|
return _localizationService.GetString(BirthdayInvalid ? "BirthdayInvalid" : "BirthdayHint");
|
|
|
|
|
|
var culture = ReminderTask.DisplayCulture?.Invoke() ?? System.Globalization.CultureInfo.CurrentCulture;
|
|
|
|
|
|
var text = next.ToString("ddd, " + ReminderTask.DayMonthPattern(culture) + " yyyy", culture);
|
2026-11-29 15:06:19 +01:00
|
|
|
|
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));
|
2026-11-29 14:42:16 +01:00
|
|
|
|
var rel = ReminderTask.RelativeFormatter?.Invoke(next, DateTime.Now);
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rel)) text += " · " + rel;
|
|
|
|
|
|
return text;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AppointmentText => _localizationService.GetString("TypeAppointment");
|
2026-11-29 15:06:19 +01:00
|
|
|
|
public string BirthdayTypeText => _localizationService.GetString("TypeAnniversary");
|
|
|
|
|
|
public string BirthdayLabel => _localizationService.GetString("AnniversaryDate");
|
|
|
|
|
|
public string CategoryLabel => _localizationService.GetString("Category");
|
2026-11-29 14:42:16 +01:00
|
|
|
|
public string NoteLabel => _localizationService.GetString("Note");
|
|
|
|
|
|
|
2026-11-29 15:06:19 +01:00
|
|
|
|
// ---------- 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)
|
2026-11-25 13:44:02 +01:00
|
|
|
|
{
|
|
|
|
|
|
_localizationService = localizationService;
|
|
|
|
|
|
_isNewTask = existingTask == null;
|
2026-11-29 15:06:19 +01:00
|
|
|
|
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();
|
2026-11-29 14:42:16 +01:00
|
|
|
|
|
2026-11-25 13:44:02 +01:00
|
|
|
|
if (_isNewTask)
|
|
|
|
|
|
{
|
|
|
|
|
|
_originalTask = new ReminderTask();
|
|
|
|
|
|
_reminderDate = DateTime.Now.AddHours(1);
|
2026-11-29 15:06:19 +01:00
|
|
|
|
_isBirthday = defaultCategory != null;
|
|
|
|
|
|
if (_isBirthday) _selectedLeadIndex = 1;
|
2026-11-29 14:42:16 +01:00
|
|
|
|
}
|
2026-11-29 15:06:19 +01:00
|
|
|
|
else if (existingTask!.IsAnniversary)
|
2026-11-29 14:42:16 +01:00
|
|
|
|
{
|
|
|
|
|
|
_originalTask = existingTask;
|
|
|
|
|
|
_isBirthday = true;
|
|
|
|
|
|
_name = existingTask.Name;
|
|
|
|
|
|
_description = existingTask.Description;
|
|
|
|
|
|
_reminderDate = existingTask.ReminderDate;
|
|
|
|
|
|
_isRecurring = true;
|
|
|
|
|
|
_selectedRecurrenceIndex = (int)RecurrenceType.Yearly;
|
|
|
|
|
|
_selectedLeadIndex = Math.Max(0, Array.IndexOf(LeadOptions, existingTask.LeadDays));
|
|
|
|
|
|
_birthdayText = existingTask.ReminderDate.ToString("dd.MM.", System.Globalization.CultureInfo.InvariantCulture)
|
|
|
|
|
|
+ (existingTask.BirthYear?.ToString() ?? "");
|
2026-11-25 13:44:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_originalTask = existingTask!;
|
|
|
|
|
|
_name = existingTask!.Name;
|
|
|
|
|
|
_description = existingTask.Description;
|
|
|
|
|
|
_reminderDate = existingTask.ReminderDate;
|
|
|
|
|
|
_isRecurring = existingTask.IsRecurring;
|
|
|
|
|
|
_selectedRecurrenceIndex = (int)existingTask.RecurrenceType;
|
Upcoming view, search/filters, lead reminders, birthdays, folder colors, ICS, sound, undo
- Upcoming: all folders grouped by overdue/today/tomorrow/7 days/later/done
- Search (Ctrl+F) + All/Today/Overdue filters + hide done (persisted)
- Lead reminder 1/2/3 days or 1 week before; birth year shows age
- Several due reminders are combined into one balloon
- Folder colors and reordering (drag, context menu)
- iCalendar export with RRULE and VALARM
- Generated reminder chime (ComfyUI / Stable Audio), can be turned off
- Undo snackbar for deleted tasks/folders (Ctrl+Z), Ctrl+N, Del, Esc
- 41 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 15:03:36 +01:00
|
|
|
|
_selectedLeadIndex = Math.Max(0, Array.IndexOf(LeadOptions, existingTask.LeadDays));
|
|
|
|
|
|
_birthYearText = existingTask.BirthYear?.ToString() ?? "";
|
2026-11-25 13:44:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SaveCommand = new RelayCommand(Save, CanSave);
|
|
|
|
|
|
CancelCommand = new RelayCommand(Cancel);
|
|
|
|
|
|
SetTomorrowCommand = new RelayCommand(SetTomorrow);
|
|
|
|
|
|
SetNextWeekCommand = new RelayCommand(SetNextWeek);
|
|
|
|
|
|
SetNextMonthCommand = new RelayCommand(SetNextMonth);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UpdateHourMinuteIndices()
|
|
|
|
|
|
{
|
|
|
|
|
|
OnPropertyChanged(nameof(SelectedHourIndex));
|
|
|
|
|
|
OnPropertyChanged(nameof(SelectedMinuteIndex));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-29 14:42:16 +01:00
|
|
|
|
private bool CanSave() => !string.IsNullOrWhiteSpace(Name) &&
|
2026-11-29 15:06:19 +01:00
|
|
|
|
(IsAnniversary ? TryBirthday(out _, out _) : !BirthYearError);
|
2026-11-25 13:44:02 +01:00
|
|
|
|
|
|
|
|
|
|
private void ValidateInput()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(Name))
|
|
|
|
|
|
{
|
|
|
|
|
|
ErrorMessage = _localizationService.GetString("NameRequired");
|
|
|
|
|
|
HasError = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ErrorMessage = "";
|
|
|
|
|
|
HasError = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetTomorrow()
|
|
|
|
|
|
{
|
|
|
|
|
|
ReminderDate = DateTime.Now.Date.AddDays(1).AddHours(9);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetNextWeek()
|
|
|
|
|
|
{
|
|
|
|
|
|
var nextWeek = DateTime.Now.Date.AddDays(7);
|
|
|
|
|
|
var dayOfWeek = nextWeek.DayOfWeek;
|
|
|
|
|
|
if (dayOfWeek == DayOfWeek.Saturday) nextWeek = nextWeek.AddDays(2);
|
|
|
|
|
|
else if (dayOfWeek == DayOfWeek.Sunday) nextWeek = nextWeek.AddDays(1);
|
|
|
|
|
|
ReminderDate = nextWeek.AddHours(9);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetNextMonth()
|
|
|
|
|
|
{
|
|
|
|
|
|
var nextMonth = DateTime.Now.Date.AddMonths(1);
|
|
|
|
|
|
ReminderDate = new DateTime(nextMonth.Year, nextMonth.Month, 1).AddHours(9);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Save()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!CanSave()) return;
|
|
|
|
|
|
|
2026-11-29 15:06:19 +01:00
|
|
|
|
if (IsAnniversary && TryBirthday(out var nextBirthday, out var birthYear))
|
2026-11-29 14:42:16 +01:00
|
|
|
|
{
|
|
|
|
|
|
var lead = LeadOptions[SelectedLeadIndex];
|
|
|
|
|
|
// Editing on the birthday itself after it was already reminded: keep next year's date.
|
|
|
|
|
|
if (!_isNewTask && nextBirthday <= DateTime.Now && _originalTask.ReminderDate > DateTime.Now)
|
|
|
|
|
|
nextBirthday = nextBirthday.AddYears(1);
|
|
|
|
|
|
if (_isNewTask || _originalTask.ReminderDate != nextBirthday || _originalTask.LeadDays != lead)
|
|
|
|
|
|
_originalTask.IsPreNotified = false;
|
2026-11-29 15:06:19 +01:00
|
|
|
|
_originalTask.IsAnniversary = true;
|
|
|
|
|
|
_originalTask.CategoryId = SelectedCategory?.Id ?? Category.BirthdayId;
|
2026-11-29 14:42:16 +01:00
|
|
|
|
_originalTask.Name = Name.Trim();
|
|
|
|
|
|
_originalTask.Description = Description?.Trim() ?? "";
|
|
|
|
|
|
_originalTask.IsRecurring = true;
|
|
|
|
|
|
_originalTask.RecurrenceType = RecurrenceType.Yearly;
|
|
|
|
|
|
_originalTask.BirthYear = birthYear;
|
|
|
|
|
|
_originalTask.LeadDays = lead;
|
|
|
|
|
|
_originalTask.ReminderDate = nextBirthday;
|
|
|
|
|
|
_originalTask.IsNotified = false;
|
|
|
|
|
|
RequestClose?.Invoke(this, true);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-11-29 15:06:19 +01:00
|
|
|
|
_originalTask.IsAnniversary = false;
|
2026-11-29 14:42:16 +01:00
|
|
|
|
|
Upcoming view, search/filters, lead reminders, birthdays, folder colors, ICS, sound, undo
- Upcoming: all folders grouped by overdue/today/tomorrow/7 days/later/done
- Search (Ctrl+F) + All/Today/Overdue filters + hide done (persisted)
- Lead reminder 1/2/3 days or 1 week before; birth year shows age
- Several due reminders are combined into one balloon
- Folder colors and reordering (drag, context menu)
- iCalendar export with RRULE and VALARM
- Generated reminder chime (ComfyUI / Stable Audio), can be turned off
- Undo snackbar for deleted tasks/folders (Ctrl+Z), Ctrl+N, Del, Esc
- 41 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 15:03:36 +01:00
|
|
|
|
var leadDays = LeadOptions[SelectedLeadIndex];
|
|
|
|
|
|
bool timingChanged = _originalTask.ReminderDate != ReminderDate || _originalTask.LeadDays != leadDays;
|
|
|
|
|
|
_originalTask.LeadDays = leadDays;
|
|
|
|
|
|
_originalTask.BirthYear = IsYearly ? ParsedBirthYear : null;
|
|
|
|
|
|
if (timingChanged || _isNewTask) _originalTask.IsPreNotified = false;
|
|
|
|
|
|
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
_originalTask.Name = Name.Trim();
|
|
|
|
|
|
_originalTask.Description = Description?.Trim() ?? "";
|
2026-11-25 13:44:02 +01:00
|
|
|
|
_originalTask.IsRecurring = IsRecurring;
|
|
|
|
|
|
_originalTask.RecurrenceType = (RecurrenceType)SelectedRecurrenceIndex;
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
_originalTask.ReminderDate = ReminderDate;
|
|
|
|
|
|
// A recurring start date in the past would fire at once – move it to the next occurrence.
|
|
|
|
|
|
if (IsRecurring && ReminderDate <= DateTime.Now)
|
|
|
|
|
|
_originalTask.ReminderDate = _originalTask.GetNextOccurrence();
|
|
|
|
|
|
_originalTask.IsNotified = false;
|
2026-11-25 13:44:02 +01:00
|
|
|
|
RequestClose?.Invoke(this, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Cancel()
|
|
|
|
|
|
{
|
|
|
|
|
|
RequestClose?.Invoke(this, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|