清理多余引用
This commit is contained in:
@@ -3,10 +3,6 @@ using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using ShrlAlgoToolkit.RevitAddins.Common.Assists;
|
||||
using ShrlAlgoToolkit;
|
||||
using ShrlAlgoToolkit.RevitAddins;
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.Common.Assists;
|
||||
|
||||
/// <summary>
|
||||
@@ -20,7 +16,7 @@ public class WindowsThumbnailProvider
|
||||
{
|
||||
var result = new Bitmap(srcBitmap.Width, srcBitmap.Height, targetPixelFormat);
|
||||
|
||||
var bmpBounds = new System.Drawing.Rectangle(0, 0, srcBitmap.Width, srcBitmap.Height);
|
||||
var bmpBounds = new Rectangle(0, 0, srcBitmap.Width, srcBitmap.Height);
|
||||
|
||||
var srcData = srcBitmap.LockBits(bmpBounds, ImageLockMode.ReadOnly, srcBitmap.PixelFormat);
|
||||
|
||||
@@ -32,7 +28,7 @@ public class WindowsThumbnailProvider
|
||||
{
|
||||
for (var x = 0; x <= srcData.Width - 1; x++)
|
||||
{
|
||||
var pixelColor = System.Drawing.Color.FromArgb(Marshal.ReadInt32(srcData.Scan0, (srcData.Stride * y) + (4 * x)));
|
||||
var pixelColor = Color.FromArgb(Marshal.ReadInt32(srcData.Scan0, (srcData.Stride * y) + (4 * x)));
|
||||
|
||||
if ((pixelColor.A > 0) & (pixelColor.A < 255))
|
||||
{
|
||||
@@ -58,7 +54,7 @@ public class WindowsThumbnailProvider
|
||||
return Image.GetPixelFormatSize(bmp.PixelFormat) < 32 ? bmp : CreateAlphaBitmap(bmp, PixelFormat.Format32bppArgb);
|
||||
}
|
||||
|
||||
public static Bitmap GetThumbnail(string fileName, int width, int height, Assists.ThumbnailOptions options)
|
||||
public static Bitmap GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
|
||||
{
|
||||
var hBitmap = GetHBitmap(Path.GetFullPath(fileName), width, height, options);
|
||||
|
||||
@@ -84,10 +80,10 @@ public class WindowsThumbnailProvider
|
||||
// The following parameter is not used - binding context.
|
||||
IntPtr pbc,
|
||||
ref Guid riid,
|
||||
[MarshalAs(UnmanagedType.Interface)] out Assists.WindowsThumbnailProvider.IShellItem shellItem
|
||||
[MarshalAs(UnmanagedType.Interface)] out IShellItem shellItem
|
||||
);
|
||||
|
||||
private static IntPtr GetHBitmap(string fileName, int width, int height, Assists.ThumbnailOptions options)
|
||||
private static IntPtr GetHBitmap(string fileName, int width, int height, ThumbnailOptions options)
|
||||
{
|
||||
var shellItem2Guid = new Guid(ShellItem2Guid);
|
||||
var retCode = SHCreateItemFromParsingName(fileName, IntPtr.Zero, ref shellItem2Guid, out var nativeShellItem);
|
||||
@@ -97,13 +93,13 @@ public class WindowsThumbnailProvider
|
||||
throw Marshal.GetExceptionForHR(retCode);
|
||||
}
|
||||
|
||||
var nativeSize = new Assists.WindowsThumbnailProvider.NativeSize { Width = width, Height = height };
|
||||
var nativeSize = new NativeSize { Width = width, Height = height };
|
||||
|
||||
var hr = ((Assists.WindowsThumbnailProvider.IShellItemImageFactory)nativeShellItem).GetImage(nativeSize, options, out var hBitmap);
|
||||
var hr = ((IShellItemImageFactory)nativeShellItem).GetImage(nativeSize, options, out var hBitmap);
|
||||
|
||||
Marshal.ReleaseComObject(nativeShellItem);
|
||||
|
||||
return hr == Assists.WindowsThumbnailProvider.HResult.Ok ? hBitmap : throw Marshal.GetExceptionForHR((int)hr);
|
||||
return hr == HResult.Ok ? hBitmap : throw Marshal.GetExceptionForHR((int)hr);
|
||||
}
|
||||
|
||||
internal enum HResult
|
||||
@@ -130,13 +126,13 @@ public class WindowsThumbnailProvider
|
||||
{
|
||||
void BindToHandler(IntPtr pbc, [MarshalAs(UnmanagedType.LPStruct)] Guid bhid, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IntPtr ppv);
|
||||
|
||||
void Compare(Assists.WindowsThumbnailProvider.IShellItem psi, uint hint, out int piOrder);
|
||||
void Compare(IShellItem psi, uint hint, out int piOrder);
|
||||
|
||||
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
|
||||
|
||||
void GetDisplayName(Assists.WindowsThumbnailProvider.SIGDN sigdnName, out IntPtr ppszName);
|
||||
void GetDisplayName(SIGDN sigdnName, out IntPtr ppszName);
|
||||
|
||||
void GetParent(out Assists.WindowsThumbnailProvider.IShellItem ppsi);
|
||||
void GetParent(out IShellItem ppsi);
|
||||
}
|
||||
|
||||
[ComImport]
|
||||
@@ -145,7 +141,7 @@ public class WindowsThumbnailProvider
|
||||
internal interface IShellItemImageFactory
|
||||
{
|
||||
[PreserveSig]
|
||||
Assists.WindowsThumbnailProvider.HResult GetImage([In] [MarshalAs(UnmanagedType.Struct)] Assists.WindowsThumbnailProvider.NativeSize size, [In] Assists.ThumbnailOptions flags, [Out] out IntPtr phbm);
|
||||
HResult GetImage([In] [MarshalAs(UnmanagedType.Struct)] NativeSize size, [In] ThumbnailOptions flags, [Out] out IntPtr phbm);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
||||
Reference in New Issue
Block a user