-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theme responsive notification icons #23
Conversation
I skimmed through those changes. The whole idea and implementation seems great to me 💯 Those are my review comments:
Classnamespace ExternalHelpers
{
public class WindowsDarkMode
{
public static bool IsDarkModeEnabled { get; }
public static event Action<bool> DarkModeChanged;
static WindowsDarkMode() { /* init */ on first use }
}
} |
Sure thing, thanks for review! I believe I have to switch VS to English to make comments in generated classes English, too. But RegistryMonitor should be moved as is to ExternalHelpers (it already has comments on origin, license) or should it be remade into something more suiting the convention, eg. merged into WindowsDarkMode? I would really like not to do the latter, but I will respect the project :D |
That is in general my idea to make things isolated and have minimal dependencies outside. So, those components can be replaced if needed, and they are self-contained. Try it and see how much effort is that. You could even make |
Oki, I will try. Also it looks like github actually stores project files in LF, not CRLF (I have used git config --global core.autocrlf false re-cloned the repo and checked files in the unmodified main branch) |
@maniman303 Yes, git will drop |
As I didn't want to break anything in RegistryMonitor I moved it to the WindowsDarkMode.cs as an internal class. Also I've added in comments proper links to the source and license |
@maniman303 I also wonder. This is quite heavy duty. Each app is UI app. Maybe we could actually make it way simpler without additional thread reading registry. Something like this would be equally effective and equally performant: public static bool IsDarkModeEnabled { get; private set; }
private static System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer()
{
Interval = 1000
};
static WindowsDarkMode()
{
...
IsDarkModeEnabled = FetchIsDarkModeEnabled();
timer.Tick += delegate
{
var value = FetchIsDarkModeEnabled();
if(value == IsDarkModeEnabled)
return;
IsDarkModeEnabled = value;
DarkModeChanged(value);
});
timer.Start();
}
private static bool FetchIsDarkModeEnabled()
{
try
{
string RegistryKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
int theme = (int?)Registry.GetValue(RegistryKey, "SystemUsesLightTheme", 1) ?? 1;
return theme == 0;
}
catch
{
return false;
}
} |
One one hand it seams a bit hacky, one the other it's now much simpler. But it works :) |
@maniman303 Did you missed icon for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maniman303 This looks great 💯 My final comments for me to merge it:
- I miss
.ico
toFanControl
- We can remove the
event
as we don't seem to use - Also, since there's nothing really new in
ExternalHelpers.WindowsDarkMode
now, can we move it toCommonHelpers
I use ExternalHelpers
to track "externally licensed components".
Fan control is missing .ico because if I'm not wrong it doesn't show up in notification tray. It's missing implementation via Controller class like others "packages" so I on purpose didn't modify it |
@maniman303 Take a look at this: https://github.com/ayufan/steam-deck-tools/blob/main/FanControl/FanControlForm.cs#L154, there's an access to The |
Okay, it looks like a good place to update notifyIcon, but whenever I try to add to FanControlForm.resx a new resource I get "You are trying to edit a resource file that is a port of another project item. Editing this item could corrupt the project item..." :/ |
@maniman303 Strange. I will handle it myself. Can you just add a |
Sure, no prob |
Hi! This PR will make notification icons (the ones in tray) responsive to the windows theme - white icons in the dark mode and black icons in a light mode :). They will also automatically change with system theme change.
Should deal with #14, but tested only in Windows 11. Windows 10 might use different registry keys, but support can be easily added later.