|
|
@ -14,7 +14,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
<!-- Actions --> |
|
|
|
<!-- Actions --> |
|
|
|
<Actions> |
|
|
|
<Actions> |
|
|
|
<Open filename = "SysTrayIcon.cs"/> |
|
|
|
<Open filename = "NotificationIcon.cs"/> |
|
|
|
</Actions> |
|
|
|
</Actions> |
|
|
|
|
|
|
|
|
|
|
|
<Project language="C#"> |
|
|
|
<Project language="C#"> |
|
|
@ -31,7 +31,7 @@ |
|
|
|
</PropertyGroup> |
|
|
|
</PropertyGroup> |
|
|
|
|
|
|
|
|
|
|
|
<Files> |
|
|
|
<Files> |
|
|
|
<File name="SysTrayIcon.cs" language="C#"><![CDATA[${StandardHeader.C#} |
|
|
|
<File name="NotificationIcon.cs" language="C#"><![CDATA[${StandardHeader.C#} |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Drawing; |
|
|
|
using System.Drawing; |
|
|
@ -40,21 +40,21 @@ using System.Windows.Forms; |
|
|
|
|
|
|
|
|
|
|
|
namespace ${StandardNamespace} |
|
|
|
namespace ${StandardNamespace} |
|
|
|
{ |
|
|
|
{ |
|
|
|
public sealed class SysTrayIcon |
|
|
|
public sealed class NotificationIcon |
|
|
|
{ |
|
|
|
{ |
|
|
|
private System.Windows.Forms.NotifyIcon trayIcon; |
|
|
|
private NotifyIcon notifyIcon; |
|
|
|
private System.Windows.Forms.ContextMenu sysTrayMenu; |
|
|
|
private ContextMenu notificationMenu; |
|
|
|
|
|
|
|
|
|
|
|
#region Initialize icon and menu |
|
|
|
#region Initialize icon and menu |
|
|
|
public SysTrayIcon() |
|
|
|
public NotificationIcon() |
|
|
|
{ |
|
|
|
{ |
|
|
|
trayIcon = new NotifyIcon(); |
|
|
|
notifyIcon = new NotifyIcon(); |
|
|
|
sysTrayMenu = new ContextMenu(InitializeMenu()); |
|
|
|
notificationMenu = new ContextMenu(InitializeMenu()); |
|
|
|
|
|
|
|
|
|
|
|
trayIcon.DoubleClick += TrayIconDoubleClick; |
|
|
|
notifyIcon.DoubleClick += IconDoubleClick; |
|
|
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SysTrayIcon)); |
|
|
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NotificationIcon)); |
|
|
|
trayIcon.Icon = (Icon)resources.GetObject("$this.Icon"); |
|
|
|
notifyIcon.Icon = (Icon)resources.GetObject("$this.Icon"); |
|
|
|
trayIcon.ContextMenu = sysTrayMenu; |
|
|
|
notifyIcon.ContextMenu = notificationMenu; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private MenuItem[] InitializeMenu() |
|
|
|
private MenuItem[] InitializeMenu() |
|
|
@ -80,13 +80,13 @@ namespace ${StandardNamespace} |
|
|
|
// Please use a unique name for the mutex to prevent conflicts with other programs |
|
|
|
// Please use a unique name for the mutex to prevent conflicts with other programs |
|
|
|
using (Mutex mtx = new Mutex(true, "${StandardNamespace}", out isFirstInstance)) { |
|
|
|
using (Mutex mtx = new Mutex(true, "${StandardNamespace}", out isFirstInstance)) { |
|
|
|
if (isFirstInstance) { |
|
|
|
if (isFirstInstance) { |
|
|
|
SysTrayIcon sysTrayIcon = new SysTrayIcon(); |
|
|
|
NotificationIcon notificationIcon = new NotificationIcon(); |
|
|
|
sysTrayIcon.trayIcon.Visible = true; |
|
|
|
notificationIcon.notifyIcon.Visible = true; |
|
|
|
Application.Run(); |
|
|
|
Application.Run(); |
|
|
|
sysTrayIcon.trayIcon.Dispose(); |
|
|
|
notificationIcon.notifyIcon.Dispose(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// The application is already running |
|
|
|
// The application is already running |
|
|
|
|
|
|
|
// TODO: Display message box or change focus to existing application instance |
|
|
|
} |
|
|
|
} |
|
|
|
} // releases the Mutex |
|
|
|
} // releases the Mutex |
|
|
|
} |
|
|
|
} |
|
|
@ -103,7 +103,7 @@ namespace ${StandardNamespace} |
|
|
|
Application.Exit(); |
|
|
|
Application.Exit(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void TrayIconDoubleClick(object sender, EventArgs e) |
|
|
|
private void IconDoubleClick(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MessageBox.Show("The icon was double clicked"); |
|
|
|
MessageBox.Show("The icon was double clicked"); |
|
|
|
} |
|
|
|
} |
|
|
@ -112,7 +112,7 @@ namespace ${StandardNamespace} |
|
|
|
} |
|
|
|
} |
|
|
|
]]> |
|
|
|
]]> |
|
|
|
</File> |
|
|
|
</File> |
|
|
|
<File name="SysTrayIcon.resx" src="NotifyIconResources.resx" buildAction="EmbeddedResource" DependentUpon="SysTrayIcon.cs" /> |
|
|
|
<File name="NotificationIcon.resx" src="NotifyIconResources.resx" buildAction="EmbeddedResource" DependentUpon="NotificationIcon.cs" /> |
|
|
|
<File name="AssemblyInfo.cs" src="DefaultAssemblyInfo.cs" /> |
|
|
|
<File name="AssemblyInfo.cs" src="DefaultAssemblyInfo.cs" /> |
|
|
|
</Files> |
|
|
|
</Files> |
|
|
|
</Project> |
|
|
|
</Project> |
|
|
|