WIP on ShellItemSource

master
David Hall 2024-06-09 16:07:36 -06:00
parent ac0a1ac301
commit ce28b45d48
2 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,52 @@
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using Vanara.Windows.Shell;
using static Vanara.PInvoke.User32;
using static Vanara.PInvoke.Shell32;
using static Vanara.PInvoke.Shell32.ShellUtil;
using System.IO;
using System.Windows.Media.Imaging;
namespace Vanara.PInvoke;
/*internal class ShellImageSource : BitmapSource
{
public ShellImageSource(string path, System.Drawing.Size imageSize)
{
SHCreateItemFromParsingName(path, null, typeof(IShellItemImageFactory).GUID, out var ppv).ThrowIfFailed();
((IShellItemImageFactory)ppv!).GetImage(imageSize, SIIGBF.SIIGBF_INCACHEONLY, out var hbmp).ThrowIfFailed();
if (LoadImageFromImageFactory(path, ref imageSize, SIIGBF.SIIGBF_INCACHEONLY, out var hbmp).Succeeded && hbmp != null)
if (cache.TryGetValue(path, out var bmp))
Bitmap = bmp;
bool? isDir = IsDirFile(path);
var hico = ShellImageList.GetFileIcon(path, iconType) ?? ShellImageList.GetSystemIcon(path, iconType);
}
private static IShellItemImageFactory GetFactory(string path)
{
SHCreateItemFromParsingName(path, null, typeof(IShellItemImageFactory).GUID, out var ppv).ThrowIfFailed();
return (IShellItemImageFactory)ppv!;
}
private static IShellItemImageFactory GetFactory(PIDL pidl)
{
SHCreateItemFromIDList(pidl, typeof(IShellItemImageFactory).GUID, out var ppv).ThrowIfFailed();
return (IShellItemImageFactory)ppv!;
}
private static async Task<Bitmap> GetImageAsync(IShellItemImageFactory siif, System.Drawing.Size imageSize)
{
siif.GetImage(imageSize, SIIGBF.SIIGBF_INCACHEONLY, out var hbmp).ThrowIfFailed();
}
protected override Freezable CreateInstanceCore() => throw new NotImplementedException();
}*/

View File

@ -23,6 +23,7 @@ SystemFoundationExtensions
<ItemGroup>
<ProjectReference Include="..\PInvoke\Gdi32\Vanara.PInvoke.Gdi32.csproj" />
<ProjectReference Include="..\PInvoke\User32\Vanara.PInvoke.User32.csproj" />
<ProjectReference Include="..\Windows.Shell.Common\Vanara.Windows.Shell.Common.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />