Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace NotifyIconKanthesh
- {
- /// <summary>
- /// Interaction logic for App.xaml
- /// </summary>
- public partial class App : Application
- {
- /// <summary>
- /// Represents the notify icon for the applicaion.
- /// </summary>
- private System.Windows.Forms.NotifyIcon notify;
- public App()
- {
- }
- /// <summary>
- /// Raises the <see cref="E:System.Windows.Application.Exit"/> event.
- /// </summary>
- /// <param name="e">An <see cref="T:System.Windows.ExitEventArgs"/> that contains the event data.</param>
- protected override void OnExit(ExitEventArgs e)
- {
- if (this.notify != null)
- {
- this.notify.Dispose();
- }
- base.OnExit(e);
- }
- /// <summary>
- /// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
- /// </summary>
- /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
- protected override void OnStartup(StartupEventArgs e)
- {
- base.OnStartup(e);
- InitializeNotifyIcon();
- }
- private void InitializeNotifyIcon()
- {
- notify = new System.Windows.Forms.NotifyIcon();
- notify.Text = "Kanthesha Murthy";
- notify.Icon = NotifyIconKanthesh.Properties.Resources.Error;
- notify.Visible = true;
- notify.ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[]
- {
- new System.Windows.Forms.MenuItem("Show compass", (s, e) => this.MainWindow.Show()),
- new System.Windows.Forms.MenuItem("Hide compass", (s, e) => this.MainWindow.Hide()),
- new System.Windows.Forms.MenuItem("-"),
- new System.Windows.Forms.MenuItem("Close", (s, e) => this.Shutdown())
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement