Add dark mode - #12
Open
KamilDev wants to merge 1 commit into
Open
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theSystemColors.Window/WindowText/Control/ControlText/GrayTextresource keys, so stock WPF styles (Window,Label,ScrollViewercorner) pick up the theme without custom templates.Gui/Theme/Controls.xaml: templates forButton/ToggleButton,TextBox,ListBoxItem,ScrollBar,ContextMenu/MenuItem,ToolTip; brush setters forListBox,ProgressBar. The stock templates hard-code light colors in their triggers, which is why they are redefined.Icons.xaml: the grey#212121fills 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, appliesDWMWA_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 answersWM_ERASEBKGNDwithout 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.ErrorDialogis now a WPF window instead of the Win32MessageBox, which has no dark mode. SameErrorDialog.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.