2026-11-25 13:44:02 +01:00
|
|
|
#nullable enable
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using ReminderOrganizer.Core;
|
|
|
|
|
|
|
|
|
|
namespace ReminderOrganizer.Models
|
|
|
|
|
{
|
|
|
|
|
public class ReminderTask : ViewModelBase
|
|
|
|
|
{
|
|
|
|
|
private string _id = Guid.NewGuid().ToString();
|
|
|
|
|
private string _name = "New Task";
|
|
|
|
|
private string _description = "";
|
|
|
|
|
private DateTime _reminderDate = DateTime.Now.AddHours(1);
|
|
|
|
|
private bool _isNotified = false;
|
|
|
|
|
private bool _isRecurring = false;
|
|
|
|
|
private RecurrenceType _recurrenceType = RecurrenceType.Yearly;
|
|
|
|
|
|
|
|
|
|
public string Id
|
|
|
|
|
{
|
|
|
|
|
get => _id;
|
|
|
|
|
set => SetProperty(ref _id, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get => _name;
|
|
|
|
|
set => SetProperty(ref _name, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
|
|
|
|
get => _description;
|
|
|
|
|
set => SetProperty(ref _description, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DateTime ReminderDate
|
|
|
|
|
{
|
|
|
|
|
get => _reminderDate;
|
|
|
|
|
set => SetProperty(ref _reminderDate, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsNotified
|
|
|
|
|
{
|
|
|
|
|
get => _isNotified;
|
|
|
|
|
set => SetProperty(ref _isNotified, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsRecurring
|
|
|
|
|
{
|
|
|
|
|
get => _isRecurring;
|
|
|
|
|
set => SetProperty(ref _isRecurring, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RecurrenceType RecurrenceType
|
|
|
|
|
{
|
|
|
|
|
get => _recurrenceType;
|
|
|
|
|
set => SetProperty(ref _recurrenceType, value);
|
|
|
|
|
}
|
|
|
|
|
|
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 DateTime GetNextOccurrence() => GetNextOccurrence(DateTime.Now);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// First occurrence after <paramref name="now"/>. Steps are counted from the original
|
|
|
|
|
/// date, so "31 Jan monthly" gives 29 Feb, 31 Mar, 30 Apr … instead of drifting to the 28th.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTime GetNextOccurrence(DateTime now)
|
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
|
|
|
var start = ReminderDate;
|
|
|
|
|
if (start > now) return start;
|
|
|
|
|
|
|
|
|
|
// Jump close to "now" first so long gaps (app off for years) don't loop thousands of times.
|
|
|
|
|
int k = RecurrenceType switch
|
|
|
|
|
{
|
|
|
|
|
RecurrenceType.Daily => Math.Max(0, (int)((now - start).TotalDays) - 1),
|
|
|
|
|
RecurrenceType.Weekly => Math.Max(0, (int)((now - start).TotalDays / 7) - 1),
|
|
|
|
|
RecurrenceType.Monthly => Math.Max(0, (now.Year - start.Year) * 12 + now.Month - start.Month - 1),
|
|
|
|
|
_ => Math.Max(0, now.Year - start.Year - 1)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DateTime next;
|
|
|
|
|
do
|
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
|
|
|
k++;
|
2026-11-25 13:44:02 +01:00
|
|
|
next = RecurrenceType switch
|
|
|
|
|
{
|
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
|
|
|
RecurrenceType.Daily => start.AddDays(k),
|
|
|
|
|
RecurrenceType.Weekly => start.AddDays(7 * k),
|
|
|
|
|
RecurrenceType.Monthly => start.AddMonths(k),
|
|
|
|
|
_ => start.AddYears(k)
|
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
|
|
|
} while (next <= now);
|
2026-11-25 13:44:02 +01:00
|
|
|
return next;
|
|
|
|
|
}
|
|
|
|
|
|
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>
|
|
|
|
|
/// Marks every due task: one-off tasks become notified, recurring ones move to their next date.
|
|
|
|
|
/// Returns the tasks that should be shown as a notification now.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static System.Collections.Generic.List<ReminderTask> ProcessDue(System.Collections.Generic.IEnumerable<Folder> folders, DateTime now)
|
|
|
|
|
{
|
|
|
|
|
var due = new System.Collections.Generic.List<ReminderTask>();
|
|
|
|
|
foreach (var folder in folders)
|
|
|
|
|
{
|
|
|
|
|
foreach (var task in folder.Tasks)
|
|
|
|
|
{
|
|
|
|
|
if (task.IsNotified || task.ReminderDate > now) continue;
|
|
|
|
|
due.Add(task);
|
|
|
|
|
if (task.IsRecurring)
|
|
|
|
|
task.ReminderDate = task.GetNextOccurrence(now);
|
|
|
|
|
else
|
|
|
|
|
task.IsNotified = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return due;
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-25 13:44:02 +01:00
|
|
|
public ReminderTask() { }
|
|
|
|
|
|
|
|
|
|
public ReminderTask(string name, string description, DateTime reminderDate)
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
Description = description;
|
|
|
|
|
ReminderDate = reminderDate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum RecurrenceType
|
|
|
|
|
{
|
|
|
|
|
Daily,
|
|
|
|
|
Weekly,
|
|
|
|
|
Monthly,
|
|
|
|
|
Yearly
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Folder : ViewModelBase
|
|
|
|
|
{
|
|
|
|
|
private string _id = Guid.NewGuid().ToString();
|
|
|
|
|
private string _name = "New Folder";
|
|
|
|
|
private ObservableCollection<ReminderTask> _tasks = new();
|
|
|
|
|
|
|
|
|
|
public string Id
|
|
|
|
|
{
|
|
|
|
|
get => _id;
|
|
|
|
|
set => SetProperty(ref _id, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get => _name;
|
|
|
|
|
set => SetProperty(ref _name, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<ReminderTask> Tasks
|
|
|
|
|
{
|
|
|
|
|
get => _tasks;
|
|
|
|
|
set => SetProperty(ref _tasks, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Folder() { }
|
|
|
|
|
|
|
|
|
|
public Folder(string name)
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class AppData
|
|
|
|
|
{
|
|
|
|
|
public ObservableCollection<Folder> Folders { get; set; } = new();
|
2026-11-25 14:52:25 +01:00
|
|
|
/// <summary>"de"/"en"; empty = not chosen yet → Windows display language.</summary>
|
|
|
|
|
public string Language { get; set; } = "";
|
|
|
|
|
/// <summary>null = not chosen yet → Windows app theme.</summary>
|
|
|
|
|
public bool? IsDarkMode { get; set; }
|
2026-11-25 13:44:02 +01:00
|
|
|
}
|
|
|
|
|
}
|