Skip to content

Commit

Permalink
Fixed MicaWPF.Lite brushes when hovering.
Browse files Browse the repository at this point in the history
  • Loading branch information
Simnico99 committed May 9, 2024
1 parent bf37adc commit 5310f26
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
14 changes: 9 additions & 5 deletions src/MicaWPF.Core/Controls/MicaWindow/MicaWindowInteropHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// This software is distributed under the MIT license and its code is open-source and free for use, modification, and distribution.
// </copyright>

using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Automation.Peers;
Expand All @@ -12,7 +11,6 @@
using MicaWPF.Core.Enums;
using MicaWPF.Core.Helpers;
using MicaWPF.Core.Interop;
using MicaWPF.Core.Services;

namespace MicaWPF.Core.Controls.MicaWindow;

Expand All @@ -30,9 +28,15 @@ public MicaWindowInteropHandler()
{
}

protected System.Windows.Controls.Button? ButtonMax { get; set; }
protected System.Windows.Controls.Button? ButtonMax
{
get; set;
}

protected System.Windows.Controls.Button? ButtonRestore { get; set; }
protected System.Windows.Controls.Button? ButtonRestore
{
get; set;
}

protected override void OnInitialized(EventArgs e)
{
Expand Down Expand Up @@ -79,7 +83,7 @@ private nint ShowSnapLayout(nint lparam, ref bool handled)
handled = rect.Contains(point);
if (handled)
{
var color = TryFindResource($"MicaWPF{MicaWPFServiceUtility.BrushNamespace}.GradientBrushes.ControlElevationBorder") as LinearGradientBrush ?? new LinearGradientBrush();
var color = TryFindResource($"MicaWPF.GradientBrushes.ControlElevationBorder") as LinearGradientBrush ?? new LinearGradientBrush();
button.Background = color;
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/MicaWPF.Core/Services/AccentColorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void UpdateColorResources(Color primaryAccent, Color secondaryAccent, Co

for (var i = 0; i < _colorKeys.Length; i++)
{
Application.Current.Resources[$"MicaWPF{MicaWPFServiceUtility.BrushNamespace}.Colors.SystemAccentColor{_colorKeys[i]}"] = accentColors[i];
Application.Current.Resources[$"MicaWPF.Colors.SystemAccentColor{_colorKeys[i]}"] = accentColors[i];
}

WindowHelper.RefreshAllWindowsContents();
Expand Down
7 changes: 4 additions & 3 deletions src/MicaWPF.Core/Services/MicaWPFServiceUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ static MicaWPFServiceUtility()
}
}

public static bool HasBeenInitialized { get; }
public static bool HasBeenInitialized
{
get;
}

/// <summary>
/// Gets or sets the Accent Color Service instance (WARNING: Sets should be done on application start).
Expand Down Expand Up @@ -70,6 +73,4 @@ public static string CurrentNamespace
get => _currentNamespace ?? throw new ArgumentNullException("Value is not initialized yet.");
set => StaticHelper.Init(value, ref _currentNamespace);
}

public static string BrushNamespace => CurrentNamespace == "MicaWPF" ? string.Empty : $".{CurrentNamespace}";
}

0 comments on commit 5310f26

Please sign in to comment.