private static void NotifyIcon_MouseClick(object sender, MouseEventArgs e)
        {
            if (_contextMenu != null)
            {
                _contextMenu.Close();
            }
            _contextMenu = new NotifyIconContextMenu(_toolViewModel);

            POINT p = new POINT();

            GetCursorPos(ref p);
            double x       = p.X;
            double y       = p.Y;
            var    w       = _contextMenu.Width;
            var    h       = _contextMenu.Height;
            var    scrInfo = DisplayDevices.GetCurrentScreenInfo(x, y);
            var    r       = scrInfo.WorkArea;

            if (w + x > r.Right)
            {
                x += r.Right - (w + x) + AppSettings.NotifyIconContextMenuDx;
            }
            if (h + y > r.Bottom)
            {
                y += r.Bottom - (h + y) + AppSettings.NotifyIconContextMenuDy;
            }
            _contextMenu.Left = x;
            _contextMenu.Top  = y;
#if alldbg || dbg
            DesktopPanelTool.Lib.Debug.WriteLine($"scr={scrInfo}");
            DesktopPanelTool.Lib.Debug.WriteLine($"x={x} y={y} w={w} h={h}");
#endif
            _contextMenu.Show();
        }
Esempio n. 2
0
File: Main.cs Progetto: Soju06/NUMC
 private void NotifyIcon_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         Show();
     }
     else
     {
         NotifyIconContextMenu.Show(MousePosition);
     }
 }
Esempio n. 3
0
 private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         NotifyIconContextMenu.Show(Cursor.Position.X, Cursor.Position.Y);
     }
     else if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         this.Show();
         WindowState         = FormWindowState.Normal;
         notifyIcon1.Visible = false;
     }
 }
Esempio n. 4
0
 private void NotifyIconContextMenu_MouseLeave(object sender, EventArgs e)
 {
     System.Threading.Thread.Sleep(500);
     NotifyIconContextMenu.Hide();
 }