Skip to content

Commit

Permalink
Theme responsive notification icons (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
maniman303 authored and ayufan committed Dec 14, 2022
1 parent 85a2778 commit c4fd544
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 8 deletions.
37 changes: 37 additions & 0 deletions CommonHelpers/WindowsDarkMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Microsoft.Win32;

namespace CommonHelpers
{
public class WindowsDarkMode
{
private static System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer()
{
Interval = 1500
};

public static bool IsDarkModeEnabled { get; private set; }

static WindowsDarkMode()
{

IsDarkModeEnabled = FetchIsDarkModeEnabled();

timer.Tick += delegate{ IsDarkModeEnabled = FetchIsDarkModeEnabled(); };
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;
}
}
}
}
Binary file added FanControl/FanControl-white.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions PerformanceOverlay/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Controller()
exitItem.Click += ExitItem_Click;

notifyIcon = new System.Windows.Forms.NotifyIcon(components);
notifyIcon.Icon = Resources.poll;
notifyIcon.Icon = WindowsDarkMode.IsDarkModeEnabled ? Resources.poll_light : Resources.poll;
notifyIcon.Text = TitleWithVersion;
notifyIcon.Visible = true;
notifyIcon.ContextMenuStrip = contextMenu;
Expand Down Expand Up @@ -197,7 +197,7 @@ private void OsdTimer_Tick(object? sender, EventArgs e)
try
{
notifyIcon.Text = TitleWithVersion + ". RTSS Version: " + OSD.Version;
notifyIcon.Icon = Resources.poll;
notifyIcon.Icon = WindowsDarkMode.IsDarkModeEnabled ? Resources.poll_light : Resources.poll;
}
catch
{
Expand Down
10 changes: 10 additions & 0 deletions PerformanceOverlay/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions PerformanceOverlay/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
<data name="poll" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\poll.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="poll_light" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\poll_light.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="poll_red" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\poll_red.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
Binary file added PerformanceOverlay/Resources/poll_light.ico
Binary file not shown.
5 changes: 3 additions & 2 deletions PowerControl/Controller.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CommonHelpers;
using ExternalHelpers;
using Microsoft.VisualBasic.Logging;
using Microsoft.Win32;
using PowerControl.External;
using PowerControl.Helpers;
using RTSSSharedMemoryNET;
Expand Down Expand Up @@ -89,7 +90,7 @@ public Controller()
exitItem.Click += ExitItem_Click;

notifyIcon = new System.Windows.Forms.NotifyIcon(components);
notifyIcon.Icon = Resources.traffic_light_outline;
notifyIcon.Icon = WindowsDarkMode.IsDarkModeEnabled ? Resources.traffic_light_outline_light : Resources.traffic_light_outline;
notifyIcon.Text = TitleWithVersion;
notifyIcon.Visible = true;
notifyIcon.ContextMenuStrip = contextMenu;
Expand Down Expand Up @@ -183,7 +184,7 @@ private void OsdTimer_Tick(object? sender, EventArgs e)
try
{
notifyIcon.Text = TitleWithVersion + ". RTSS Version: " + OSD.Version;
notifyIcon.Icon = Resources.traffic_light_outline;
notifyIcon.Icon = WindowsDarkMode.IsDarkModeEnabled ? Resources.traffic_light_outline_light : Resources.traffic_light_outline;
}
catch
{
Expand Down
10 changes: 10 additions & 0 deletions PowerControl/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions PowerControl/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="traffic-light-outline_light" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\traffic-light-outline_light.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="traffic_light_outline" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\traffic-light-outline.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
Binary file not shown.
16 changes: 12 additions & 4 deletions SteamController/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public Controller()
exitItem.Click += delegate { Application.Exit(); };

notifyIcon = new NotifyIcon(components);
notifyIcon.Icon = Resources.microsoft_xbox_controller_off;
notifyIcon.Icon = WindowsDarkMode.IsDarkModeEnabled ? Resources.microsoft_xbox_controller_off_white : Resources.microsoft_xbox_controller_off;
notifyIcon.Text = TitleWithVersion;
notifyIcon.Visible = true;
notifyIcon.ContextMenuStrip = contextMenu;
Expand Down Expand Up @@ -149,6 +149,14 @@ private void ContextStateUpdate_Tick(object? sender, EventArgs e)
context.Tick();

var isDesktop = context.CurrentProfile?.IsDesktop ?? false;
var monitorOffIco = WindowsDarkMode.IsDarkModeEnabled ? Resources.monitor_off_white : Resources.monitor_off;
var monitorOnIco = WindowsDarkMode.IsDarkModeEnabled ? Resources.monitor_white : Resources.monitor;
var controllerOffIco = WindowsDarkMode.IsDarkModeEnabled ?
Resources.microsoft_xbox_controller_off_white :
Resources.microsoft_xbox_controller_off;
var controllerOnIco = WindowsDarkMode.IsDarkModeEnabled ?
Resources.microsoft_xbox_controller_white :
Resources.microsoft_xbox_controller;

if (!context.KeyboardMouseValid)
{
Expand All @@ -164,12 +172,12 @@ private void ContextStateUpdate_Tick(object? sender, EventArgs e)
{
if (context.State.SteamUsesSteamInput)
{
notifyIcon.Icon = isDesktop ? Resources.monitor_off : Resources.microsoft_xbox_controller_off;
notifyIcon.Icon = isDesktop ? monitorOffIco : controllerOffIco;
notifyIcon.Text = TitleWithVersion + ". Steam uses Steam Input";
}
else
{
notifyIcon.Icon = isDesktop ? Resources.monitor : Resources.microsoft_xbox_controller;
notifyIcon.Icon = isDesktop ? monitorOnIco : controllerOnIco;
notifyIcon.Text = TitleWithVersion;
}

Expand All @@ -179,7 +187,7 @@ private void ContextStateUpdate_Tick(object? sender, EventArgs e)
}
else
{
notifyIcon.Icon = isDesktop ? Resources.monitor_off : Resources.microsoft_xbox_controller_off;
notifyIcon.Icon = isDesktop ? monitorOffIco : controllerOffIco;
notifyIcon.Text = TitleWithVersion + ". Disabled";
}

Expand Down
20 changes: 20 additions & 0 deletions SteamController/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions SteamController/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@
<data name="monitor_off" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\monitor-off.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="monitor_off_white" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\monitor-off-white.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="monitor_white" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\monitor-white.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="steam" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\steam.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
Binary file modified SteamController/Resources/microsoft-xbox-controller-white.ico
Binary file not shown.
Binary file added SteamController/Resources/monitor-off-white.ico
Binary file not shown.
Binary file added SteamController/Resources/monitor-white.ico
Binary file not shown.

0 comments on commit c4fd544

Please sign in to comment.