Skip to content

Commit

Permalink
Close submenus and improve selection (#112), version 0.11.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofknecht committed Jun 25, 2020
1 parent 4a47181 commit 2e72322
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
26 changes: 21 additions & 5 deletions Business/Menus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ void LoadSubMenuCompleted(object senderCompleted,
}
}

waitToOpenMenu.CloseMenu += CloseMenu;
void CloseMenu(int level)
{
if (menus[level] != null)
{
menus[level - 1].FocusTextBox();
HideOldMenu(menus[level]);
}
}

keyboardInput = new KeyboardInput(menus);
keyboardInput.RegisterHotKey();
keyboardInput.HotKeyPressed += KeyboardInput_HotKeyPressed;
Expand Down Expand Up @@ -588,6 +598,15 @@ private void RefreshSelection(DataGridView dgv)
}

private void ShowSubMenu(Menu menuToShow)
{
HideOldMenu(menuToShow, true);

menus[menuToShow.Level] = menuToShow;
AdjustMenusSizeAndLocation();
menus[menuToShow.Level].ShowWithFadeOrTransparent(IsActive());
}

private void HideOldMenu(Menu menuToShow, bool keepOrSetIsMenuOpen = false)
{
//Clean up menu status IsMenuOpen for previous one
Menu menuPrevious = menus[menuToShow.Level - 1];
Expand All @@ -597,7 +616,7 @@ private void ShowSubMenu(Menu menuToShow)
RowData rowDataToClear = (RowData)row[2];
if (rowDataToClear == (RowData)menuToShow.Tag)
{
rowDataToClear.IsMenuOpen = true;
rowDataToClear.IsMenuOpen = keepOrSetIsMenuOpen;
}
else
{
Expand All @@ -606,17 +625,14 @@ private void ShowSubMenu(Menu menuToShow)
}
RefreshSelection(dgvPrevious);

//Hide old menu
foreach (Menu menuToClose in menus.Where(
m => m != null && m.Level > menuPrevious.Level))
{
menuToClose.VisibleChanged += MenuVisibleChanged;
menuToClose.HideWithFade();
menus[menuToClose.Level] = null;
}

menus[menuToShow.Level] = menuToShow;
AdjustMenusSizeAndLocation();
menus[menuToShow.Level].ShowWithFadeOrTransparent(IsActive());
}

private void FadeInIfNeeded()
Expand Down
10 changes: 10 additions & 0 deletions Business/WaitToLoadMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace SystemTrayMenu.Handler
internal class WaitToLoadMenu : IDisposable
{
internal event Action<RowData> StartLoadMenu;
internal event Action<int> CloseMenu;
internal event EventHandlerEmpty StopLoadMenu;
internal event Action<DataGridView, int> MouseEnterOk;

Expand Down Expand Up @@ -143,6 +144,15 @@ private void CallOpenMenuNow()
RowData rowData = (RowData)dgv.Rows[rowIndex].Cells[2].Value;
Menu menu = (Menu)dgv.FindForm();
rowData.MenuLevel = menu.Level;
if (rowData.ContainsMenu)
{
CloseMenu.Invoke(rowData.MenuLevel + 2);
}
else
{
CloseMenu.Invoke(rowData.MenuLevel + 1);
}

if (!rowData.IsContextMenuOpen &&
rowData.ContainsMenu &&
rowData.MenuLevel + 1 < MenuDefines.MenusMax)
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// 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.4")]
[assembly: AssemblyFileVersion("0.11.1.4")]
[assembly: AssemblyVersion("0.11.1.5")]
[assembly: AssemblyFileVersion("0.11.1.5")]

0 comments on commit 2e72322

Please sign in to comment.