diff --git a/.github/workflows/wpf-ui-cd-docs.yaml b/.github/workflows/wpf-ui-cd-docs.yaml index f09ad23aa..4b1adf1be 100644 --- a/.github/workflows/wpf-ui-cd-docs.yaml +++ b/.github/workflows/wpf-ui-cd-docs.yaml @@ -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 @@ -62,4 +62,4 @@ jobs: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v3 diff --git a/.github/workflows/wpf-ui-cd-nuget.yaml b/.github/workflows/wpf-ui-cd-nuget.yaml index 10e30b1dd..a9fabd45e 100644 --- a/.github/workflows/wpf-ui-cd-nuget.yaml +++ b/.github/workflows/wpf-ui-cd-nuget.yaml @@ -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 diff --git a/.github/workflows/wpf-ui-pr-validator.yaml b/.github/workflows/wpf-ui-pr-validator.yaml index 858e1626f..5d973e389 100644 --- a/.github/workflows/wpf-ui-pr-validator.yaml +++ b/.github/workflows/wpf-ui-pr-validator.yaml @@ -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 diff --git a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs index 35e865406..fd0797a45 100644 --- a/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs +++ b/src/Wpf.Ui/Interop/UnsafeNativeMethods.cs @@ -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; @@ -351,11 +352,33 @@ public static bool ApplyWindowLegacyAcrylicEffect(IntPtr handle) /// 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(); } /// @@ -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); + } }