Skip to content

feat: improve adaptive theme detection, add seconds-level TimePicker and main-window occlusion auto-hide#56

Merged
Programmer-MrWang merged 7 commits intomainfrom
codex/refactor-timepicker-to-use-axaml-component
Apr 8, 2026
Merged

feat: improve adaptive theme detection, add seconds-level TimePicker and main-window occlusion auto-hide#56
Programmer-MrWang merged 7 commits intomainfrom
codex/refactor-timepicker-to-use-axaml-component

Conversation

@Programmer-MrWang
Copy link
Copy Markdown
Owner

Motivation

  • Provide seconds-precision UI for the "是否在某时间段" rule and move its layout to a dedicated AXAML view for better maintainability and native UX.
  • Fix incorrect color sampling that changed ClassIsland theme emphasis color and made adaptive theme switching unreliable by sampling the application window instead of the relevant screen area.
  • Implement a user-toggleable automatic occlusion detector to hide the main window when screen content covers it (to avoid showing sensitive or obstructed content).
  • Keep theme color source and emphasis color unchanged while only switching light/dark mode consistently with ClassIsland's theme mode mapping.

Description

  • Replaced inline control construction for the in-time-period rule with a new Controls/InTimePeriodRuleSettingsControl.axaml and updated Controls/InTimePeriodRuleSettingsControl.cs to load the AXAML and wire TimePicker events, enabling UseSeconds="True" and preserving hh:mm:ss settings sync.
  • Reworked Services/AdaptiveThemeSyncService.cs to sample the current screen area (top/bottom one-fifth) based on main-window vertical placement via GetWindowRect and Screen.FromRectangle, compute average luminance on an 8x grid, and map luminance to ClassIsland-compatible theme modes (0=明亮, 1=黑暗) while only switching light/dark (calling IThemeService.SetTheme(mode, null)) so emphasis/primary colors are not altered.
  • Added Services/MainWindowOcclusionAutoHideService.cs that runs every 2 seconds, captures the screen region beneath the main window, runs OCR using Windows OcrEngine to measure recognized character length, and hides/shows the main window (ShowWindow) when character count > 4.
  • Added a persistent config field AutoHideMainWindowWhenOccluded to ConfigHandlers/MainConfigData.cs and new UI controls in SettingsPage/MoreFeaturesOptionsSettingsPage.axaml plus event handler in its .axaml.cs to toggle and RefreshNow() the services.
  • Registered and lifecycle-managed the new occlusion service in Plugin.cs so it starts/stops with the plugin, and added Microsoft.Windows.SDK.Contracts to SystemTools.csproj to enable Windows OCR API usage.

Testing

  • Ran git diff --check which reported no whitespace or index issues and succeeded.
  • Attempted dotnet restore in this environment but it failed because dotnet is not available here, so build and runtime validation were not executed.
  • No automated unit tests were present or executed as part of this change in the current environment.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79880392d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +67 to +69
var handle = Process.GetCurrentProcess().MainWindowHandle;
if (handle == IntPtr.Zero || !GetWindowRect(handle, out var rect))
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve window handle so auto-hide can restore window

After ShowWindow(handle, SW_HIDE), subsequent ticks reacquire Process.GetCurrentProcess().MainWindowHandle; for hidden windows this value becomes IntPtr.Zero, so execution returns here and never reaches the SW_SHOWNA path. That means once the feature hides the main window, it can no longer automatically show it again when occlusion clears unless some external path reopens it. Keep a stable HWND (or resolve hidden-window HWND via a different API) before hiding so restore logic can still run.

Useful? React with 👍 / 👎.

@Programmer-MrWang Programmer-MrWang merged commit 35a2fff into main Apr 8, 2026
1 check passed
@Programmer-MrWang Programmer-MrWang deleted the codex/refactor-timepicker-to-use-axaml-component branch April 8, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant