-
Notifications
You must be signed in to change notification settings - Fork 0
/
IopTrayIcon.cs
51 lines (43 loc) · 1.58 KB
/
IopTrayIcon.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
using Gdk;
using Gtk;
using Window = Gtk.Window;
namespace InteractiveOfficeClient
{
public class IopTrayIcon : Gtk.StatusIcon
{
private readonly Menu _popupMenu;
public IopTrayIcon(InteractiveOfficeClient app) : base(
Pixbuf.LoadFromResource("InteractiveOfficeClient.Resources.app_icon.png"))
{
Activate += delegate { app.ToggleAppVisibility(); };
PopupMenu += OnTrayIconPopup;
TooltipText = "Interactive Office";
Visible = true;
_popupMenu = new Menu();
var menuItemStartWork = AddImageMenuItem("Start Work", Gtk.Stock.MediaPlay);
menuItemStartWork.Activated += delegate
{
app.TriggerNotification();
};
var menuItemStartPause = AddImageMenuItem("Start Break", Gtk.Stock.MediaPause);
menuItemStartPause.Activated += delegate
{
app.TriggerNotification();
};
var menuItemQuit = AddImageMenuItem("Quit", Gtk.Stock.Quit);
menuItemQuit.Activated += delegate { Application.Quit(); };
}
private void OnTrayIconPopup(object o, PopupMenuArgs popupMenuArgs)
{
_popupMenu.ShowAll();
_popupMenu.Popup();
}
private ImageMenuItem AddImageMenuItem(string label, string quit)
{
ImageMenuItem menuItem = new ImageMenuItem(label);
menuItem.Image = new Gtk.Image(quit, IconSize.Menu);
_popupMenu.Add(menuItem);
return menuItem;
}
}
}