SystemTrayMenu/UserInterface/AppNotifyIcon.cs
Peter Kirmeier 0158499a2c Simplified directory and file discovery
Corrected namespace naming of Helpers
2023-04-16 14:17:33 +02:00

45 lines
1.3 KiB
C#

// <copyright file="AppNotifyIcon.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace SystemTrayMenu.UserInterface
{
using System;
using System.Windows;
using Hardcodet.Wpf.TaskbarNotification;
using SystemTrayMenu.Helpers;
using SystemTrayMenu.Utilities;
internal class AppNotifyIcon : IDisposable
{
private readonly TaskbarIcon notifyIcon = new ();
public AppNotifyIcon()
{
notifyIcon.ToolTipText = "SystemTrayMenu";
notifyIcon.Icon = Config.GetAppIcon();
notifyIcon.Visibility = Visibility.Visible;
notifyIcon.ContextMenu = new AppContextMenu().Create();
notifyIcon.LeftClickCommand = new ActionCommand((_) => Click?.Invoke());
notifyIcon.DoubleClickCommand = new ActionCommand((_) => Click?.Invoke());
}
public event Action? Click;
public void Dispose()
{
notifyIcon.Icon = null;
notifyIcon.Dispose();
}
public void LoadingStart()
{
notifyIcon.Icon = Resources.StaticResources.LoadingIcon;
}
public void LoadingStop()
{
notifyIcon.Icon = Config.GetAppIcon();
}
}
}