You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.5 KiB
121 lines
3.5 KiB
<?xml version="1.0"?> |
|
<Template originator = "Justin Dearing" |
|
created = "25/07/2006" |
|
lastModified = "30/07/2006"> |
|
|
|
<!-- Template Header --> |
|
<TemplateConfiguration> |
|
<Name>${res:Templates.Project.SysTrayIcon.Name}</Name> |
|
<Category>C#</Category> |
|
<Subcategory>${res:Templates.File.Categories.WindowsApplications}</Subcategory> |
|
<Icon>C#.Project.Form</Icon> |
|
<Description>${res:Templates.Project.SysTrayIcon.Description}</Description> |
|
<SupportedTargetFrameworks>v2.0;v3.5Client</SupportedTargetFrameworks> |
|
</TemplateConfiguration> |
|
|
|
<!-- Actions --> |
|
<Actions> |
|
<Open filename = "NotificationIcon.cs"/> |
|
</Actions> |
|
|
|
<Project language="C#"> |
|
<ProjectItems> |
|
<Reference Include="System" /> |
|
<Reference Include="System.Data" /> |
|
<Reference Include="System.Drawing" /> |
|
<Reference Include="System.Windows.Forms" /> |
|
<Reference Include="System.Xml" /> |
|
</ProjectItems> |
|
|
|
<PropertyGroup> |
|
<OutputType>WinExe</OutputType> |
|
<AppDesignerFolder>Properties</AppDesignerFolder> |
|
</PropertyGroup> |
|
|
|
<Files> |
|
<File name="NotificationIcon.cs" language="C#"><![CDATA[${StandardHeader.C#} |
|
using System; |
|
using System.Diagnostics; |
|
using System.Drawing; |
|
using System.Threading; |
|
using System.Windows.Forms; |
|
|
|
namespace ${StandardNamespace} |
|
{ |
|
public sealed class NotificationIcon |
|
{ |
|
private NotifyIcon notifyIcon; |
|
private ContextMenu notificationMenu; |
|
|
|
#region Initialize icon and menu |
|
public NotificationIcon() |
|
{ |
|
notifyIcon = new NotifyIcon(); |
|
notificationMenu = new ContextMenu(InitializeMenu()); |
|
|
|
notifyIcon.DoubleClick += IconDoubleClick; |
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NotificationIcon)); |
|
notifyIcon.Icon = (Icon)resources.GetObject("$this.Icon"); |
|
notifyIcon.ContextMenu = notificationMenu; |
|
} |
|
|
|
private MenuItem[] InitializeMenu() |
|
{ |
|
MenuItem[] menu = new MenuItem[] { |
|
new MenuItem("About", menuAboutClick), |
|
new MenuItem("Exit", menuExitClick) |
|
}; |
|
return menu; |
|
} |
|
#endregion |
|
|
|
#region Main - Program entry point |
|
/// <summary>Program entry point.</summary> |
|
/// <param name="args">Command Line Arguments</param> |
|
[STAThread] |
|
public static void Main(string[] args) |
|
{ |
|
Application.EnableVisualStyles(); |
|
Application.SetCompatibleTextRenderingDefault(false); |
|
|
|
bool isFirstInstance; |
|
// Please use a unique name for the mutex to prevent conflicts with other programs |
|
using (Mutex mtx = new Mutex(true, "${StandardNamespace}", out isFirstInstance)) { |
|
if (isFirstInstance) { |
|
NotificationIcon notificationIcon = new NotificationIcon(); |
|
notificationIcon.notifyIcon.Visible = true; |
|
Application.Run(); |
|
notificationIcon.notifyIcon.Dispose(); |
|
} else { |
|
// The application is already running |
|
// TODO: Display message box or change focus to existing application instance |
|
} |
|
} // releases the Mutex |
|
} |
|
#endregion |
|
|
|
#region Event Handlers |
|
private void menuAboutClick(object sender, EventArgs e) |
|
{ |
|
MessageBox.Show("About This Application"); |
|
} |
|
|
|
private void menuExitClick(object sender, EventArgs e) |
|
{ |
|
Application.Exit(); |
|
} |
|
|
|
private void IconDoubleClick(object sender, EventArgs e) |
|
{ |
|
MessageBox.Show("The icon was double clicked"); |
|
} |
|
#endregion |
|
} |
|
} |
|
]]> |
|
</File> |
|
<File name="NotificationIcon.resx" src="NotifyIconResources.resx" buildAction="EmbeddedResource" DependentUpon="NotificationIcon.cs" /> |
|
<File name="Properties\AssemblyInfo.cs" src="DefaultAssemblyInfo.cs" /> |
|
</Files> |
|
</Project> |
|
</Template>
|
|
|