C# console get Windows 10 Accent Color

前端 未结 2 454
滥情空心
滥情空心 2021-01-07 08:27

Is there a way in .Net Core 2.X to read the Selected Windows 10 Accent Color in a Console Application.

Most of the solution i found are UWP or WPF apps.

Too

2条回答
  •  自闭症患者
    2021-01-07 09:00

    Starting with .NET Core 3.0 it is also possible to call UWP APIs from non UWP apps with the help of Microsoft.Windows.SDK.Contracts package.

    So we can use UWP API to get accent color from .NET Core console app using:

    var uiSettings = new UISettings();
    var accentColor = uiSettings.GetColorValue(UIColorType.Accent);
    

    The returned color is of type Windows.UI.Color, but can easily converted into for example System.Drawing.Color

    Color.FromArgb(accentColor.A, accentColor.R, accentColor.G, accentColor.B);
    

提交回复
热议问题