Professional redesign: native window, settings, calmer UI
- WindowChrome: resizable, snap layouts, native shadow, DWM rounded corners; size/position remembered; fade-in after load (no theme flash) - Menu bar replaced by a settings window (theme system/light/dark, language, sound, autostart, categories, data, shortcuts, about) - Shared styles in Themes/Controls.xaml; neutral palette with one accent applied to Application.Resources (context menus/tooltips themed) - Rows: To-Do style check left, title + details, relative date right, actions on hover, visible selection (Enter edits, Del deletes) - No glow/scale effects; subtle animations (dialogs, snackbar, chevrons) - Checking a recurring task moves it to the next date (with undo) - Themed combo box, date picker, check box; neutral dialog headers - New flat app icon (tools/make_icon.py) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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()
|
||||
/// <summary>The window's X keeps the app running in the tray (reminders need it); "Exit" is in the tray menu.</summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user