diff --git a/App.xaml b/App.xaml index 58d8355..95fa682 100644 --- a/App.xaml +++ b/App.xaml @@ -1,18 +1,25 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/App.xaml.cs b/App.xaml.cs index ef0e78b..df21cb3 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -41,6 +41,13 @@ namespace ReminderOrganizer private System.Threading.Mutex? _singleInstance; + /// Really exit (tray menu / "Exit"): the main window otherwise only hides to the tray. + public static void Quit() + { + (Current.MainWindow as MainWindow)?.AllowClose(); + Current.Shutdown(); + } + protected override void OnExit(ExitEventArgs e) { (MainWindow as MainWindow)?.OnAppExit(); diff --git a/Assets/app.ico b/Assets/app.ico index f8be00d..750cd87 100644 Binary files a/Assets/app.ico and b/Assets/app.ico differ diff --git a/Assets/app.png b/Assets/app.png index 6365566..a5006d3 100644 Binary files a/Assets/app.png and b/Assets/app.png differ diff --git a/CLAUDE.md b/CLAUDE.md index b9e257c..1016fb8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,9 +12,14 @@ services through `ServiceLocator` (Microsoft.Extensions.DependencyInjection). - Anniversaries: `ReminderTask.IsAnniversary` (stored as JSON `"IsBirthday"` for older files) + `CategoryId` → `Models/Category.cs` (presets birthday/wedding/jubilee/memorial + own ones, text with `{0}`/`{o}`). Filter/sort/group rules are in `Core/TaskQuery.cs` (pure, tested). -- `Core/Theme.cs`: the only light/dark palette, used by MainWindow and the dialogs (`Theme.Apply(Resources, dark)`). -- `MainWindow.xaml`: custom chrome (WindowStyle=None). Icons are Segoe MDL2 glyphs or Path geometry, **no emojis** - (they don't follow the theme). +- `Core/Theme.cs`: the only light/dark palette (neutral greys + one accent), applied to **Application.Resources** + (so context menus, tooltips and dialogs follow). Theme mode system/light/dark in settings. +- `Themes/Controls.xaml`: all shared styles (menus, tooltips, scrollbars, combo box, date picker, check box, + buttons `PrimaryButton`/`SubtleButton`/`IconButton`, `Segment`, `ToggleSwitch`, `DoneCheck`). Change looks here, not per window. +- `MainWindow.xaml`: `WindowChrome` (native resize/snap/shadow, DWM rounded corners), no menu bar: settings gear + → `SettingsWindow`. Row actions appear on hover. Icons are Segoe Fluent/MDL2 glyphs or Path geometry, **no emojis**. +- Design rules: no glow, no scaling on hover, animations only 120–200 ms and only where they carry meaning + (dialog open, snackbar, group chevron, toggle knob, window fade-in). - `Tests/`: xUnit project, excluded from the app csproj via `Compile Remove`. ## Rules @@ -25,6 +30,9 @@ services through `ServiceLocator` (Microsoft.Extensions.DependencyInjection). - Run `dotnet test Tests\ReminderOrganizer.Tests.csproj` before each release. `release.bat` does this automatically. ## Graphics +App icon is drawn, not generated: `py -3.12 tools\make_icon.py ` (rounded square + Fluent bell), then +save as `Assets\app.png` (256) and `Assets\app.ico` (16–256). Older ComfyUI notes below. + `sprite-generator\` = ComfyGen template (`_Tools\ComfyGen`). App icon: `gen generate icon` → `gen adopt --size 512 icon` → convert `Assets\Sprites\icon.png` to `Assets\app.ico` (Pillow, sizes 16–256). The csproj and MainWindow pick up `Assets\app.ico` automatically (window, tray, exe). Without the file, the default icon is used. diff --git a/CategoryWindow.xaml b/CategoryWindow.xaml index 28f00bd..ca16a02 100644 --- a/CategoryWindow.xaml +++ b/CategoryWindow.xaml @@ -59,7 +59,7 @@ - + @@ -72,14 +72,13 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - Discord - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 3482981..99d8cbc 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -1,6 +1,7 @@ -#nullable enable +#nullable enable using System; using System.ComponentModel; +using System.Runtime.InteropServices; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -31,11 +32,13 @@ namespace ReminderOrganizer ?? throw new InvalidOperationException("MainViewModel not found"); DataContext = _viewModel; - _viewModel.ThemeChanged += (_, dark) => ApplyTheme(dark, animate: true); + _viewModel.ThemeChanged += (_, dark) => Theme.Apply(Application.Current.Resources, dark); _viewModel.EditTaskRequested += OnEditTaskRequested; _viewModel.PropertyChanged += OnViewModelPropertyChanged; + Microsoft.Win32.SystemEvents.UserPreferenceChanged += OnUserPreferenceChanged; TrySetWindowIcon(); + SourceInitialized += (_, _) => UseRoundedCorners(); Loaded += async (_, _) => await InitializeOnceAsync(); StateChanged += MainWindow_StateChanged; } @@ -53,17 +56,71 @@ namespace ReminderOrganizer _initialized = true; SetupTrayIcon(); await _viewModel.InitializeAsync(); - ApplyTheme(_viewModel.IsDarkMode, animate: false); + Theme.Apply(Application.Current.Resources, _viewModel.IsDarkMode); + RestoreWindowPlacement(); SyncTreeSelection(); + + // The window starts invisible so the user never sees the default theme flash. + BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(160))); } public void OnAppExit() { if (!_initialized) return; + RememberWindowPlacement(); + Microsoft.Win32.SystemEvents.UserPreferenceChanged -= OnUserPreferenceChanged; _viewModel.Cleanup(); _viewModel.FlushSave(); } + private void OnUserPreferenceChanged(object? sender, Microsoft.Win32.UserPreferenceChangedEventArgs e) + { + if (e.Category == Microsoft.Win32.UserPreferenceCategory.General) + Dispatcher.BeginInvoke(_viewModel.OnSystemThemeChanged); + } + + // ---------- window placement ---------- + + private void RestoreWindowPlacement() + { + if (_viewModel.SavedWindowBounds is Rect r) + { + // only if the saved rectangle is still (mostly) on a screen + var screen = new Rect(SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop, + SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight); + if (screen.IntersectsWith(new Rect(r.Left + 40, r.Top, Math.Max(1, r.Width - 80), 40))) + { + WindowStartupLocation = WindowStartupLocation.Manual; + Left = r.Left; + Top = r.Top; + Width = Math.Max(MinWidth, r.Width); + Height = Math.Max(MinHeight, r.Height); + } + } + if (_viewModel.SavedWindowMaximized) WindowState = WindowState.Maximized; + } + + private void RememberWindowPlacement() + { + var bounds = WindowState == WindowState.Normal ? new Rect(Left, Top, Width, Height) : RestoreBounds; + if (bounds.Width > 0 && bounds.Height > 0) + _viewModel.RememberWindow(bounds, WindowState == WindowState.Maximized); + } + + // Windows 11: native rounded corners for our custom-chrome window. + [DllImport("dwmapi.dll")] + private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int value, int size); + + private void UseRoundedCorners() + { + try + { + int round = 2; // DWMWCP_ROUND + DwmSetWindowAttribute(new WindowInteropHelper(this).Handle, 33, ref round, sizeof(int)); + } + catch { /* older Windows */ } + } + private void TrySetWindowIcon() { try @@ -72,7 +129,7 @@ namespace ReminderOrganizer } catch { - // no Assets\app.ico yet – Windows default icon + // no Assets\app.ico – Windows default icon } } @@ -103,14 +160,10 @@ namespace ReminderOrganizer }, System.Windows.Threading.DispatcherPriority.Loaded); } - private void UpcomingEntry_Click(object sender, MouseButtonEventArgs e) - { - _viewModel.ShowUpcomingCommand.Execute(null); - } - private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { bool ctrl = (Keyboard.Modifiers & ModifierKeys.Control) != 0; + bool typing = Keyboard.FocusedElement is TextBox; if (ctrl && e.Key == Key.N) { if (_viewModel.AddTaskCommand.CanExecute(null)) _viewModel.AddTaskCommand.Execute(null); @@ -122,23 +175,38 @@ namespace ReminderOrganizer SearchBox.SelectAll(); e.Handled = true; } + else if (ctrl && e.Key == Key.OemComma) + { + _viewModel.OpenSettingsCommand.Execute(null); + e.Handled = true; + } else if (e.Key == Key.Escape && (SearchBox.IsKeyboardFocusWithin || _viewModel.SearchText.Length > 0)) { _viewModel.ClearSearchCommand.Execute(null); FolderTree.Focus(); e.Handled = true; } - else if (ctrl && e.Key == Key.Z && _viewModel.IsUndoVisible) + else if (e.Key == Key.Escape && _viewModel.SelectedTask != null) + { + _viewModel.SelectedTask = null; + e.Handled = true; + } + else if (ctrl && e.Key == Key.Z && _viewModel.IsUndoVisible && !typing) { _viewModel.UndoCommand.Execute(null); e.Handled = true; } - else if (e.Key == Key.Delete && !SearchBox.IsKeyboardFocusWithin && _viewModel.SelectedTask != null) + else if (e.Key == Key.Delete && !typing && _viewModel.SelectedTask != null) { _viewModel.DeleteTaskCommand.Execute(_viewModel.SelectedTask); _viewModel.SelectedTask = null; e.Handled = true; } + else if (e.Key == Key.Enter && !typing && _viewModel.SelectedTask != null) + { + _viewModel.EditTaskCommand.Execute(_viewModel.SelectedTask); + e.Handled = true; + } } private void OnEditTaskRequested(object? sender, ReminderTask? task) @@ -152,29 +220,19 @@ namespace ReminderOrganizer } } - private void ApplyTheme(bool isDarkMode, bool animate) - { - Theme.Apply(Resources, isDarkMode); - if (!animate || ThemeTransitionOverlay == null) return; - - var overlay = ThemeTransitionOverlay; - overlay.Background = new SolidColorBrush(isDarkMode ? Color.FromRgb(0x12, 0x12, 0x18) : Color.FromRgb(0xF1, 0xF5, 0xF9)); - var fadeIn = new DoubleAnimation(0, 0.3, TimeSpan.FromMilliseconds(100)); - var fadeOut = new DoubleAnimation(0.3, 0, TimeSpan.FromMilliseconds(200)); - fadeIn.Completed += (s, args) => overlay.BeginAnimation(OpacityProperty, fadeOut); - overlay.BeginAnimation(OpacityProperty, fadeIn); - } + // ---------- caption ---------- private void MainWindow_StateChanged(object? sender, EventArgs e) { - if (WindowState == WindowState.Minimized) - { - HideToTray(); - } + // With WindowChrome a maximized window reaches past the screen edge by the resize border. + RootGrid.Margin = WindowState == WindowState.Maximized ? new Thickness(7) : new Thickness(0); + MaximizeButton.Content = WindowState == WindowState.Maximized ? "\uE923" : "\uE922"; + MaximizeButton.ToolTip = _viewModel.L(WindowState == WindowState.Maximized ? "Restore" : "Maximize"); } private void HideToTray() { + RememberWindowPlacement(); Hide(); if (!_trayHintShown && _notifyIcon != null) { @@ -183,50 +241,30 @@ namespace ReminderOrganizer } } - private void TitleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) - { - if (e.ClickCount == 2) - { - MaximizeRestore(); - } - else if (e.LeftButton == MouseButtonState.Pressed) - { - DragMove(); - } - } - - private void MinimizeButton_Click(object sender, RoutedEventArgs e) - { - WindowState = WindowState.Minimized; - } + private void MinimizeButton_Click(object sender, RoutedEventArgs e) => SystemCommands.MinimizeWindow(this); private void MaximizeButton_Click(object sender, RoutedEventArgs e) { - MaximizeRestore(); + if (WindowState == WindowState.Maximized) SystemCommands.RestoreWindow(this); + else SystemCommands.MaximizeWindow(this); } - private void MaximizeRestore() + /// The window's X keeps the app running in the tray (reminders need it); "Exit" is in the tray menu. + private void CloseButton_Click(object sender, RoutedEventArgs e) => HideToTray(); + + protected override void OnClosing(CancelEventArgs e) { - if (WindowState == WindowState.Maximized) + // Alt+F4 / taskbar "close window": same as the X button unless the app is shutting down. + if (!_shuttingDown) { - WindowState = WindowState.Normal; - MaximizeButton.Content = ""; - } - else - { - // WindowStyle=None would cover the taskbar – limit to the work area. - MaxHeight = SystemParameters.WorkArea.Height + 8; - MaxWidth = SystemParameters.WorkArea.Width + 8; - WindowState = WindowState.Maximized; - MaximizeButton.Content = ""; + e.Cancel = true; + HideToTray(); } + base.OnClosing(e); } - private void CloseButton_Click(object sender, RoutedEventArgs e) - { - HideToTray(); - } - + private bool _shuttingDown; + public void AllowClose() => _shuttingDown = true; private void SetupTrayIcon() { System.Drawing.Icon icon = System.Drawing.SystemIcons.Information; @@ -250,8 +288,7 @@ namespace ReminderOrganizer menu.Items.Add(_viewModel.L("Open"), null, (s, e) => ShowMainWindow()); menu.Items.Add(_viewModel.L("Exit"), null, (s, e) => { - _viewModel.Cleanup(); - Application.Current.Shutdown(); + App.Quit(); }); _notifyIcon.ContextMenuStrip = menu; _notifyIcon.DoubleClick += (s, e) => ShowMainWindow(); @@ -327,42 +364,6 @@ namespace ReminderOrganizer } } - private void TaskItem_MouseEnter(object sender, MouseEventArgs e) - { - if (sender is Border border) - { - if (border.RenderTransform is ScaleTransform scaleTransform) - { - scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, new DoubleAnimation(1, 1.01, TimeSpan.FromMilliseconds(150))); - scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, new DoubleAnimation(1, 1.01, TimeSpan.FromMilliseconds(150))); - } - if (border.Effect is System.Windows.Media.Effects.DropShadowEffect effect) - { - effect.BeginAnimation(System.Windows.Media.Effects.DropShadowEffect.BlurRadiusProperty, new DoubleAnimation(15, TimeSpan.FromMilliseconds(200))); - effect.BeginAnimation(System.Windows.Media.Effects.DropShadowEffect.OpacityProperty, new DoubleAnimation(0.35, TimeSpan.FromMilliseconds(200))); - } - border.SetResourceReference(Border.BackgroundProperty, "HoverBrush"); - } - } - - private void TaskItem_MouseLeave(object sender, MouseEventArgs e) - { - if (sender is Border border) - { - if (border.RenderTransform is ScaleTransform scaleTransform) - { - scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, new DoubleAnimation(1, TimeSpan.FromMilliseconds(150))); - scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, new DoubleAnimation(1, TimeSpan.FromMilliseconds(150))); - } - if (border.Effect is System.Windows.Media.Effects.DropShadowEffect effect) - { - effect.BeginAnimation(System.Windows.Media.Effects.DropShadowEffect.BlurRadiusProperty, new DoubleAnimation(0, TimeSpan.FromMilliseconds(150))); - effect.BeginAnimation(System.Windows.Media.Effects.DropShadowEffect.OpacityProperty, new DoubleAnimation(0, TimeSpan.FromMilliseconds(150))); - } - border.Background = Brushes.Transparent; - } - } - private void TaskItem_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed || sender is not FrameworkElement element || element.DataContext is not ReminderTask task) @@ -376,17 +377,6 @@ namespace ReminderOrganizer DragDrop.DoDragDrop(element, task, DragDropEffects.Move); } - // kept for styles that still reference them - private void SecondaryButton_MouseEnter(object sender, MouseEventArgs e) - { - if (sender is Border border) border.SetResourceReference(Border.BackgroundProperty, "HoverBrush"); - } - - private void SecondaryButton_MouseLeave(object sender, MouseEventArgs e) - { - if (sender is Border border) border.Background = Brushes.Transparent; - } - private void TreeView_DragOver(object sender, DragEventArgs e) { e.Effects = e.Data.GetDataPresent(typeof(ReminderTask)) ? DragDropEffects.Move : DragDropEffects.None; @@ -436,4 +426,4 @@ namespace ReminderOrganizer e.Handled = true; } } -} +} \ No newline at end of file diff --git a/Models/ReminderModels.cs b/Models/ReminderModels.cs index 0365607..140822e 100644 --- a/Models/ReminderModels.cs +++ b/Models/ReminderModels.cs @@ -138,6 +138,11 @@ namespace ReminderOrganizer.Models /// Set once by the app: culture for month names, relative-date formatter. public static Func? DisplayCulture { get; set; } public static Func? RelativeFormatter { get; set; } + public static Func? RecurrenceFormatter { get; set; } + + /// "Weekly" etc. for recurring appointments (empty for one-off tasks and anniversaries). + [System.Text.Json.Serialization.JsonIgnore] + public string RecurrenceText => IsRecurring && !IsAnniversary ? RecurrenceFormatter?.Invoke(RecurrenceType) ?? RecurrenceType.ToString() : ""; /// "19. März" for birthdays, otherwise "19.03.2027 09:00". [System.Text.Json.Serialization.JsonIgnore] @@ -329,6 +334,16 @@ namespace ReminderOrganizer.Models public bool? IsDarkMode { get; set; } public bool PlaySound { get; set; } = true; public bool HideDone { get; set; } + /// "system", "light", "dark" (empty = from IsDarkMode of older files). + public string ThemeMode { get; set; } = ""; + + /// Last window position/size (device-independent pixels). + public double? WindowLeft { get; set; } + public double? WindowTop { get; set; } + public double? WindowWidth { get; set; } + public double? WindowHeight { get; set; } + public bool WindowMaximized { get; set; } + /// "list", "compact" or "cards". public string ViewMode { get; set; } = "list"; /// Group the list by month (collapsible). diff --git a/SettingsWindow.xaml b/SettingsWindow.xaml new file mode 100644 index 0000000..5f2e9b6 --- /dev/null +++ b/SettingsWindow.xaml @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +