From 65159276d767ca5ffdb45b96f0050a15734aec4b Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Mon, 22 Jun 2020 21:52:35 +0200 Subject: [PATCH] #110, #111, version 0.11.1.1 [BUG] ArgumentOutOfRangeException #110 [BUG] AutosizeRows when high dpi #111 --- Business/WaitToLoadMenu.cs | 15 +++++++++------ UserInterface/Menu.cs | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Business/WaitToLoadMenu.cs b/Business/WaitToLoadMenu.cs index b678636..f508a55 100644 --- a/Business/WaitToLoadMenu.cs +++ b/Business/WaitToLoadMenu.cs @@ -89,12 +89,15 @@ namespace SystemTrayMenu.Handler internal void EnterOpensInstantly(DataGridView dgv, int rowIndex) { - timerStartLoad.Stop(); - StopLoadMenu.Invoke(); - SetData(dgv, rowIndex); - MouseActive = false; - checkForMouseActive = false; - CallOpenMenuNow(); + if (dgv.Rows.Count > rowIndex) + { + timerStartLoad.Stop(); + StopLoadMenu.Invoke(); + SetData(dgv, rowIndex); + MouseActive = false; + checkForMouseActive = false; + CallOpenMenuNow(); + } } internal void MouseMove(object sender, MouseEventArgs e) diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index 2ae96b8..fcecda6 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -37,7 +37,6 @@ namespace SystemTrayMenu.UserInterface private readonly Fading fading = new Fading(); private bool isShowing = false; - private bool dgvAutoResizeRowDone = false; internal Menu() { @@ -242,10 +241,14 @@ namespace SystemTrayMenu.UserInterface internal void AdjustSizeAndLocation(Menu menuPredecessor = null, bool directionToRight = false) { - if (!dgvAutoResizeRowDone) + CheckForAutoResizeRowDone(); + void CheckForAutoResizeRowDone() { - dgv.AutoResizeRows(); - dgvAutoResizeRowDone = true; + if (!(bool)dgv.Tag) + { + dgv.AutoResizeRows(); + dgv.Tag = true; + } } int dgvHeightNeeded = dgv.Rows.GetRowsHeight( @@ -277,14 +280,14 @@ namespace SystemTrayMenu.UserInterface { if (directionToRight) { - x = menuPredecessor.Location.X + + x = menuPredecessor.Location.X + menuPredecessor.Width - (int)Math.Round(Scaling.Factor, 0, MidpointRounding.AwayFromZero); } else { - x = menuPredecessor.Location.X - + x = menuPredecessor.Location.X - Width + (int)Math.Round(Scaling.Factor, 0, MidpointRounding.AwayFromZero);