2022-10-23 11:02:31 +13:00
|
|
|
|
// <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;
|
2023-04-17 00:17:33 +12:00
|
|
|
|
using SystemTrayMenu.Helpers;
|
2022-10-23 11:02:31 +13:00
|
|
|
|
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;
|
2022-12-06 09:46:53 +13:00
|
|
|
|
notifyIcon.ContextMenu = new AppContextMenu().Create();
|
2022-10-23 11:02:31 +13:00
|
|
|
|
notifyIcon.LeftClickCommand = new ActionCommand((_) => Click?.Invoke());
|
|
|
|
|
notifyIcon.DoubleClickCommand = new ActionCommand((_) => Click?.Invoke());
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-05 13:27:57 +13:00
|
|
|
|
public event Action? Click;
|
2022-10-23 11:02:31 +13:00
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
notifyIcon.Icon = null;
|
|
|
|
|
notifyIcon.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadingStart()
|
|
|
|
|
{
|
|
|
|
|
notifyIcon.Icon = Resources.StaticResources.LoadingIcon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadingStop()
|
|
|
|
|
{
|
|
|
|
|
notifyIcon.Icon = Config.GetAppIcon();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-05 05:04:14 +12:00
|
|
|
|
}
|