Skip to content

Commit

Permalink
change colours if theme setting is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
infinitepower18 committed Nov 13, 2023
1 parent 1f3b8ef commit fdbd7a5
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions WSA System Control/AppContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ public AppContext()

contextMenu = new ContextMenuStrip();

int res = (int)Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme", -1);
if (res == 0)
{
contextMenu.BackColor = ColorTranslator.FromHtml("#FF2D2D30");
contextMenu.ForeColor = Color.White;
}
setTheme();

contextMenu.RenderMode = ToolStripRenderMode.System;

Expand Down Expand Up @@ -105,6 +100,20 @@ internal static bool IsPackaged()
}
}

private void setTheme()
{
int res = (int)Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme", -1);
if (res == 0)
{
contextMenu.BackColor = ColorTranslator.FromHtml("#FF2D2D30");
contextMenu.ForeColor = Color.White;
} else
{
contextMenu.BackColor = Color.White;
contextMenu.ForeColor = Color.Black;
}
}

private void Win11WSANotFound()
{
string message = rm.GetString("WSANotInstalledWin11");
Expand Down Expand Up @@ -225,6 +234,7 @@ void androidSettings(object sender, EventArgs e)
private void mouseClick(object sender, EventArgs e)
{
MouseEventArgs mouseEventArgs = (MouseEventArgs)e;
setTheme();
if (mouseEventArgs.Button == MouseButtons.Left & contextMenu.Items[0].Enabled == false)
{
MethodInfo mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
Expand Down

0 comments on commit fdbd7a5

Please sign in to comment.