diff --git a/DataClasses/RowData.cs b/DataClasses/RowData.cs index babe993..e114865 100644 --- a/DataClasses/RowData.cs +++ b/DataClasses/RowData.cs @@ -60,8 +60,6 @@ namespace SystemTrayMenu.DataClasses internal int MenuLevel { get; set; } - internal Icon Icon => icon; - internal bool IconLoading { get; set; } public void Dispose() @@ -82,11 +80,6 @@ namespace SystemTrayMenu.DataClasses DataRow row = dataTable.Rows.Add(); data.RowIndex = dataTable.Rows.IndexOf(row); - if (icon == null) - { - icon = NotFoundIcon; - } - if (HiddenEntry) { row[0] = IconReader.AddIconOverlay( @@ -179,6 +172,11 @@ namespace SystemTrayMenu.DataClasses } } + if (icon == null) + { + icon = NotFoundIcon; + } + return isLnkDirectory; } @@ -242,6 +240,36 @@ namespace SystemTrayMenu.DataClasses } } + internal Icon ReadLoadedIcon() + { + bool showOverlay = false; + string fileExtension = Path.GetExtension(TargetFilePath); + if (fileExtension == ".lnk" || fileExtension == ".url") + { + showOverlay = true; + } + + string path = TargetFilePath; + if (ContainsMenu) + { + path = TargetFilePathOrig; + } + + icon = IconReader.GetFileIconWithCache( + path, + showOverlay, + false, + out bool loading); + IconLoading = loading; + + if (!loading && icon == null) + { + icon = NotFoundIcon; + } + + return icon; + } + protected virtual void Dispose(bool disposing) { if (!isDisposed) diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index 7c42017..78cdac0 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -703,13 +703,6 @@ namespace SystemTrayMenu.UserInterface else { filesCount++; - - if (rowData.IconLoading) - { - string resolvedLnkPath = string.Empty; - rowData.ReadIcon(rowData.ContainsMenu, ref resolvedLnkPath); - row.Cells[0].Value = rowData.Icon; - } } } @@ -816,9 +809,7 @@ namespace SystemTrayMenu.UserInterface if (rowData.IconLoading) { iconsToUpdate++; - string resolvedLnkPath = string.Empty; - rowData.ReadIcon(rowData.ContainsMenu, ref resolvedLnkPath); - row.Cells[0].Value = rowData.Icon; + row.Cells[0].Value = rowData.ReadLoadedIcon(); } } diff --git a/Utilities/File/IconReader.cs b/Utilities/File/IconReader.cs index 7fa0147..7288997 100644 --- a/Utilities/File/IconReader.cs +++ b/Utilities/File/IconReader.cs @@ -26,6 +26,7 @@ namespace SystemTrayMenu.Utilities public static class IconReader { private static readonly ConcurrentDictionary DictIconCache = new ConcurrentDictionary(); + private static readonly Icon LoadingIcon = Properties.Resources.Loading; // private static readonly object ReadIcon = new object(); public enum IconSize @@ -67,7 +68,7 @@ namespace SystemTrayMenu.Utilities { if (!DictIconCache.TryGetValue(filePath, out icon)) { - icon = Properties.Resources.Loading; + icon = LoadingIcon; loading = true; if (updateIconInBackground)