mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Add Everything support show file icon
and add a file icon cache associate with file extension
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Wox.Plugin.Everything
|
||||
{
|
||||
@@ -10,6 +11,7 @@ namespace Wox.Plugin.Everything
|
||||
{
|
||||
Wox.Plugin.PluginInitContext context;
|
||||
EverythingAPI api = new EverythingAPI();
|
||||
private static List<string> imageExts = new List<string>() { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff" };
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
@@ -17,13 +19,14 @@ namespace Wox.Plugin.Everything
|
||||
if (query.ActionParameters.Count > 0 && query.ActionParameters[0].Length > 0)
|
||||
{
|
||||
var keyword = string.Join(" ", query.ActionParameters.ToArray());
|
||||
IEnumerable<string> enumerable = api.Search(keyword, 0, 100);
|
||||
foreach (string s in enumerable)
|
||||
var enumerable = api.Search(keyword, 0, 100);
|
||||
foreach (var s in enumerable)
|
||||
{
|
||||
var path = s;
|
||||
var path = s.FullPath;
|
||||
Result r = new Result();
|
||||
r.Title = Path.GetFileName(path);
|
||||
r.SubTitle = path;
|
||||
r.IcoPath = GetIconPath(s);
|
||||
r.Action = (c) =>
|
||||
{
|
||||
context.HideApp();
|
||||
@@ -48,6 +51,22 @@ namespace Wox.Plugin.Everything
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
private string GetIconPath(SearchResult s)
|
||||
{
|
||||
if (s.Type == ResultType.Folder)
|
||||
{
|
||||
return "Images\\folder.png";
|
||||
}
|
||||
else
|
||||
{
|
||||
var ext = Path.GetExtension(s.FullPath);
|
||||
if (!string.IsNullOrEmpty(ext) && imageExts.Contains(ext.ToLower()))
|
||||
return "Images\\image.png";
|
||||
else
|
||||
return s.FullPath;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
|
||||
private static extern int LoadLibrary(string name);
|
||||
|
||||
Reference in New Issue
Block a user