-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProcessIcon.cs
72 lines (65 loc) · 1.72 KB
/
ProcessIcon.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Based on https://www.codeproject.com/articles/290013/formless-system-tray-application
*/
using System;
using System.Diagnostics;
using System.Windows.Forms;
using AutoCap.Properties;
namespace AutoCap
{
/// <summary>
///
/// </summary>
class ProcessIcon : IDisposable
{
/// <summary>
/// The NotifyIcon object.
/// </summary>
NotifyIcon ni;
/// <summary>
/// Initializes a new instance of the <see cref="ProcessIcon"/> class.
/// </summary>
public ProcessIcon()
{
// Instantiate the NotifyIcon object.
ni = new NotifyIcon();
}
/// <summary>
/// Displays the icon in the system tray.
/// </summary>
public void Display()
{
// Put the icon in the system tray and allow it react to mouse clicks.
ni.MouseClick += new MouseEventHandler(ni_MouseClick);
ni.Icon = Resources.CameraIcon;
ni.Text = "Auto Desktop Screenshot Capture";
ni.Visible = true;
// Attach a context menu.
ni.ContextMenuStrip = new ContextMenus().Create();
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources
/// </summary>
public void Dispose()
{
// When the application closes, this will remove the icon from the system tray immediately.
ni.Dispose();
}
/// <summary>
/// Handles the MouseClick event of the ni control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
void ni_MouseClick(object sender, MouseEventArgs e)
{
/*
// Handle mouse button clicks.
if (e.Button == MouseButtons.Left)
{
// Start Windows Explorer.
Process.Start("explorer", null);
}
*/
}
}
}