[BUG] Fix performance when open subfolder, Fix rare unknown exception (#124)
|
@ -104,7 +104,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
}
|
}
|
||||||
else if (isDirectory)
|
else if (isDirectory)
|
||||||
{
|
{
|
||||||
icon = IconReader.GetFolderIcon(
|
icon = IconReader.GetFolderIconSTA(
|
||||||
TargetFilePath,
|
TargetFilePath,
|
||||||
IconReader.FolderType.Closed,
|
IconReader.FolderType.Closed,
|
||||||
false);
|
false);
|
||||||
|
@ -256,7 +256,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
resolvedLnkPath = FileLnk.GetResolvedFileName(TargetFilePath);
|
resolvedLnkPath = FileLnk.GetResolvedFileName(TargetFilePath);
|
||||||
if (FileLnk.IsDirectory(resolvedLnkPath))
|
if (FileLnk.IsDirectory(resolvedLnkPath))
|
||||||
{
|
{
|
||||||
icon = IconReader.GetFolderIcon(TargetFilePath, IconReader.FolderType.Open, true);
|
icon = IconReader.GetFolderIconSTA(TargetFilePath, IconReader.FolderType.Open, true);
|
||||||
handled = true;
|
handled = true;
|
||||||
isLnkDirectory = true;
|
isLnkDirectory = true;
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 99 KiB |
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 137 KiB |
Before Width: | Height: | Size: 543 KiB After Width: | Height: | Size: 472 KiB |
|
@ -39,5 +39,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("1.0.10.0")]
|
[assembly: AssemblyVersion("1.0.11.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.10.0")]
|
[assembly: AssemblyFileVersion("1.0.11.0")]
|
||||||
|
|
|
@ -160,6 +160,14 @@
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="LICENSE">
|
||||||
|
<Pack>True</Pack>
|
||||||
|
<PackagePath></PackagePath>
|
||||||
|
</None>
|
||||||
|
<None Include="Resources\icon.png">
|
||||||
|
<Pack>True</Pack>
|
||||||
|
<PackagePath></PackagePath>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Resources\SystemTrayMenu.ico" />
|
<Content Include="Resources\SystemTrayMenu.ico" />
|
||||||
|
@ -206,9 +214,18 @@
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Packaging\AppPackages\" />
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PreBuildEvent>taskkill /fi "pid gt 0" /im SystemTrayMenu.exe
|
<PreBuildEvent>taskkill /fi "pid gt 0" /im SystemTrayMenu.exe
|
||||||
taskkill /f /fi "pid gt 0" /im SystemTrayMenu.exe
|
taskkill /f /fi "pid gt 0" /im SystemTrayMenu.exe
|
||||||
EXIT 0</PreBuildEvent>
|
EXIT 0</PreBuildEvent>
|
||||||
|
<RepositoryUrl>https://github.com/Hofknecht/SystemTrayMenu</RepositoryUrl>
|
||||||
|
<PackageIcon>icon.png</PackageIcon>
|
||||||
|
<PackageProjectUrl>hofknecht.eu/systemtraymenu/</PackageProjectUrl>
|
||||||
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
|
<RepositoryType></RepositoryType>
|
||||||
|
<PackageTags>SystemTrayMenu</PackageTags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -11,6 +11,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
// from https://www.codeproject.com/Articles/2532/Obtaining-and-managing-file-and-folder-icons-using
|
// from https://www.codeproject.com/Articles/2532/Obtaining-and-managing-file-and-folder-icons-using
|
||||||
// added ImageList_GetIcon, IconCache, AddIconOverlay
|
// added ImageList_GetIcon, IconCache, AddIconOverlay
|
||||||
|
@ -58,18 +59,39 @@ namespace SystemTrayMenu.Utilities
|
||||||
icon = DictIconCache.GetOrAdd(extension, GetIcon);
|
icon = DictIconCache.GetOrAdd(extension, GetIcon);
|
||||||
Icon GetIcon(string keyExtension)
|
Icon GetIcon(string keyExtension)
|
||||||
{
|
{
|
||||||
return GetFileIcon(filePath, linkOverlay, size);
|
return GetFileIconSTA(filePath, linkOverlay, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
icon = GetFileIcon(filePath, linkOverlay, size);
|
icon = GetFileIconSTA(filePath, linkOverlay, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// }
|
// }
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2008:Do not create tasks without passing a TaskScheduler", Justification = "todo")]
|
||||||
|
public static Icon GetFolderIconSTA(
|
||||||
|
string directoryPath,
|
||||||
|
FolderType folderType,
|
||||||
|
bool linkOverlay,
|
||||||
|
IconSize size = IconSize.Small)
|
||||||
|
{
|
||||||
|
Icon icon = null;
|
||||||
|
|
||||||
|
Task<Icon> task = Task.Factory.StartNew(() => GetFolderIcon(
|
||||||
|
directoryPath,
|
||||||
|
folderType,
|
||||||
|
linkOverlay,
|
||||||
|
size));
|
||||||
|
icon = task.Result;
|
||||||
|
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
public static Icon GetFolderIcon(
|
public static Icon GetFolderIcon(
|
||||||
string directoryPath,
|
string directoryPath,
|
||||||
FolderType folderType,
|
FolderType folderType,
|
||||||
|
@ -116,7 +138,6 @@ namespace SystemTrayMenu.Utilities
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Icon.FromHandle(shfi.hIcon);
|
|
||||||
icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone();
|
icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone();
|
||||||
DllImports.NativeMethods.User32DestroyIcon(shfi.hIcon);
|
DllImports.NativeMethods.User32DestroyIcon(shfi.hIcon);
|
||||||
}
|
}
|
||||||
|
@ -163,6 +184,17 @@ namespace SystemTrayMenu.Utilities
|
||||||
return isExtensionWitSameIcon;
|
return isExtensionWitSameIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2008:Do not create tasks without passing a TaskScheduler", Justification = "todo")]
|
||||||
|
private static Icon GetFileIconSTA(string filePath, bool linkOverlay, IconSize size = IconSize.Small)
|
||||||
|
{
|
||||||
|
Icon icon = null;
|
||||||
|
|
||||||
|
Task<Icon> task = Task.Factory.StartNew(() => GetFileIcon(filePath, linkOverlay, size));
|
||||||
|
icon = task.Result;
|
||||||
|
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
private static Icon GetFileIcon(string filePath, bool linkOverlay, IconSize size = IconSize.Small)
|
private static Icon GetFileIcon(string filePath, bool linkOverlay, IconSize size = IconSize.Small)
|
||||||
{
|
{
|
||||||
Icon icon = null;
|
Icon icon = null;
|
||||||
|
|