- 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>
52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
#nullable enable
|
||
using System;
|
||
using System.Windows.Forms;
|
||
|
||
namespace ReminderOrganizer.Services
|
||
{
|
||
public class NotificationService : INotificationService
|
||
{
|
||
private readonly object _lock = new();
|
||
|
||
public static NotifyIcon? SharedTrayIcon { get; set; }
|
||
|
||
public void ShowNotification(string title, string message)
|
||
{
|
||
try
|
||
{
|
||
System.Diagnostics.Debug.WriteLine($"[NotificationService] ShowNotification: {title} - {message}");
|
||
System.Diagnostics.Debug.WriteLine($"[NotificationService] SharedTrayIcon is null: {SharedTrayIcon == null}");
|
||
ShowBalloonTip(title, message);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
System.Diagnostics.Debug.WriteLine($"[NotificationService] Error: {ex.Message}");
|
||
}
|
||
}
|
||
|
||
private void ShowBalloonTip(string title, string message)
|
||
{
|
||
lock (_lock)
|
||
{
|
||
if (SharedTrayIcon != null)
|
||
{
|
||
// ShowBalloonTip throws on empty text – tasks without description would never notify.
|
||
SharedTrayIcon.BalloonTipTitle = string.IsNullOrWhiteSpace(title) ? "Reminder Organizer" : title;
|
||
SharedTrayIcon.BalloonTipText = string.IsNullOrWhiteSpace(message) ? " " : message;
|
||
SharedTrayIcon.BalloonTipIcon = ToolTipIcon.Info;
|
||
SharedTrayIcon.ShowBalloonTip(5000);
|
||
System.Diagnostics.Debug.WriteLine("[NotificationService] BalloonTip shown!");
|
||
}
|
||
else
|
||
{
|
||
System.Diagnostics.Debug.WriteLine("[NotificationService] SharedTrayIcon is null, cannot show balloon tip!");
|
||
}
|
||
}
|
||
}
|
||
|
||
public void Dispose()
|
||
{
|
||
}
|
||
}
|
||
}
|