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