91287c9860
* Fix startup binding and prep v1.2.0 * Polish v1.2.0 validation UX * Fix final v1.2.0 validation polish * Make Activity Logs a ThreadPilot audit trail * Fix high scheduling registry value * Polish process list and automation settings UX * Fix process context menu separator styling * Theme process context menu visuals * Stabilize process context menu styling * Remove process menu icon gutter * Polish startup and idle process refresh * Finalize PR22 release polish
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
namespace ThreadPilot.Services
|
|
{
|
|
using System.Drawing;
|
|
|
|
public static class SystemTrayMenuPlacement
|
|
{
|
|
public static Point ResolveMenuOpenPoint(Point cursorPosition, Point lastKnownPosition)
|
|
{
|
|
return ResolveMenuOpenPoint(
|
|
cursorPosition,
|
|
lastKnownPosition,
|
|
Rectangle.Empty,
|
|
Rectangle.Empty);
|
|
}
|
|
|
|
public static Point ResolveMenuOpenPoint(
|
|
Point cursorPosition,
|
|
Point lastKnownPosition,
|
|
Rectangle trayBounds,
|
|
Rectangle fallbackWorkingArea)
|
|
{
|
|
if (!cursorPosition.IsEmpty)
|
|
{
|
|
return cursorPosition;
|
|
}
|
|
|
|
if (!lastKnownPosition.IsEmpty)
|
|
{
|
|
return lastKnownPosition;
|
|
}
|
|
|
|
if (!trayBounds.IsEmpty)
|
|
{
|
|
return new Point(trayBounds.Left + (trayBounds.Width / 2), trayBounds.Top + (trayBounds.Height / 2));
|
|
}
|
|
|
|
if (!fallbackWorkingArea.IsEmpty)
|
|
{
|
|
return new Point(
|
|
Math.Max(fallbackWorkingArea.Left + 1, fallbackWorkingArea.Right - 8),
|
|
Math.Max(fallbackWorkingArea.Top + 1, fallbackWorkingArea.Bottom - 8));
|
|
}
|
|
|
|
return new Point(16, 16);
|
|
}
|
|
}
|
|
}
|