Repository navigation
Add Light/Dark theme switching mechanism - #899
hesamkal2009 wants to merge 1 commit into
Conversation
979aea5 to
b153e76
Compare
|
Thanks @hesamkal2009! Please provide screenshots of some of the dialogs/windows in the app so we see how it looks like. |
|
My pleasure, @ErikMogensen. Sure, the Default/Light theme is intact; I just added the Dark theme. :) It's not perfect by any means, but at least it saves my eyes when I work at night in a dark room.
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Dark-theme rendering, restart argument handling, generated settings access, and control retention contain unresolved defects.
Review effort: Balanced
Findings: 4
Open (4)
What changed in this PR
Adds persistent light/dark theme selection with restart-based application.
Changes:
- Introduces centralized WinForms theme application and restoration.
- Adds theme selection, persistence, restart behavior, and themed custom rendering.
- Documents appearance options and adds parsing tests.
| File | Description |
|---|---|
ThemeManager.cs |
Implements theme state and control styling. |
DataGridViewDeleteButtonCell.cs |
Adds theme-aware rendering. |
Settings.settings |
Defines the user theme setting. |
Settings.Designer.cs |
Exposes the generated setting. |
Program.cs |
Initializes theming at startup. |
MainForm.cs |
Adds theme menu and restart flow. |
ThemeManagerTests.cs |
Tests theme parsing. |
README.md |
Documents theme usage. |
Files not reviewed (1)
- src/ServiceBusExplorer/Properties/Settings.Designer.cs: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
b153e76 to
56c5bba
Compare
|
Hi @ErikMogensen! Apologies if I shouldn't be tagging you directly—I wasn't sure who to tag, and since you kindly provided comments earlier, I thought I'd reach out to you. Sorry for any inconvenience, and thank you for your time! I wanted to follow up on this PR, as I’ve addressed the previous issues/feedback. 🙂 |
|
@hesamkal2009, this is non-paid work on my free time so sometimes it takes time. That said, thanks for providing this PR 👍🏻 . Having a dark theme would be great. I ran Claude Code on it and it had three issues with it. It is seems unlikely that any one of them would happen, but on the other hand they seem easy to fix so please fix them: The review found 3 bugs in the theme switching implementation: 🔴 CRITICAL: Unhandled exception in Process.Start (MainForm.cs:385) Process.Start() can throw multiple exception types (FileNotFoundException, Win32Exception, InvalidOperationException, OutOfMemoryException) when application restart fails. With no exception handling, if the restart fails (file not found, access denied, etc.), an unhandled exception crashes the app. The theme preference is saved but the restart won't occur, leaving users confused about whether the change took effect. 🟡 MEDIUM: Missing null check for viewToolStripMenuItem (MainForm.cs:350) The code calls viewToolStripMenuItem.DropDownItems.Insert(2, themeMenuItem) without verifying the menu item isn't null. While InitializeComponent() should initialize it, there's no defensive check. A NullReferenceException would occur if the menu structure changes or initialization fails. 🔵 LOW: GetCurrentParent() return value not null-checked (MainForm.cs:364) The code calls selectedItem.GetCurrentParent().Items without checking if GetCurrentParent() returns null. While unlikely based on WinForms guarantees, this could theoretically throw a NullReferenceException. |
Thank you, @ErikMogensen, for your feedback! I genuinely appreciate your dedication, as well as the efforts of all maintainers who help nurture free software and support the community. I apologize if my previous comment caused any inconvenience. I wanted to mention it because there isn't an "Ask for re-review" button available on this PR. I'll address the mentioned issues. |
Docs/tests: update theme docs and expand ThemeManager.ParseConfiguredMode tests to cover null/empty/casing and invalid values Theme: apply FastColoredTextBox token colors and fix config parsing (cachedMode) Theme: improve FastColoredTextBox colors for dark mode (reflection-based, best-effort) Theme: improve confirmation and restart flow; guard shown handler; cache theme config and avoid DropDown allocations Fix theme switching: handle Process.Start exceptions; null-check viewToolStripMenuItem and menu parent; prevent duplicate Theme menu insertion Theme: improve FastColoredTextBox bracket and selection colors; make PropertyGrid readable in dark mode Theme: remove invalid bracket style code that was causing compile errors - MarkerStyle does not support BackBrush property - Bracket highlighting is managed by selection color - All 117 tests passing
56c5bba to
ce4442c
Compare
|
Thanks @hesamkal2009! Happy that you compared the PRs. It is, of course, not a problem to close this PR. |







Summary
Adds light and dark theme support to Service Bus Explorer.
Changes
View > ThemewithLightandDarkoptions.Known limitation
Changing the theme currently restarts the application. This is intentional because some existing WinForms controls do not reliably repaint all of their child controls when the theme is changed dynamically.
The selected theme is persisted before the restart, so the application comes back using the newly selected theme.
A future improvement could apply the theme without restarting the application.