-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTerminalTrayIcon.cs
58 lines (50 loc) · 1.53 KB
/
TerminalTrayIcon.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using WindowsTermialTray;
using WindowsTermialTray.Keys;
using WindowsTermialTray.Properties;
namespace WindowsTerminalTray
{
public class TerminalTrayIcon : IDisposable
{
// Apps that hides to Tray
private List<TrayApp> _appTrayList;
// Tray vars
public NotifyIcon Ni;
public TerminalTrayIcon()
{
var contextMenu = new ContextMenu();
var exitItem = new MenuItem
{
Index = 0,
Text = "E&xit"
};
exitItem.Click += Close;
contextMenu.MenuItems.Add(exitItem);
_appTrayList = new List<TrayApp>();
_appTrayList.AddRange(new []
{
new TrayApp("WindowsTerminal", "wt.exe", ModifierKeys.Alt, Keys.Oemtilde)
// Add your other tray apps here
// new TrayApp("ProcessName", "exec.exe", ModifierKeys.Ctrl, Keys.Oemtilde)
});
Ni = new NotifyIcon
{
Visible = true,
Icon = Resources.terminal_tray,
Text = $@"Termial Tray!",
ContextMenu = contextMenu
};
}
private void Close(object Sender, EventArgs e)
{
_appTrayList.ForEach(x => x.Dispose());
Dispose();
Ni.Visible = false;
Application.Exit();
}
public void Dispose() { }
}
}