Skip to content

Refactor theme collection handler#1209

Merged
Armin2208 merged 11 commits intoAutoDarkMode:v11.1from
Jay-o-Way:refactor-ThemeCollectionHandler
Apr 3, 2026
Merged

Refactor theme collection handler#1209
Armin2208 merged 11 commits intoAutoDarkMode:v11.1from
Jay-o-Way:refactor-ThemeCollectionHandler

Conversation

@Jay-o-Way
Copy link
Copy Markdown
Contributor

@Jay-o-Way Jay-o-Way commented Mar 18, 2026

fixes #1208

Refactored the handler to search for .theme files, also in the Windows Themes folder.
Note that the DisplayName is not a friendly string inside the built-in Windows themes, so I used a look-up table to connect the strings from resources.
Moved the InjectWindowsThemes code into the larger code block.

✔️ Somebody check if this is correct:

 if (file.Contains(Helper.PathUnmanagedDarkTheme) ||
    file.Contains(Helper.PathUnmanagedLightTheme) ||
    file.Contains(Helper.PathManagedTheme)) continue;

Because a different part uses used "NameUnmanagedLightTheme"

 .Where(f => !f.Contains(Helper.PathUnmanagedDarkTheme) && !f.Contains(Helper.NameUnmanagedLightTheme) && !f.Contains(Helper.PathManagedTheme)).ToList();

❓ Question: should we (alphabetically) sort the final list? done

Note

I don't use Windows 10 anymore, so would be great if somebody could test that!

Screenshot? Sure!

Theme switching

With proper checks, because the name is not simply stored in the file, for Windows built-in themes
@Jay-o-Way Jay-o-Way requested review from a team, Armin2208 and Spiritreader as code owners March 18, 2026 17:15
@Jay-o-Way Jay-o-Way added the area-windows themes Issues related to Windows themes label Mar 18, 2026
@Jay-o-Way Jay-o-Way changed the base branch from master to v11.1 March 18, 2026 17:16
@Jay-o-Way Jay-o-Way force-pushed the refactor-ThemeCollectionHandler branch from 883b9b6 to 51d22ba Compare March 18, 2026 17:29
@ChenYiLins
Copy link
Copy Markdown
Member

Nice PR! Respond quickly to Issues!

✔️ Somebody check if this is correct:

 if (file.Contains(Helper.PathUnmanagedDarkTheme) ||
    file.Contains(Helper.PathUnmanagedLightTheme) ||
    file.Contains(Helper.PathManagedTheme)) continue;

Because a different part uses used "NameUnmanagedLightTheme"

No, this part of the code is incorrect, because all three variables correspond to complete paths, not file names. You can use NameUnmanagedLightTheme instead, and add a NamePathManagedTheme for PathManagedTheme, which can avoid hard coding.

❓ Question: should we (alphabetically) sort the final list?

I think it's a good idea. In the case of multi-theme files, you can quickly find the theme files you want.

I don't use Windows 10 anymore, so would be great if somebody could test that!

As far as the current changes are concerned, it should not affect the compatibility of Win10, because as far as I know, Win11 has little change in theme compared with Win10.

(In the next few days, I can't use the computer for personal reasons, so Jay, I can't help you change this PR, I can only look at it. (;´д`)ゞ)

@Jay-o-Way
Copy link
Copy Markdown
Contributor Author

Jay-o-Way commented Mar 19, 2026

EnumerateFiles always returns full paths, not just filenames. So the safety thing would be to compare paths against paths, right? Also be using Equals(...)

@Jay-o-Way Jay-o-Way force-pushed the refactor-ThemeCollectionHandler branch from 841965b to 1f69bff Compare March 19, 2026 21:08
@Jay-o-Way
Copy link
Copy Markdown
Contributor Author

image Done

@Armin2208 Armin2208 merged commit a2e71cb into AutoDarkMode:v11.1 Apr 3, 2026
@Jay-o-Way Jay-o-Way deleted the refactor-ThemeCollectionHandler branch April 3, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-windows themes Issues related to Windows themes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow selecting base themes as well

4 participants