Ejemplo n.º 1
0
        public static void AttachToSystemTray()
        {
            var ctx = new ContextMenu();

            var menuExit = new MenuItem
            {
                Text = TextResource.GetText("MENU_EXIT")
            };

            menuExit.Click += (_, _) => Environment.Exit(0);

            var menuRestore = new MenuItem
            {
                Text = TextResource.GetText("MSG_RESTORE")
            };

            menuRestore.Click += (sender, e) => TrayClick?.Invoke(sender, e);

            ctx.MenuItems.Add(menuRestore);
            ctx.MenuItems.Add(menuExit);

            notifyIcon = new NotifyIcon
            {
                Text        = "XDM",
                Visible     = true,
                Icon        = new Icon(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "xdm-logo.ico")),
                ContextMenu = ctx
            };
            notifyIcon.MouseClick += NotifyIcon_MouseClick;
        }
Ejemplo n.º 2
0
 private static void NotifyIcon_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         TrayClick?.Invoke(sender, e);
     }
 }
Ejemplo n.º 3
0
 void NotifyIcon1_MouseClick(object sender, MouseEventArgs e)
 {
     TrayClick?.Invoke(this, e);
 }
Ejemplo n.º 4
0
 void NotifyIcon1_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     TrayClick?.Invoke(this, e);
 }