Skip to content

Add dark mode - #12

Open
KamilDev wants to merge 1 commit into
PolarGoose:mainfrom
KamilDev:dark-mode
Open

Add dark mode#12
KamilDev wants to merge 1 commit into
PolarGoose:mainfrom
KamilDev:dark-mode

Conversation

@KamilDev

@KamilDev KamilDev commented Sep 2, 2026

Copy link
Copy Markdown

Closes #7.

What

The app follows the Windows "Choose your default app mode" setting (HKCU\...\Themes\Personalize\AppsUseLightTheme) and switches live when the setting changes (SystemEvents.UserPreferenceChanged).

  • Gui/Theme/Light.xaml, Dark.xaml: brush palettes. They also override the SystemColors.Window/WindowText/Control/ControlText/GrayText resource keys, so stock WPF styles (Window, Label, ScrollViewer corner) pick up the theme without custom templates.
  • Gui/Theme/Controls.xaml: templates for Button/ToggleButton, TextBox, ListBoxItem, ScrollBar, ContextMenu/MenuItem, ToolTip; brush setters for ListBox, ProgressBar. The stock templates hard-code light colors in their triggers, which is why they are redefined.
  • Icons.xaml: the grey #212121 fills and the Refresh blue now reference theme brushes (IconBrush, IconAccentBrush). Shield and error icon colors are unchanged.
  • ThemeManager: reads the setting, swaps the brush dictionary, applies DWMWA_USE_IMMERSIVE_DARK_MODE (20, falling back to 19 on Windows 10 before 20H1) to the title bar.
  • WindowBackgroundPainter: removes the white flash on startup. WPF answers WM_ERASEBKGND without painting and presents its first frame asynchronously, so DWM shows the window's untouched white surface from the moment it becomes visible until that frame arrives (~40 ms on my machine, several frames). The hook GDI-fills the client area with the theme color on the first message that arrives while the window is visible and on every erase. Same approach Chromium/Electron use for their startup background.
  • ErrorDialog is now a WPF window instead of the Win32 MessageBox, which has no dark mode. Same ErrorDialog.Show(text) API.

Tested

Windows 11, both modes, live switching while the app is open: toolbar buttons (hover/pressed), process list selection (active/inactive), context menu, tooltips, scrollbar, progress bar, result text, error dialog (from startup with a nonexistent path and after startup), process termination.

…uding live switching. Theme all controls, icons and the title bar. Paint the theme background before WPF's first frame so the window does not flash white on startup. Replace the Win32 error MessageBox with a themed WPF dialog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dark mode??

1 participant