Skip to content

Commit

Permalink
Merge branch 'development' into dependabot/github_actions/development…
Browse files Browse the repository at this point in the history
…/actions/configure-pages-4
  • Loading branch information
pomianowski authored Dec 7, 2023
2 parents 2c340d1 + f91d47c commit 0a0061b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/wpf-ui-cd-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
with:
node-version: 18.x
- name: Setup .NET Core SDK 8.x
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

Expand Down Expand Up @@ -62,4 +62,4 @@ jobs:

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v3
2 changes: 1 addition & 1 deletion .github/workflows/wpf-ui-cd-nuget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
- name: Setup .NET Core SDK 8.x
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wpf-ui-pr-validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
- name: Setup .NET Core SDK 8.x
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

Expand Down
36 changes: 33 additions & 3 deletions src/Wpf.Ui/Interop/UnsafeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// This Source Code is partially based on the source code provided by the .NET Foundation.

using System.Runtime.InteropServices;
using Microsoft.Win32;
using Wpf.Ui.Controls;
using Wpf.Ui.Hardware;

Expand Down Expand Up @@ -351,11 +352,33 @@ public static bool ApplyWindowLegacyAcrylicEffect(IntPtr handle)
/// </summary>
public static Color GetDwmColor()
{
Dwmapi.DwmGetColorizationParameters(out var dwmParams);
try
{
Dwmapi.DwmGetColorizationParameters(out var dwmParams);
var values = BitConverter.GetBytes(dwmParams.clrColor);

var values = BitConverter.GetBytes(dwmParams.clrColor);
return Color.FromArgb(255, values[2], values[1], values[0]);
}
catch
{
var colorizationColorValue = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", null);

return Color.FromArgb(255, values[2], values[1], values[0]);
if (colorizationColorValue is not null)
{
try
{
var colorizationColor = (uint)(int)colorizationColorValue;
var values = BitConverter.GetBytes(colorizationColor);

return Color.FromArgb(255, values[2], values[1], values[0]);
}
catch
{
}
}
}

return GetDefaultWindowsAccentColor();
}

/// <summary>
Expand Down Expand Up @@ -585,4 +608,11 @@ private static IntPtr SetWindowLong(IntPtr handle, User32.GWL nIndex, long windo

return User32.SetWindowLongPtr(handle, (int)nIndex, (IntPtr)windowStyleLong);
}

private static Color GetDefaultWindowsAccentColor()
{
// Windows default accent color
// https://learn.microsoft.com/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup-themes-windowcolor#values
return Color.FromArgb(0xff, 0x00, 0x78, 0xd7);
}
}

0 comments on commit 0a0061b

Please sign in to comment.