Tray icon now respects current system theme
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Windows.UI.ViewManagement;
|
||||
|
||||
namespace NotificationFlyout.Shared.UI.Helpers
|
||||
{
|
||||
public class SystemPersonalisationHelper
|
||||
{
|
||||
private readonly UISettings _settings = new UISettings();
|
||||
|
||||
private SystemPersonalisationHelper()
|
||||
{
|
||||
_settings.ColorValuesChanged += _settings_ColorValuesChanged;
|
||||
}
|
||||
|
||||
private void _settings_ColorValuesChanged(UISettings sender, object args)
|
||||
{
|
||||
ThemeChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event EventHandler ThemeChanged;
|
||||
|
||||
public SystemTheme SystemTheme => GetSystemTheme();
|
||||
|
||||
public static SystemPersonalisationHelper Create()
|
||||
{
|
||||
return new SystemPersonalisationHelper();
|
||||
}
|
||||
|
||||
private SystemTheme GetSystemTheme()
|
||||
{
|
||||
var uiTheme = _settings.GetColorValue(UIColorType.Background).ToString();
|
||||
return uiTheme == "#FFFFFFFF" ? SystemTheme.Light : SystemTheme.Dark;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace NotificationFlyout.Shared.UI.Helpers
|
||||
{
|
||||
public enum SystemTheme
|
||||
{
|
||||
Dark,
|
||||
Light,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user