mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 19:49:15 +08:00
64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Wox.Plugin.Everything
|
|
{
|
|
public class Main : IPlugin
|
|
{
|
|
Wox.Plugin.PluginInitContext context;
|
|
EverythingAPI api = new EverythingAPI();
|
|
|
|
public List<Result> Query(Query query)
|
|
{
|
|
var results = new List<Result>();
|
|
if (query.ActionParameters.Count > 0 && query.ActionParameters[0].Length > 0)
|
|
{
|
|
IEnumerable<string> enumerable = api.Search(query.ActionParameters[0], 0, 100);
|
|
foreach (string s in enumerable)
|
|
{
|
|
Result r = new Result();
|
|
r.Title = Path.GetFileName(s);
|
|
r.SubTitle = s;
|
|
r.Action = () =>
|
|
{
|
|
context.HideApp();
|
|
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
|
|
info.UseShellExecute = true;
|
|
info.FileName = s;
|
|
try
|
|
{
|
|
System.Diagnostics.Process.Start(info);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
context.ShowMsg("Could not start " + r.Title, ex.Message, null);
|
|
}
|
|
};
|
|
results.Add(r);
|
|
}
|
|
}
|
|
|
|
api.Reset();
|
|
|
|
return results;
|
|
}
|
|
|
|
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
|
|
private static extern int LoadLibrary(string name);
|
|
|
|
public void Init(Wox.Plugin.PluginInitContext context)
|
|
{
|
|
this.context = context;
|
|
|
|
LoadLibrary(Path.Combine(
|
|
Path.Combine(context.PluginMetadata.PluginDirecotry, (IntPtr.Size == 4) ? "x86" : "x64"),
|
|
"Everything.dll"
|
|
));
|
|
//init everything
|
|
}
|
|
}
|
|
}
|