mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-20 19:30:31 +12:00
[Feature] Mouse disturbing while using keys (#69) [BUG] Crash when fast mouse movings (#104) [Bug] Reload menu when reenter or click (#103)
This commit is contained in:
parent
4edc72c5f7
commit
fe02510cf6
|
@ -217,7 +217,7 @@ namespace SystemTrayMenu.Handler
|
|||
DataGridView dgv = menu.GetDataGridView();
|
||||
if (dgv.Rows.Count > 0)
|
||||
{
|
||||
Select(dgv, 0);
|
||||
Select(dgv, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ namespace SystemTrayMenu.Handler
|
|||
return found;
|
||||
}
|
||||
|
||||
public void Select(DataGridView dgv, int i)
|
||||
public void Select(DataGridView dgv, int i, bool refreshview)
|
||||
{
|
||||
int newiMenuKey = ((Menu)dgv.TopLevelControl).Level;
|
||||
if (i != iRowKey || newiMenuKey != iMenuKey)
|
||||
|
@ -475,8 +475,11 @@ namespace SystemTrayMenu.Handler
|
|||
DataGridViewRow row = dgv.Rows[i];
|
||||
RowData rowData = (RowData)row.Cells[2].Value;
|
||||
rowData.IsSelected = true;
|
||||
row.Selected = false; //event trigger
|
||||
row.Selected = true; //event trigger
|
||||
if (refreshview)
|
||||
{
|
||||
row.Selected = false; //event trigger
|
||||
row.Selected = true; //event trigger
|
||||
}
|
||||
}
|
||||
|
||||
private bool Select(DataGridView dgv, int i,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Clearcove.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
@ -78,12 +79,13 @@ namespace SystemTrayMenu.Business
|
|||
workerSubMenu.CancelAsync();
|
||||
}
|
||||
}
|
||||
|
||||
waitToOpenMenu.StartLoadMenu += StartLoadMenu;
|
||||
void StartLoadMenu(RowData rowData)
|
||||
{
|
||||
if (menus[0].IsUsable &&
|
||||
menus[rowData.MenuLevel] == null ||
|
||||
menus[rowData.MenuLevel].Tag as RowData != rowData)
|
||||
menus[rowData.MenuLevel + 1] == null ||
|
||||
menus[rowData.MenuLevel + 1].Tag as RowData != rowData)
|
||||
{
|
||||
LoadStarted();
|
||||
BackgroundWorker workerSubMenu = workersSubMenu.
|
||||
|
@ -164,6 +166,7 @@ namespace SystemTrayMenu.Business
|
|||
|
||||
internal void SwitchOpenClose(bool byClick)
|
||||
{
|
||||
waitToOpenMenu.MouseActive = byClick;
|
||||
if (byClick && (DateTime.Now - deactivatedTime).TotalMilliseconds < 200)
|
||||
{
|
||||
//By click on notifyicon the menu gets deactivated and closed
|
||||
|
@ -471,10 +474,10 @@ namespace SystemTrayMenu.Business
|
|||
}
|
||||
DataGridView dgv = menu.GetDataGridView();
|
||||
dgv.CellMouseEnter += waitToOpenMenu.MouseEnter;
|
||||
dgv.CellMouseEnter += Dgv_CellMouseEnter;
|
||||
void Dgv_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
|
||||
waitToOpenMenu.MouseEnterOk += Dgv_CellMouseEnter;
|
||||
void Dgv_CellMouseEnter(DataGridView dgv, int rowIndex)
|
||||
{
|
||||
if (menus[0].IsUsable && waitToOpenMenu.MouseActive)
|
||||
if (menus[0].IsUsable)
|
||||
{
|
||||
if (keyboardInput.InUse)
|
||||
{
|
||||
|
@ -482,7 +485,7 @@ namespace SystemTrayMenu.Business
|
|||
keyboardInput.InUse = false;
|
||||
}
|
||||
|
||||
keyboardInput.Select(dgv, e.RowIndex);
|
||||
keyboardInput.Select(dgv, rowIndex, false);
|
||||
}
|
||||
}
|
||||
dgv.CellMouseLeave += waitToOpenMenu.MouseLeave;
|
||||
|
@ -558,18 +561,18 @@ namespace SystemTrayMenu.Business
|
|||
row.DefaultCellStyle.SelectionBackColor = Color.White;
|
||||
row.Selected = false;
|
||||
}
|
||||
else if (rowData.IsSelected)
|
||||
{
|
||||
row.DefaultCellStyle.SelectionBackColor =
|
||||
MenuDefines.ColorSelectedItem;
|
||||
row.Selected = true;
|
||||
}
|
||||
else if (rowData.IsMenuOpen)
|
||||
{
|
||||
row.DefaultCellStyle.SelectionBackColor =
|
||||
MenuDefines.ColorOpenFolder;
|
||||
row.Selected = true;
|
||||
}
|
||||
else if (rowData.IsSelected)
|
||||
{
|
||||
row.DefaultCellStyle.SelectionBackColor =
|
||||
MenuDefines.ColorSelectedItem;
|
||||
row.Selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
row.DefaultCellStyle.SelectionBackColor = Color.White;
|
||||
|
|
|
@ -11,15 +11,18 @@ namespace SystemTrayMenu.Handler
|
|||
{
|
||||
internal event Action<RowData> StartLoadMenu;
|
||||
internal event EventHandlerEmpty StopLoadMenu;
|
||||
internal event Action<DataGridView, int> MouseEnterOk;
|
||||
|
||||
private readonly Timer timerStartLoad = new Timer();
|
||||
private DataGridView dgv = null;
|
||||
private int rowIndex = 0;
|
||||
private DataGridView dgvTmp = null;
|
||||
private int rowIndexTmp = 0;
|
||||
|
||||
internal bool MouseActive = false;
|
||||
private int mouseMoveEvents = 0;
|
||||
private DateTime dateTimeLastMouseMoveEvent = DateTime.Now;
|
||||
private bool checkForMouseActive = false;
|
||||
private bool checkForMouseActive = true;
|
||||
|
||||
internal WaitToLoadMenu()
|
||||
{
|
||||
|
@ -29,11 +32,21 @@ namespace SystemTrayMenu.Handler
|
|||
|
||||
internal void MouseEnter(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
timerStartLoad.Stop();
|
||||
StopLoadMenu.Invoke();
|
||||
SetData((DataGridView)sender, e.RowIndex, MouseActive);
|
||||
checkForMouseActive = true;
|
||||
timerStartLoad.Start();
|
||||
if (MouseActive)
|
||||
{
|
||||
DataGridView dgv = (DataGridView)sender;
|
||||
MouseEnterOk(dgv, e.RowIndex);
|
||||
timerStartLoad.Stop();
|
||||
StopLoadMenu.Invoke();
|
||||
checkForMouseActive = true;
|
||||
SetData(dgv, e.RowIndex);
|
||||
timerStartLoad.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dgvTmp = (DataGridView)sender;
|
||||
this.rowIndexTmp = e.RowIndex;
|
||||
}
|
||||
}
|
||||
|
||||
internal void RowSelected(DataGridView dgv, int rowIndex)
|
||||
|
@ -48,9 +61,12 @@ namespace SystemTrayMenu.Handler
|
|||
|
||||
internal void MouseLeave(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
timerStartLoad.Stop();
|
||||
StopLoadMenu.Invoke();
|
||||
ResetData((DataGridView)sender, e.RowIndex);
|
||||
if (MouseActive)
|
||||
{
|
||||
timerStartLoad.Stop();
|
||||
StopLoadMenu.Invoke();
|
||||
ResetData((DataGridView)sender, e.RowIndex);
|
||||
}
|
||||
}
|
||||
|
||||
internal void RowDeselected(int iMenuBefore, int rowIndex, DataGridView dgv) //iMenuBefore not needed
|
||||
|
@ -88,6 +104,11 @@ namespace SystemTrayMenu.Handler
|
|||
if (mouseMoveEvents > 3)
|
||||
{
|
||||
MouseActive = true;
|
||||
if (dgvTmp != null && !dgvTmp.IsDisposed)
|
||||
{
|
||||
MouseEnter(dgvTmp, new DataGridViewCellEventArgs(
|
||||
0, rowIndexTmp));
|
||||
}
|
||||
mouseMoveEvents = 0;
|
||||
}
|
||||
else if (DateTime.Now - dateTimeLastMouseMoveEvent <
|
||||
|
@ -128,16 +149,14 @@ namespace SystemTrayMenu.Handler
|
|||
}
|
||||
}
|
||||
|
||||
private void SetData(DataGridView dgv, int rowIndex, bool select = true)
|
||||
private void SetData(DataGridView dgv, int rowIndex)
|
||||
{
|
||||
dgvTmp = null;
|
||||
this.dgv = dgv;
|
||||
this.rowIndex = rowIndex;
|
||||
RowData rowData = (RowData)dgv.Rows[rowIndex].Cells[2].Value;
|
||||
if (select)
|
||||
{
|
||||
rowData.IsSelected = true;
|
||||
dgv.Rows[rowIndex].Selected = true;
|
||||
}
|
||||
rowData.IsSelected = true;
|
||||
dgv.Rows[rowIndex].Selected = true;
|
||||
}
|
||||
|
||||
private void ResetData(DataGridView dgv, int rowIndex)
|
||||
|
@ -156,6 +175,8 @@ namespace SystemTrayMenu.Handler
|
|||
{
|
||||
timerStartLoad.Stop();
|
||||
timerStartLoad.Dispose();
|
||||
dgv.Dispose();
|
||||
dgvTmp.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.11.0.0")]
|
||||
[assembly: AssemblyVersion("0.11.1.0")]
|
||||
[assembly: AssemblyFileVersion("0.11.1.0")]
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace SystemTrayMenu.Utilities
|
|||
public static class IconReader
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, Icon> dictIconCache = new ConcurrentDictionary<string, Icon>();
|
||||
|
||||
private static readonly Object readIcon = new Object();
|
||||
public enum IconSize
|
||||
{
|
||||
Large = 0, //32x32 pixels
|
||||
|
@ -46,18 +46,20 @@ namespace SystemTrayMenu.Utilities
|
|||
{
|
||||
Icon icon = null;
|
||||
string extension = Path.GetExtension(filePath);
|
||||
|
||||
if (IsExtensionWitSameIcon(extension))
|
||||
lock (readIcon)
|
||||
{
|
||||
icon = dictIconCache.GetOrAdd(extension, GetIcon);
|
||||
Icon GetIcon(string keyExtension)
|
||||
if (IsExtensionWitSameIcon(extension))
|
||||
{
|
||||
return GetFileIcon(filePath, linkOverlay, size);
|
||||
icon = dictIconCache.GetOrAdd(extension, GetIcon);
|
||||
Icon GetIcon(string keyExtension)
|
||||
{
|
||||
return GetFileIcon(filePath, linkOverlay, size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = GetFileIcon(filePath, linkOverlay, size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = GetFileIcon(filePath, linkOverlay, size);
|
||||
}
|
||||
|
||||
return icon;
|
||||
|
|
Loading…
Reference in a new issue