SystemTrayMenu/Business/SystemTrayMenu.cs
Markus Hofknecht 43755ae648 #10, #49
2020-04-30 13:22:47 +02:00

43 lines
1.3 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 += menus.SwitchOpenClose;
menuNotifyIcon.OpenLog += Log.OpenLogFile;
menuNotifyIcon.ChangeFolder += ChangeFolder;
void ChangeFolder()
{
if (Config.SetFolderByUser())
{
AppRestart.ByConfigChange();
}
}
menus.MainPreload();
}
public void Dispose()
{
menus.Dispose();
menuNotifyIcon.Dispose();
}
}
}