Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 22, 2025

Extends existing context menu theme support to the main window. All UI elements now automatically detect and adapt to Windows light/dark theme on startup and respond to runtime theme changes.

Implementation

Theme Detection

  • Reads HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme
  • Monitors SystemEvents.UserPreferenceChanged for runtime changes
  • Defaults to dark theme if registry unavailable

Theme Application

// Dark mode constants with hex documentation
private static readonly Color DarkFormBackground = Color.FromArgb(32, 32, 32);        // #202020
private static readonly Color DarkGroupBoxBackground = Color.FromArgb(45, 45, 45);    // #2D2D2D
private static readonly Color DarkControlBackground = Color.FromArgb(55, 55, 55);     // #373737
// ... applied to Form, GroupBox, TextBox, Button, CheckBox, Label, NumericUpDown, TrackBar

Optimizations

  • Change detection prevents redundant updates when theme hasn't changed
  • Thread-safe cross-thread invocation
  • Event cleanup with error handling in Dispose()

Files Changed

  • MainForm.cs (+179): Theme methods, constants, event handling
  • MainForm.Designer.cs (+7): Removed hardcoded colors, added cleanup
  • README.md (+1): Updated feature description
Original prompt

This section details on the original issue you should resolve

<issue_title>Modernize UI to Support Host OS Theme Mode in Main Window</issue_title>
<issue_description>### Enhancement Request

To improve user experience and keep GateSwitchWay visually aligned with current desktop standards, update the main UI window to detect and support the host operating system's theme mode (light/dark).

Desired Actions:

  • Refactor UI so it automatically switches between light and dark modes based on the OS settings.
  • Ensure all UI elements (backgrounds, text, icons, etc.) adapt properly to both modes.
  • Provide fallback or manual mode toggle if automatic detection fails.
  • Test across supported platforms for consistency.

Motivation

This modernization enhances accessibility and usability while meeting the expectations of users on modern OS platforms.
</issue_description>

<agent_instructions>create new fork first, when fork become mature and pass all tests, will make decision to submit PR</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 8 commits November 22, 2025 18:01
Co-authored-by: lsd-techno <6795932+lsd-techno@users.noreply.github.com>
Co-authored-by: lsd-techno <6795932+lsd-techno@users.noreply.github.com>
Co-authored-by: lsd-techno <6795932+lsd-techno@users.noreply.github.com>
Co-authored-by: lsd-techno <6795932+lsd-techno@users.noreply.github.com>
Co-authored-by: lsd-techno <6795932+lsd-techno@users.noreply.github.com>
Co-authored-by: lsd-techno <6795932+lsd-techno@users.noreply.github.com>
Co-authored-by: lsd-techno <6795932+lsd-techno@users.noreply.github.com>
Co-authored-by: lsd-techno <6795932+lsd-techno@users.noreply.github.com>
Copilot AI changed the title [WIP] Update main UI to support host OS theme mode Add OS theme detection and automatic UI adaptation for main window Nov 22, 2025
Copilot AI requested a review from lsd-techno November 22, 2025 18:17
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.

Modernize UI to Support Host OS Theme Mode in Main Window

2 participants