diff --git a/Business/Menus.cs b/Business/Menus.cs index 3b45ddf..b82d6eb 100644 --- a/Business/Menus.cs +++ b/Business/Menus.cs @@ -84,8 +84,8 @@ namespace SystemTrayMenu.Business void StartLoadMenu(RowData rowData) { if (menus[0].IsUsable && - menus[rowData.MenuLevel + 1] == null || - menus[rowData.MenuLevel + 1].Tag as RowData != rowData) + (menus[rowData.MenuLevel + 1] == null || + menus[rowData.MenuLevel + 1].Tag as RowData != rowData)) { LoadStarted(); BackgroundWorker workerSubMenu = workersSubMenu. diff --git a/NativeDllImport/IsTouchEnabled.cs b/NativeDllImport/IsTouchEnabled.cs new file mode 100644 index 0000000..dd0c536 --- /dev/null +++ b/NativeDllImport/IsTouchEnabled.cs @@ -0,0 +1,18 @@ +using System.Runtime.InteropServices; + +namespace SystemTrayMenu.DllImports +{ + public static partial class NativeMethods + { + [DllImport("user32.dll")] + private static extern int GetSystemMetrics(int nIndex); + + public static bool IsTouchEnabled() + { + const int MAXTOUCHES_INDEX = 95; + int maxTouches = GetSystemMetrics(MAXTOUCHES_INDEX); + + return maxTouches > 0; + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index ca0e923..eb18ad5 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.11.1.9")] -[assembly: AssemblyFileVersion("0.11.1.9")] +[assembly: AssemblyVersion("0.11.1.10")] +[assembly: AssemblyFileVersion("0.11.1.10")] diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index 8b6b1b4..bf99202 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -244,25 +244,32 @@ namespace SystemTrayMenu.UserInterface CheckForAutoResizeRowDone(); void CheckForAutoResizeRowDone() { + double factor = 1; + if (NativeMethods.IsTouchEnabled()) + { + factor = 1.5; + } + if (dgv.Tag == null) { if (menuPredecessor == null) { dgv.AutoResizeRows(); + if (factor > 1) + { + dgv.RowTemplate.Height = (int)(dgv.RowTemplate.Height * factor); + foreach (DataGridViewRow row in dgv.Rows) + { + row.Height = dgv.RowTemplate.Height; + } + } dgv.Tag = true; } else { - DataGridView dgvPredecessor = menuPredecessor.GetDataGridView(); - if (dgvPredecessor.Rows.Count > 0) - { - int rowHeight = dgvPredecessor.Rows[0].Height; - foreach (DataGridViewRow row in dgv.Rows) - { - row.Height = rowHeight; - } - dgv.Tag = true; - } + dgv.RowTemplate.Height = menuPredecessor.GetDataGridView(). + RowTemplate.Height; + dgv.Tag = true; } } }