SystemTrayMenu/Business/SystemTrayMenu.cs
2020-05-04 19:49:19 +02:00

35 lines
1.1 KiB
C#

using Microsoft.Win32;
using System;
using System.Windows.Forms;
using SystemTrayMenu.Business;
using SystemTrayMenu.UserInterface;
using SystemTrayMenu.Utilities;
namespace SystemTrayMenu
{
internal class SystemTrayMenu : IDisposable
{
private readonly MenuNotifyIcon menuNotifyIcon = new MenuNotifyIcon();
private Menus menus = new Menus();
public SystemTrayMenu()
{
AppRestart.BeforeRestarting += Dispose;
SystemEvents.DisplaySettingsChanged += AppRestart.ByDisplaySettings;
menus.LoadStarted += menuNotifyIcon.LoadingStart;
menus.LoadStopped += menuNotifyIcon.LoadingStop;
menuNotifyIcon.Exit += Application.Exit;
menuNotifyIcon.Restart += AppRestart.ByMenuNotifyIcon;
menuNotifyIcon.Click += MenuNotifyIcon_Click;
void MenuNotifyIcon_Click() => menus.SwitchOpenClose(true);
menuNotifyIcon.OpenLog += Log.OpenLogFile;
menus.MainPreload();
}
public void Dispose()
{
menus.Dispose();
menuNotifyIcon.Dispose();
}
}
}