Skip to content

Commit

Permalink
Changed BGR coloring to RGB
Browse files Browse the repository at this point in the history
  • Loading branch information
Reabstraction committed Jul 28, 2023
1 parent d9c8bf7 commit 61e4933
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 13 additions & 3 deletions MicaForEveryone.Core/Models/TargetWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ public void ApplyBorderColorRule(COLORREF borderColor)
DesktopWindowManager.SetBorderColor(WindowHandle, borderColor);
}

private static UInt32 HexToColorRef(string? value)
{
if (value == null)
return 0;

var rgb = Convert.ToUInt32(value, 16);
var bgr = ((rgb & 0xFF) << 16) | (rgb & 0xFF00) | ((rgb >> 16) & 0xFF);
return bgr;
}

public void ApplyRule(IRule rule, TitlebarColorMode systemTitlebarColorMode)
{
#if DEBUG
Expand All @@ -123,7 +133,7 @@ public void ApplyRule(IRule rule, TitlebarColorMode systemTitlebarColorMode)
{
try
{
ApplyCaptionColorRule(Convert.ToUInt32(rule.CaptionColor, 16));
ApplyCaptionColorRule(HexToColorRef(rule.CaptionColor));
}
catch (FormatException)
{
Expand All @@ -136,7 +146,7 @@ public void ApplyRule(IRule rule, TitlebarColorMode systemTitlebarColorMode)
{
try
{
ApplyCaptionTextColorRule(Convert.ToUInt32(rule.CaptionTextColor, 16));
ApplyCaptionTextColorRule(HexToColorRef(rule.CaptionTextColor));
}
catch (FormatException)
{
Expand All @@ -148,7 +158,7 @@ public void ApplyRule(IRule rule, TitlebarColorMode systemTitlebarColorMode)
{
try
{
ApplyBorderColorRule(Convert.ToUInt32(rule.BorderColor, 16));
ApplyBorderColorRule(HexToColorRef(rule.BorderColor));
}
catch (FormatException)
{
Expand Down
6 changes: 3 additions & 3 deletions MicaForEveryone.UI/Strings/en/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -433,21 +433,21 @@ Fix errors then use "Reload config file" option to reload it.</value>
<value>Exit</value>
</data>
<data name="BorderColor.Description" xml:space="preserve">
<value>Color in BBGGRR hex string, empty for default
<value>Color in RRGGBB hex string, empty for default
requires build 22000+</value>
</data>
<data name="BorderColor.Header" xml:space="preserve">
<value>Window Border Color</value>
</data>
<data name="CaptionColor.Description" xml:space="preserve">
<value>Color in BBGGRR hex string, empty for default
<value>Color in RRGGBB hex string, empty for default
requires build 22000+</value>
</data>
<data name="CaptionColor.Header" xml:space="preserve">
<value>TitleBar Color</value>
</data>
<data name="CaptionTextColor.Description" xml:space="preserve">
<value>Color in BBGGRR hex string, empty for default
<value>Color in RRGGBB hex string, empty for default
requires build 22000+</value>
</data>
<data name="CaptionTextColor.Header" xml:space="preserve">
Expand Down

0 comments on commit 61e4933

Please sign in to comment.