-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTrayIcon.xaml.cs
45 lines (39 loc) · 1.31 KB
/
TrayIcon.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Diagnostics;
using System.Windows.Input;
using Windows.UI.ViewManagement;
using DependencyPropertyGenerator;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Imaging;
namespace Coder.Desktop.App.Controls;
[DependencyProperty<ICommand>("OpenCommand")]
[DependencyProperty<ICommand>("ExitCommand")]
public sealed partial class TrayIcon : UserControl
{
private readonly UISettings _uiSettings = new();
public TrayIcon()
{
InitializeComponent();
_uiSettings.ColorValuesChanged += OnColorValuesChanged;
UpdateTrayIconBasedOnTheme();
}
private void OnColorValuesChanged(UISettings sender, object args)
{
DispatcherQueue.TryEnqueue(UpdateTrayIconBasedOnTheme);
}
private void UpdateTrayIconBasedOnTheme()
{
var currentTheme = Application.Current.RequestedTheme;
Debug.WriteLine("Theme update requested, found theme: " + currentTheme);
switch (currentTheme)
{
case ApplicationTheme.Dark:
TaskbarIcon.IconSource = (BitmapImage)Resources["IconDarkTheme"];
break;
case ApplicationTheme.Light:
default:
TaskbarIcon.IconSource = (BitmapImage)Resources["IconLightTheme"];
break;
}
}
}