Files
FSI.BT.IR.Tools/FSI.BT.Tools/SystemTrayMenu/UserInterface/AppNotifyIcon.cs
Stephan Maier 647f938eee v1.2
2024-08-27 08:10:27 +02:00

75 lines
2.0 KiB
C#

// <copyright file="AppNotifyIcon.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace FSI.BT.Tools.SystemTrayMenu.UserInterface
{
using System;
using System.Windows.Forms;
using FSI.BT.Tools.SystemTrayMenu.Helper;
using FSI.BT.Tools.SystemTrayMenu.Utilities;
internal class AppNotifyIcon : IDisposable
{
private readonly NotifyIcon notifyIcon = new();
public AppNotifyIcon()
{
notifyIcon.Text = "FSI.BT.Tools.SystemTrayMenu";
notifyIcon.Icon = Config.GetAppIcon();
notifyIcon.Visible = true;
AppContextMenu contextMenus = new();
contextMenus.ClickedOpenLog += ClickedOpenLog;
void ClickedOpenLog()
{
OpenLog?.Invoke();
}
notifyIcon.ContextMenuStrip = contextMenus.Create();
notifyIcon.MouseClick += NotifyIcon_MouseClick;
void NotifyIcon_MouseClick(object sender, MouseEventArgs e)
{
notifyIcon.BalloonTipText = "Hallo";
notifyIcon.ShowBalloonTip(5000);
// VerifyClick(e);
}
notifyIcon.MouseDoubleClick += NotifyIcon_MouseDoubleClick;
void NotifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
VerifyClick(e);
}
}
public event Action Click;
public event Action OpenLog;
public void Dispose()
{
notifyIcon.Icon = null;
notifyIcon.Dispose();
}
public void LoadingStart()
{
notifyIcon.Icon = Resources.StaticResources.LoadingIcon;
}
public void LoadingStop()
{
notifyIcon.Icon = Config.GetAppIcon();
}
private void VerifyClick(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Click?.Invoke();
}
}
}
}