2020-03-17 09:05:52 +13:00
|
|
|
|
using Microsoft.Win32;
|
2019-07-15 02:46:11 +12:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
2020-04-30 23:22:47 +12:00
|
|
|
|
using SystemTrayMenu.Business;
|
2020-03-28 12:42:32 +13:00
|
|
|
|
using SystemTrayMenu.UserInterface;
|
|
|
|
|
using SystemTrayMenu.Utilities;
|
2019-07-15 02:46:11 +12:00
|
|
|
|
|
|
|
|
|
namespace SystemTrayMenu
|
|
|
|
|
{
|
2020-03-24 00:32:47 +13:00
|
|
|
|
internal class SystemTrayMenu : IDisposable
|
2019-07-15 02:46:11 +12:00
|
|
|
|
{
|
2020-04-30 23:22:47 +12:00
|
|
|
|
private readonly MenuNotifyIcon menuNotifyIcon = new MenuNotifyIcon();
|
|
|
|
|
private Menus menus = new Menus();
|
2020-03-16 04:06:18 +13:00
|
|
|
|
|
2020-03-17 02:45:19 +13:00
|
|
|
|
public SystemTrayMenu()
|
2019-07-15 02:46:11 +12:00
|
|
|
|
{
|
2020-03-17 09:05:52 +13:00
|
|
|
|
AppRestart.BeforeRestarting += Dispose;
|
|
|
|
|
SystemEvents.DisplaySettingsChanged += AppRestart.ByDisplaySettings;
|
2020-04-30 23:22:47 +12:00
|
|
|
|
menus.LoadStarted += menuNotifyIcon.LoadingStart;
|
|
|
|
|
menus.LoadStopped += menuNotifyIcon.LoadingStop;
|
2020-03-24 00:24:16 +13:00
|
|
|
|
menuNotifyIcon.Exit += Application.Exit;
|
2020-03-17 09:05:52 +13:00
|
|
|
|
menuNotifyIcon.Restart += AppRestart.ByMenuNotifyIcon;
|
2020-05-01 22:41:35 +12:00
|
|
|
|
menuNotifyIcon.Click += MenuNotifyIcon_Click;
|
|
|
|
|
void MenuNotifyIcon_Click() => menus.SwitchOpenClose(true);
|
2020-03-17 02:45:19 +13:00
|
|
|
|
menuNotifyIcon.OpenLog += Log.OpenLogFile;
|
2019-07-15 02:46:11 +12:00
|
|
|
|
menuNotifyIcon.ChangeFolder += ChangeFolder;
|
|
|
|
|
void ChangeFolder()
|
|
|
|
|
{
|
|
|
|
|
if (Config.SetFolderByUser())
|
|
|
|
|
{
|
2020-03-17 09:05:52 +13:00
|
|
|
|
AppRestart.ByConfigChange();
|
2019-07-15 02:46:11 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-30 23:22:47 +12:00
|
|
|
|
menus.MainPreload();
|
2019-07-15 02:46:11 +12:00
|
|
|
|
}
|
2020-03-09 01:21:15 +13:00
|
|
|
|
|
2019-07-15 02:46:11 +12:00
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2020-04-30 23:22:47 +12:00
|
|
|
|
menus.Dispose();
|
2019-07-15 02:46:11 +12:00
|
|
|
|
menuNotifyIcon.Dispose();
|
2020-04-03 10:45:21 +13:00
|
|
|
|
}
|
2019-07-15 02:46:11 +12:00
|
|
|
|
}
|
2019-07-05 05:04:14 +12:00
|
|
|
|
}
|