mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-09-30 09:06:32 +13:00
This commit is contained in:
parent
da92bd8a38
commit
68ce47fb09
5 changed files with 65 additions and 8 deletions
|
@ -24,6 +24,8 @@ namespace SystemTrayMenu.Handler
|
||||||
public int iMenuKey = 0;
|
public int iMenuKey = 0;
|
||||||
string KeySearchString = string.Empty;
|
string KeySearchString = string.Empty;
|
||||||
|
|
||||||
|
public bool InUse = false;
|
||||||
|
|
||||||
public KeyboardInput(Menu[] menus)
|
public KeyboardInput(Menu[] menus)
|
||||||
{
|
{
|
||||||
this.menus = menus;
|
this.menus = menus;
|
||||||
|
@ -363,6 +365,16 @@ namespace SystemTrayMenu.Handler
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Select(DataGridView dgv, int i)
|
||||||
|
{
|
||||||
|
iRowKey = i;
|
||||||
|
iMenuKey = ((Menu)dgv.TopLevelControl).Level;
|
||||||
|
DataGridViewRow row = dgv.Rows[i];
|
||||||
|
RowData rowData = (RowData)row.Tag;
|
||||||
|
rowData.IsSelectedByKeyboard = true;
|
||||||
|
row.Selected = true;
|
||||||
|
}
|
||||||
|
|
||||||
private bool Select(DataGridView dgv, int i,
|
private bool Select(DataGridView dgv, int i,
|
||||||
string keyInput = "")
|
string keyInput = "")
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Windows.Forms;
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace SystemTrayMenu
|
namespace SystemTrayMenu
|
||||||
{
|
{
|
||||||
|
@ -13,6 +14,8 @@ namespace SystemTrayMenu
|
||||||
public event EventHandler MouseMove;
|
public event EventHandler MouseMove;
|
||||||
public event EventHandler ScrollBarMouseMove;
|
public event EventHandler ScrollBarMouseMove;
|
||||||
|
|
||||||
|
Point cursorPosition = new Point();
|
||||||
|
|
||||||
public bool PreFilterMessage(ref Message message)
|
public bool PreFilterMessage(ref Message message)
|
||||||
{
|
{
|
||||||
if (message.Msg == WM_MOUSELEAVE)
|
if (message.Msg == WM_MOUSELEAVE)
|
||||||
|
@ -20,9 +23,14 @@ namespace SystemTrayMenu
|
||||||
MouseLeave?.Invoke();
|
MouseLeave?.Invoke();
|
||||||
}
|
}
|
||||||
else if (message.Msg == WM_MOUSEMOVE)
|
else if (message.Msg == WM_MOUSEMOVE)
|
||||||
|
{
|
||||||
|
Point newCursorPosition = Cursor.Position;
|
||||||
|
if (!newCursorPosition.Equals(cursorPosition))
|
||||||
{
|
{
|
||||||
MouseMove?.Invoke();
|
MouseMove?.Invoke();
|
||||||
}
|
}
|
||||||
|
cursorPosition = newCursorPosition;
|
||||||
|
}
|
||||||
else if (message.Msg == WM_NCMOUSEMOVE)
|
else if (message.Msg == WM_NCMOUSEMOVE)
|
||||||
{
|
{
|
||||||
ScrollBarMouseMove?.Invoke();
|
ScrollBarMouseMove?.Invoke();
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace SystemTrayMenu
|
||||||
// windows explorer highlighted text
|
// windows explorer highlighted text
|
||||||
public static Color FolderOpen = Color.FromArgb(229, 243, 255);
|
public static Color FolderOpen = Color.FromArgb(229, 243, 255);
|
||||||
public static Color Background = Color.FromArgb(229, 243, 255);
|
public static Color Background = Color.FromArgb(229, 243, 255);
|
||||||
internal static Color KeyBoardSelection = Color.Yellow;
|
internal static Color KeyBoardSelection = Color.FromArgb(204, 232, 255);
|
||||||
internal static int KeySearchInterval = 1000;
|
internal static int KeySearchInterval = 1000;
|
||||||
public const int MenuRowsHeight = 18;
|
public const int MenuRowsHeight = 18;
|
||||||
public const int LengthMax = 37;
|
public const int LengthMax = 37;
|
||||||
|
|
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.9.1.260")]
|
[assembly: AssemblyVersion("0.9.2.0")]
|
||||||
[assembly: AssemblyFileVersion("0.9.1.260")]
|
[assembly: AssemblyFileVersion("0.9.2.0")]
|
||||||
|
|
|
@ -39,6 +39,9 @@ namespace SystemTrayMenu
|
||||||
BackgroundWorker worker = new BackgroundWorker();
|
BackgroundWorker worker = new BackgroundWorker();
|
||||||
Screen screen = Screen.PrimaryScreen;
|
Screen screen = Screen.PrimaryScreen;
|
||||||
|
|
||||||
|
DataGridView dgvFromLastMouseEvent = null;
|
||||||
|
DataGridViewCellEventArgs cellEventArgsFromLastMouseEvent = null;
|
||||||
|
|
||||||
public SystemTrayMenu(ref bool cancelAppRun)
|
public SystemTrayMenu(ref bool cancelAppRun)
|
||||||
{
|
{
|
||||||
log.Info("Application Start " +
|
log.Info("Application Start " +
|
||||||
|
@ -63,6 +66,7 @@ namespace SystemTrayMenu
|
||||||
keyboardInput.RowSelected += KeyboardInputRowSelected;
|
keyboardInput.RowSelected += KeyboardInputRowSelected;
|
||||||
void KeyboardInputRowSelected(DataGridView dgv, int rowIndex)
|
void KeyboardInputRowSelected(DataGridView dgv, int rowIndex)
|
||||||
{
|
{
|
||||||
|
keyboardInput.InUse = true;
|
||||||
FadeInIfNeeded();
|
FadeInIfNeeded();
|
||||||
CheckMenuOpenerStart(dgv, rowIndex);
|
CheckMenuOpenerStart(dgv, rowIndex);
|
||||||
}
|
}
|
||||||
|
@ -206,6 +210,23 @@ namespace SystemTrayMenu
|
||||||
}
|
}
|
||||||
|
|
||||||
messageFilter.MouseMove += FadeInIfNeeded;
|
messageFilter.MouseMove += FadeInIfNeeded;
|
||||||
|
messageFilter.MouseMove += MessageFilter_MouseMove;
|
||||||
|
void MessageFilter_MouseMove()
|
||||||
|
{
|
||||||
|
if (keyboardInput.InUse)
|
||||||
|
{
|
||||||
|
CheckMenuOpenerStop(keyboardInput.iMenuKey,
|
||||||
|
keyboardInput.iRowKey);
|
||||||
|
keyboardInput.ClearIsSelectedByKey();
|
||||||
|
|
||||||
|
keyboardInput.InUse = false;
|
||||||
|
if (dgvFromLastMouseEvent != null)
|
||||||
|
{
|
||||||
|
Dgv_MouseEnter(dgvFromLastMouseEvent,
|
||||||
|
cellEventArgsFromLastMouseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
messageFilter.ScrollBarMouseMove += FadeInIfNeeded;
|
messageFilter.ScrollBarMouseMove += FadeInIfNeeded;
|
||||||
|
|
||||||
messageFilter.MouseLeave += fastLeave.Start;
|
messageFilter.MouseLeave += fastLeave.Start;
|
||||||
|
@ -570,8 +591,17 @@ namespace SystemTrayMenu
|
||||||
private void Dgv_MouseEnter(object sender, DataGridViewCellEventArgs e)
|
private void Dgv_MouseEnter(object sender, DataGridViewCellEventArgs e)
|
||||||
{
|
{
|
||||||
DataGridView dgv = (DataGridView)sender;
|
DataGridView dgv = (DataGridView)sender;
|
||||||
|
dgvFromLastMouseEvent = dgv;
|
||||||
|
cellEventArgsFromLastMouseEvent = e;
|
||||||
|
|
||||||
|
if (!keyboardInput.InUse)
|
||||||
|
{
|
||||||
|
keyboardInput.ClearIsSelectedByKey();
|
||||||
|
keyboardInput.Select(dgv, e.RowIndex);
|
||||||
|
|
||||||
CheckMenuOpenerStart(dgv, e.RowIndex);
|
CheckMenuOpenerStart(dgv, e.RowIndex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckMenuOpenerStart(DataGridView dgv, int rowIndex)
|
private void CheckMenuOpenerStart(DataGridView dgv, int rowIndex)
|
||||||
{
|
{
|
||||||
|
@ -611,10 +641,17 @@ namespace SystemTrayMenu
|
||||||
private void Dgv_MouseLeave(object sender, DataGridViewCellEventArgs e)
|
private void Dgv_MouseLeave(object sender, DataGridViewCellEventArgs e)
|
||||||
{
|
{
|
||||||
DataGridView dgv = (DataGridView)sender;
|
DataGridView dgv = (DataGridView)sender;
|
||||||
|
|
||||||
|
if (!keyboardInput.InUse)
|
||||||
|
{
|
||||||
Menu menu = (Menu)dgv.FindForm();
|
Menu menu = (Menu)dgv.FindForm();
|
||||||
CheckMenuOpenerStop(menu.Level, e.RowIndex, dgv);
|
CheckMenuOpenerStop(menu.Level, e.RowIndex, dgv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dgvFromLastMouseEvent = null;
|
||||||
|
cellEventArgsFromLastMouseEvent = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckMenuOpenerStop(int menuIndex, int rowIndex, DataGridView dgv = null)
|
private void CheckMenuOpenerStop(int menuIndex, int rowIndex, DataGridView dgv = null)
|
||||||
{
|
{
|
||||||
Menu menu = menus[menuIndex];
|
Menu menu = menus[menuIndex];
|
||||||
|
|
Loading…
Reference in a new issue