diff --git a/Business/Menus.cs b/Business/Menus.cs index c4f9835..8526867 100644 --- a/Business/Menus.cs +++ b/Business/Menus.cs @@ -757,7 +757,7 @@ namespace SystemTrayMenu.Business widthPredecessors -= newWith; } - menu.AdjustSizeAndLocation(menuPredecessor); + menu.AdjustSizeAndLocation(menuPredecessor, directionToRight); widthPredecessors += menu.Width - menu.Padding.Left; menuPredecessor = menu; } diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index 54f9b41..09af8fd 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -237,7 +237,8 @@ namespace SystemTrayMenu.UserInterface } } - internal void AdjustSizeAndLocation(Menu menuPredecessor = null) + internal void AdjustSizeAndLocation(Menu menuPredecessor = null, + bool directionToRight = false) { if (!dgvAutoResizeRowDone) { @@ -272,9 +273,24 @@ namespace SystemTrayMenu.UserInterface } else { - x = menuPredecessor.Location.X - Width + - (int)Math.Round(Scaling.Factor, 0, - MidpointRounding.AwayFromZero); + if (directionToRight) + { + 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;