mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-09-29 16:51:18 +13:00
[Feature] Mouse disturbing while using keys (#69) ,version 0.10.3.0
This commit is contained in:
parent
a341d3edd8
commit
783b9b690a
4 changed files with 55 additions and 30 deletions
|
@ -469,7 +469,7 @@ namespace SystemTrayMenu.Business
|
||||||
dgv.CellMouseEnter += Dgv_CellMouseEnter;
|
dgv.CellMouseEnter += Dgv_CellMouseEnter;
|
||||||
void Dgv_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
|
void Dgv_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
|
||||||
{
|
{
|
||||||
if (menus[0].IsUsable)
|
if (menus[0].IsUsable && waitToOpenMenu.MouseActive)
|
||||||
{
|
{
|
||||||
if (keyboardInput.InUse)
|
if (keyboardInput.InUse)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,82 +12,101 @@ namespace SystemTrayMenu.Handler
|
||||||
internal event Action<RowData> StartLoadMenu;
|
internal event Action<RowData> StartLoadMenu;
|
||||||
internal event EventHandlerEmpty StopLoadMenu;
|
internal event EventHandlerEmpty StopLoadMenu;
|
||||||
|
|
||||||
private readonly Timer timer = new Timer();
|
private readonly Timer timerStartLoad = new Timer();
|
||||||
private DataGridView dgv = null;
|
private DataGridView dgv = null;
|
||||||
private int rowIndex = 0;
|
private int rowIndex = 0;
|
||||||
|
|
||||||
private bool mouseActive = false;
|
internal bool MouseActive = false;
|
||||||
|
private int mouseMoveEvents = 0;
|
||||||
|
private DateTime dateTimeLastMouseMoveEvent = DateTime.Now;
|
||||||
private bool checkForMouseActive = false;
|
private bool checkForMouseActive = false;
|
||||||
|
|
||||||
internal WaitToLoadMenu()
|
internal WaitToLoadMenu()
|
||||||
{
|
{
|
||||||
timer.Interval = 200;
|
timerStartLoad.Interval = 200;
|
||||||
timer.Tick += WaitOpen_Tick;
|
timerStartLoad.Tick += WaitStartLoad_Tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void MouseEnter(object sender, DataGridViewCellEventArgs e)
|
internal void MouseEnter(object sender, DataGridViewCellEventArgs e)
|
||||||
{
|
{
|
||||||
timer.Stop();
|
timerStartLoad.Stop();
|
||||||
StopLoadMenu.Invoke();
|
StopLoadMenu.Invoke();
|
||||||
SetData((DataGridView)sender, e.RowIndex);
|
SetData((DataGridView)sender, e.RowIndex, MouseActive);
|
||||||
checkForMouseActive = true;
|
checkForMouseActive = true;
|
||||||
timer.Start();
|
timerStartLoad.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RowSelected(DataGridView dgv, int rowIndex)
|
internal void RowSelected(DataGridView dgv, int rowIndex)
|
||||||
{
|
{
|
||||||
timer.Stop();
|
timerStartLoad.Stop();
|
||||||
StopLoadMenu.Invoke();
|
StopLoadMenu.Invoke();
|
||||||
SetData(dgv, rowIndex);
|
SetData(dgv, rowIndex);
|
||||||
mouseActive = false;
|
MouseActive = false;
|
||||||
checkForMouseActive = false;
|
checkForMouseActive = false;
|
||||||
timer.Start();
|
timerStartLoad.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void MouseLeave(object sender, DataGridViewCellEventArgs e)
|
internal void MouseLeave(object sender, DataGridViewCellEventArgs e)
|
||||||
{
|
{
|
||||||
timer.Stop();
|
timerStartLoad.Stop();
|
||||||
StopLoadMenu.Invoke();
|
StopLoadMenu.Invoke();
|
||||||
ResetData((DataGridView)sender, e.RowIndex);
|
ResetData((DataGridView)sender, e.RowIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RowDeselected(int iMenuBefore, int rowIndex, DataGridView dgv) //iMenuBefore not needed
|
internal void RowDeselected(int iMenuBefore, int rowIndex, DataGridView dgv) //iMenuBefore not needed
|
||||||
{
|
{
|
||||||
timer.Stop();
|
timerStartLoad.Stop();
|
||||||
StopLoadMenu.Invoke();
|
StopLoadMenu.Invoke();
|
||||||
ResetData(dgv, rowIndex);
|
ResetData(dgv, rowIndex);
|
||||||
mouseActive = false;
|
MouseActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ClickOpensInstantly(DataGridView dgv, int rowIndex)
|
internal void ClickOpensInstantly(DataGridView dgv, int rowIndex)
|
||||||
{
|
{
|
||||||
timer.Stop();
|
timerStartLoad.Stop();
|
||||||
StopLoadMenu.Invoke();
|
StopLoadMenu.Invoke();
|
||||||
SetData(dgv, rowIndex);
|
SetData(dgv, rowIndex);
|
||||||
mouseActive = true;
|
MouseActive = true;
|
||||||
checkForMouseActive = false;
|
checkForMouseActive = false;
|
||||||
CallOpenMenuNow();
|
CallOpenMenuNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void EnterOpensInstantly(DataGridView dgv, int rowIndex)
|
internal void EnterOpensInstantly(DataGridView dgv, int rowIndex)
|
||||||
{
|
{
|
||||||
timer.Stop();
|
timerStartLoad.Stop();
|
||||||
StopLoadMenu.Invoke();
|
StopLoadMenu.Invoke();
|
||||||
SetData(dgv, rowIndex);
|
SetData(dgv, rowIndex);
|
||||||
mouseActive = false;
|
MouseActive = false;
|
||||||
checkForMouseActive = false;
|
checkForMouseActive = false;
|
||||||
CallOpenMenuNow();
|
CallOpenMenuNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void MouseMove(object sender, MouseEventArgs e)
|
internal void MouseMove(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
mouseActive = true;
|
if (!MouseActive)
|
||||||
|
{
|
||||||
|
if (mouseMoveEvents > 3)
|
||||||
|
{
|
||||||
|
MouseActive = true;
|
||||||
|
mouseMoveEvents = 0;
|
||||||
|
}
|
||||||
|
else if (DateTime.Now - dateTimeLastMouseMoveEvent <
|
||||||
|
new TimeSpan(0, 0, 0, 0, 200))
|
||||||
|
{
|
||||||
|
mouseMoveEvents++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dateTimeLastMouseMoveEvent = DateTime.Now;
|
||||||
|
mouseMoveEvents = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WaitOpen_Tick(object sender, EventArgs e)
|
private void WaitStartLoad_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
timer.Stop();
|
timerStartLoad.Stop();
|
||||||
if (!checkForMouseActive || mouseActive)
|
if (!checkForMouseActive || MouseActive)
|
||||||
{
|
{
|
||||||
CallOpenMenuNow();
|
CallOpenMenuNow();
|
||||||
}
|
}
|
||||||
|
@ -109,14 +128,17 @@ namespace SystemTrayMenu.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetData(DataGridView dgv, int rowIndex)
|
private void SetData(DataGridView dgv, int rowIndex, bool select = true)
|
||||||
{
|
{
|
||||||
this.dgv = dgv;
|
this.dgv = dgv;
|
||||||
this.rowIndex = rowIndex;
|
this.rowIndex = rowIndex;
|
||||||
RowData rowData = (RowData)dgv.Rows[rowIndex].Cells[2].Value;
|
RowData rowData = (RowData)dgv.Rows[rowIndex].Cells[2].Value;
|
||||||
|
if (select)
|
||||||
|
{
|
||||||
rowData.IsSelected = true;
|
rowData.IsSelected = true;
|
||||||
dgv.Rows[rowIndex].Selected = true;
|
dgv.Rows[rowIndex].Selected = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ResetData(DataGridView dgv, int rowIndex)
|
private void ResetData(DataGridView dgv, int rowIndex)
|
||||||
{
|
{
|
||||||
|
@ -132,8 +154,8 @@ namespace SystemTrayMenu.Handler
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
timer.Stop();
|
timerStartLoad.Stop();
|
||||||
timer.Dispose();
|
timerStartLoad.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -35,5 +35,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.10.2.8")]
|
[assembly: AssemblyVersion("0.10.3.0")]
|
||||||
[assembly: AssemblyFileVersion("0.10.2.8")]
|
[assembly: AssemblyFileVersion("0.10.3.0")]
|
||||||
|
|
|
@ -43,9 +43,12 @@ namespace SystemTrayMenu.UserInterface
|
||||||
{
|
{
|
||||||
fading.ChangeOpacity += Fading_ChangeOpacity;
|
fading.ChangeOpacity += Fading_ChangeOpacity;
|
||||||
void Fading_ChangeOpacity(object sender, double newOpacity)
|
void Fading_ChangeOpacity(object sender, double newOpacity)
|
||||||
|
{
|
||||||
|
if(IsUsable)
|
||||||
{
|
{
|
||||||
Opacity = newOpacity;
|
Opacity = newOpacity;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fading.Show += Fading_Show;
|
fading.Show += Fading_Show;
|
||||||
void Fading_Show()
|
void Fading_Show()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue