Snooze notifications, morning summary, ICS import, data folder sync
- Windows toast notifications with snooze (10 min / 1 h / tomorrow) and done buttons; balloon fallback; works when Windows starts the app - Recurring entries snooze via SnoozedUntil without moving their date; lead reminders keep the real date - Morning summary once a day from a chosen hour (pure DailySummary) - iCalendar import incl. Google birthday calendar, folded lines, UTC, alarms, own export round trip, duplicates skipped by UID, undo - Data folder selectable (location.json pointer), file watcher reloads changes from another PC (own writes ignored) - Themed date picker calendar, WPF tray menu, arrow/Home/End/Space keys - 90 tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -62,6 +63,10 @@ namespace ReminderOrganizer
|
||||
|
||||
// The window starts invisible so the user never sees the default theme flash.
|
||||
BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(160)));
|
||||
|
||||
_ready = true;
|
||||
foreach (var pending in _pendingToasts.ToArray()) HandleToast(pending);
|
||||
_pendingToasts.Clear();
|
||||
}
|
||||
|
||||
public void OnAppExit()
|
||||
@@ -207,6 +212,48 @@ namespace ReminderOrganizer
|
||||
_viewModel.EditTaskCommand.Execute(_viewModel.SelectedTask);
|
||||
e.Handled = true;
|
||||
}
|
||||
// list navigation (the folder tree keeps its own arrow keys)
|
||||
else if (!typing && !FolderTree.IsKeyboardFocusWithin && e.Key is Key.Down or Key.Up or Key.Home or Key.End)
|
||||
{
|
||||
MoveSelection(e.Key);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (!typing && e.Key == Key.Space && _viewModel.SelectedTask is { } sel)
|
||||
{
|
||||
sel.IsNotified = !sel.IsNotified;
|
||||
_viewModel.ToggleDoneCommand.Execute(sel);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Arrow keys move the selection in display order (across groups) and keep it visible.</summary>
|
||||
private void MoveSelection(Key key)
|
||||
{
|
||||
var items = _viewModel.TasksView?.Cast<ReminderTask>().ToList();
|
||||
if (items == null || items.Count == 0) return;
|
||||
int idx = _viewModel.SelectedTask is { } cur ? items.IndexOf(cur) : -1;
|
||||
int next = key switch
|
||||
{
|
||||
Key.Home => 0,
|
||||
Key.End => items.Count - 1,
|
||||
Key.Down => idx < 0 ? 0 : Math.Min(items.Count - 1, idx + 1),
|
||||
_ => idx < 0 ? items.Count - 1 : Math.Max(0, idx - 1)
|
||||
};
|
||||
_viewModel.SelectedTask = items[next];
|
||||
Dispatcher.BeginInvoke(() => FindContainer(ListScroll, items[next])?.BringIntoView(),
|
||||
System.Windows.Threading.DispatcherPriority.Loaded);
|
||||
}
|
||||
|
||||
/// <summary>Rows sit inside group containers, so ItemContainerGenerator can't find them – search the tree.</summary>
|
||||
private static FrameworkElement? FindContainer(DependencyObject root, object item)
|
||||
{
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(root, i);
|
||||
if (child is ContentPresenter cp && ReferenceEquals(cp.Content, item)) return cp;
|
||||
if (FindContainer(child, item) is { } found) return found;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void OnEditTaskRequested(object? sender, ReminderTask? task)
|
||||
@@ -284,17 +331,71 @@ namespace ReminderOrganizer
|
||||
|
||||
Services.NotificationService.SharedTrayIcon = _notifyIcon;
|
||||
|
||||
var menu = new System.Windows.Forms.ContextMenuStrip();
|
||||
menu.Items.Add(_viewModel.L("Open"), null, (s, e) => ShowMainWindow());
|
||||
menu.Items.Add(_viewModel.L("Exit"), null, (s, e) =>
|
||||
// WPF menu instead of the WinForms one, so it uses the app's theme styles.
|
||||
_notifyIcon.MouseUp += (s, e) =>
|
||||
{
|
||||
App.Quit();
|
||||
});
|
||||
_notifyIcon.ContextMenuStrip = menu;
|
||||
if (e.Button == System.Windows.Forms.MouseButtons.Right) ShowTrayMenu();
|
||||
};
|
||||
_notifyIcon.DoubleClick += (s, e) => ShowMainWindow();
|
||||
_notifyIcon.BalloonTipClicked += (s, e) => ShowMainWindow();
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
private void ShowTrayMenu()
|
||||
{
|
||||
MenuItem Item(string key, string glyph, Action onClick)
|
||||
{
|
||||
var mi = new MenuItem
|
||||
{
|
||||
Header = _viewModel.L(key),
|
||||
Icon = new TextBlock { Text = glyph, FontFamily = (FontFamily)FindResource("IconFont"), FontSize = 12 }
|
||||
};
|
||||
mi.Click += (_, _) => onClick();
|
||||
return mi;
|
||||
}
|
||||
|
||||
var menu = new ContextMenu { Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint };
|
||||
menu.Items.Add(Item("Open", "", ShowMainWindow));
|
||||
menu.Items.Add(Item("NewEntry", "", () =>
|
||||
{
|
||||
ShowMainWindow();
|
||||
if (_viewModel.AddTaskCommand.CanExecute(null)) _viewModel.AddTaskCommand.Execute(null);
|
||||
}));
|
||||
var sound = Item("PlaySound", "", () => _viewModel.PlaySound = !_viewModel.PlaySound);
|
||||
sound.IsChecked = _viewModel.PlaySound;
|
||||
sound.Icon = null; // the check mark shows the state
|
||||
menu.Items.Add(sound);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(Item("Exit", "", App.Quit));
|
||||
|
||||
menu.IsOpen = true;
|
||||
// A popup from the tray only closes on outside clicks if it owns the foreground.
|
||||
if (PresentationSource.FromVisual(menu) is HwndSource src) SetForegroundWindow(src.Handle);
|
||||
}
|
||||
|
||||
// ---------- Windows notification buttons ----------
|
||||
|
||||
private readonly System.Collections.Generic.List<Microsoft.Toolkit.Uwp.Notifications.ToastArguments> _pendingToasts = new();
|
||||
private bool _ready;
|
||||
|
||||
/// <summary>Snooze / done / open from a toast. Waits until the data is loaded.</summary>
|
||||
public void HandleToast(Microsoft.Toolkit.Uwp.Notifications.ToastArguments args)
|
||||
{
|
||||
if (!_ready)
|
||||
{
|
||||
_pendingToasts.Add(args);
|
||||
return;
|
||||
}
|
||||
args.TryGetValue("action", out string? action);
|
||||
args.TryGetValue("id", out string? id);
|
||||
args.TryGetValue("min", out string? minutes);
|
||||
args.TryGetValue("lead", out string? lead);
|
||||
_viewModel.HandleToastAction(action ?? "open", id, minutes, lead == "1");
|
||||
if ((action ?? "open") == "open") ShowMainWindow();
|
||||
}
|
||||
|
||||
private void ShowMainWindow()
|
||||
{
|
||||
Show();
|
||||
|
||||
Reference in New Issue
Block a user