2016-02-12 15:22:01 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Wox.Core.Resource;
|
|
|
|
|
using Wox.Plugin;
|
|
|
|
|
|
|
|
|
|
namespace Wox
|
|
|
|
|
{
|
|
|
|
|
public class NotifyIconManager
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private NotifyIcon notifyIcon;
|
|
|
|
|
private IPublicAPI _api;
|
|
|
|
|
|
|
|
|
|
public NotifyIconManager(IPublicAPI api)
|
|
|
|
|
{
|
2016-02-21 23:42:37 +08:00
|
|
|
|
InitialTray();
|
|
|
|
|
_api = api;
|
2016-02-12 15:22:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitialTray()
|
|
|
|
|
{
|
|
|
|
|
notifyIcon = new NotifyIcon { Text = "Wox", Icon = Properties.Resources.app, Visible = true };
|
2016-02-21 23:42:37 +08:00
|
|
|
|
notifyIcon.Click += (o, e) => _api.ShowApp();
|
2016-02-12 15:22:01 +08:00
|
|
|
|
var open = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayOpen"));
|
2016-02-21 23:42:37 +08:00
|
|
|
|
open.Click += (o, e) => _api.ShowApp();
|
2016-02-12 15:22:01 +08:00
|
|
|
|
var setting = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTraySettings"));
|
2016-02-21 23:42:37 +08:00
|
|
|
|
setting.Click += (o, e) => _api.OpenSettingDialog();
|
2016-02-12 15:22:01 +08:00
|
|
|
|
var about = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayAbout"));
|
2016-02-21 23:42:37 +08:00
|
|
|
|
about.Click += (o, e) => _api.OpenSettingDialog("about");
|
2016-02-12 15:22:01 +08:00
|
|
|
|
var exit = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayExit"));
|
2016-02-21 23:42:37 +08:00
|
|
|
|
exit.Click += (o, e) => _api.CloseApp();
|
2016-02-12 15:22:01 +08:00
|
|
|
|
MenuItem[] childen = { open, setting, about, exit };
|
|
|
|
|
notifyIcon.ContextMenu = new ContextMenu(childen);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|