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(); }
private void NotifyIcon_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Show(); } else { NotifyIconContextMenu.Show(MousePosition); } }
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; } }
private void NotifyIconContextMenu_MouseLeave(object sender, EventArgs e) { System.Threading.Thread.Sleep(500); NotifyIconContextMenu.Hide(); }