mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-10 06:24:46 +12:00
[Feature] Clear internal icon cache if too big (#207), version 1.0.20.2
This commit is contained in:
parent
de57fce8f3
commit
d669b15bde
|
@ -128,12 +128,6 @@ namespace SystemTrayMenu.Business
|
|||
{
|
||||
loadingRowData = rowData;
|
||||
|
||||
Menu menuLoading = menus[rowData.MenuLevel + 1];
|
||||
if (menuLoading != null && menuLoading.IsLoadingMenu)
|
||||
{
|
||||
CloseMenu(rowData.MenuLevel + 1);
|
||||
}
|
||||
|
||||
CreateAndShowLoadingMenu(rowData);
|
||||
void CreateAndShowLoadingMenu(RowData rowData)
|
||||
{
|
||||
|
@ -177,7 +171,8 @@ namespace SystemTrayMenu.Business
|
|||
Menu menuLoading = menus[menuData.Level];
|
||||
if (menuLoading != null && menuLoading.IsLoadingMenu)
|
||||
{
|
||||
CloseMenu(menuData.Level);
|
||||
menuLoading.HideWithFade();
|
||||
menus[menuLoading.Level] = null;
|
||||
}
|
||||
|
||||
if (menuData.Validity != MenuDataValidity.AbortedOrUnknown &&
|
||||
|
@ -773,6 +768,12 @@ namespace SystemTrayMenu.Business
|
|||
if (!AsEnumerable.Any(m => m.Visible))
|
||||
{
|
||||
openCloseState = OpenCloseState.Default;
|
||||
|
||||
if (IconReader.ClearIfCacheTooBig())
|
||||
{
|
||||
GC.Collect();
|
||||
MainPreload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -920,7 +921,6 @@ namespace SystemTrayMenu.Business
|
|||
foreach (Menu menuToClose in menus.Where(
|
||||
m => m != null && m.Level > menuPrevious.Level))
|
||||
{
|
||||
menuToClose.VisibleChanged += MenuVisibleChanged;
|
||||
menuToClose.HideWithFade();
|
||||
menus[menuToClose.Level] = null;
|
||||
}
|
||||
|
|
|
@ -39,5 +39,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("1.0.20.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.20.1")]
|
||||
[assembly: AssemblyVersion("1.0.20.2")]
|
||||
[assembly: AssemblyFileVersion("1.0.20.2")]
|
||||
|
|
|
@ -49,6 +49,19 @@ namespace SystemTrayMenu.Utilities
|
|||
}
|
||||
}
|
||||
|
||||
internal static bool ClearIfCacheTooBig()
|
||||
{
|
||||
bool cleared = false;
|
||||
if (DictIconCache.Count > 200)
|
||||
{
|
||||
Dispose();
|
||||
DictIconCache.Clear();
|
||||
cleared = true;
|
||||
}
|
||||
|
||||
return cleared;
|
||||
}
|
||||
|
||||
public static Icon GetFileIconWithCache(string filePath, bool linkOverlay, bool updateIconInBackground, out bool loading)
|
||||
{
|
||||
Icon icon = null;
|
||||
|
|
Loading…
Reference in a new issue