Fix using direction when reach screen border (#94)

This commit is contained in:
Markus Hofknecht 2020-06-06 19:50:01 +02:00
parent b2937153c9
commit fd34b400e1
2 changed files with 21 additions and 5 deletions

View file

@ -757,7 +757,7 @@ namespace SystemTrayMenu.Business
widthPredecessors -= newWith; widthPredecessors -= newWith;
} }
menu.AdjustSizeAndLocation(menuPredecessor); menu.AdjustSizeAndLocation(menuPredecessor, directionToRight);
widthPredecessors += menu.Width - menu.Padding.Left; widthPredecessors += menu.Width - menu.Padding.Left;
menuPredecessor = menu; menuPredecessor = menu;
} }

View file

@ -237,7 +237,8 @@ namespace SystemTrayMenu.UserInterface
} }
} }
internal void AdjustSizeAndLocation(Menu menuPredecessor = null) internal void AdjustSizeAndLocation(Menu menuPredecessor = null,
bool directionToRight = false)
{ {
if (!dgvAutoResizeRowDone) if (!dgvAutoResizeRowDone)
{ {
@ -272,9 +273,24 @@ namespace SystemTrayMenu.UserInterface
} }
else else
{ {
x = menuPredecessor.Location.X - Width + if (directionToRight)
(int)Math.Round(Scaling.Factor, 0, {
MidpointRounding.AwayFromZero); x = menuPredecessor.Location.X + Width -
(int)Math.Round(Scaling.Factor, 0,
MidpointRounding.AwayFromZero);
}
else
{
x = menuPredecessor.Location.X - Width +
(int)Math.Round(Scaling.Factor, 0,
MidpointRounding.AwayFromZero);
}
}
if (x < 0)
{
x += menuPredecessor.Width;
x += Width;
} }
int y; int y;