more fixes for getting styleCop up, this will need one more push to get another 15 that will require renaming of vars (#5875)

This commit is contained in:
Clint Rutkas
2020-08-11 13:40:26 -07:00
committed by GitHub
parent 90502f7553
commit 2c49df4be3
24 changed files with 255 additions and 181 deletions

View File

@@ -25,7 +25,6 @@ namespace Wox.Infrastructure.Image
{
// PngBitmapEncoder enc2 = new PngBitmapEncoder();
// enc2.Frames.Add(BitmapFrame.Create(tt));
var enc = new JpegBitmapEncoder();
var bitmapFrame = BitmapFrame.Create(image);
bitmapFrame.Freeze();

View File

@@ -33,7 +33,7 @@ namespace Wox.Infrastructure.Image
".gif",
".bmp",
".tiff",
".ico"
".ico",
};
public static void Initialize(Theme theme)
@@ -104,7 +104,7 @@ namespace Wox.Infrastructure.Image
Data,
ImageFile,
Error,
Cache
Cache,
}
private static ImageResult LoadInternal(string path, bool loadFullImage = false)
@@ -144,8 +144,7 @@ namespace Wox.Infrastructure.Image
* - Solution: just load the icon
*/
type = ImageType.Folder;
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize,
Constant.ThumbnailSize, ThumbnailOptions.IconOnly);
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize, Constant.ThumbnailSize, ThumbnailOptions.IconOnly);
}
else if (File.Exists(path))
{
@@ -164,15 +163,13 @@ namespace Wox.Infrastructure.Image
* be the case in many situations while testing.
* - Solution: explicitly pass the ThumbnailOnly flag
*/
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize,
Constant.ThumbnailSize, ThumbnailOptions.ThumbnailOnly);
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize, Constant.ThumbnailSize, ThumbnailOptions.ThumbnailOnly);
}
}
else
{
type = ImageType.File;
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize,
Constant.ThumbnailSize, ThumbnailOptions.None);
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize, Constant.ThumbnailSize, ThumbnailOptions.None);
}
}
else

View File

@@ -3,11 +3,11 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
using System.Windows;
namespace Wox.Infrastructure.Image
{
@@ -66,7 +66,7 @@ namespace Wox.Infrastructure.Image
PARENTRELATIVEEDITING = 0x80031001,
DESKTOPABSOLUTEEDITING = 0x8004c000,
FILESYSPATH = 0x80058000,
URL = 0x80068000
URL = 0x80068000,
}
internal enum HResult
@@ -84,7 +84,7 @@ namespace Wox.Infrastructure.Image
Win32ErrorCanceled = 1223,
Canceled = unchecked((int)0x800704C7),
ResourceInUse = unchecked((int)0x800700AA),
AccessDenied = unchecked((int)0x80030005)
AccessDenied = unchecked((int)0x80030005),
}
[ComImportAttribute()]
@@ -105,9 +105,15 @@ namespace Wox.Infrastructure.Image
private int width;
private int height;
public int Width { set { width = value; } }
public int Width
{
set { width = value; }
}
public int Height { set { height = value; } }
public int Height
{
set { height = value; }
}
}
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
@@ -132,12 +138,14 @@ namespace Wox.Infrastructure.Image
int retCode = SHCreateItemFromParsingName(fileName, IntPtr.Zero, ref shellItem2Guid, out nativeShellItem);
if (retCode != 0)
{
throw Marshal.GetExceptionForHR(retCode);
}
NativeSize nativeSize = new NativeSize
{
Width = width,
Height = height
Height = height,
};
IntPtr hBitmap;
@@ -151,7 +159,10 @@ namespace Wox.Infrastructure.Image
Marshal.ReleaseComObject(nativeShellItem);
if (hr == HResult.Ok) return hBitmap;
if (hr == HResult.Ok)
{
return hBitmap;
}
throw new COMException($"Error while extracting thumbnail for {fileName}", Marshal.GetExceptionForHR((int)hr));
}