2015-01-03 15:20:34 +08:00
|
|
|
|
using System.Collections.Generic;
|
2014-01-06 19:03:20 +08:00
|
|
|
|
using System.Linq;
|
2015-01-04 23:08:26 +08:00
|
|
|
|
using Wox.Core.Plugin;
|
2015-01-05 22:41:17 +08:00
|
|
|
|
using Wox.Core.UserSettings;
|
2014-01-06 19:03:20 +08:00
|
|
|
|
|
2015-01-03 15:20:34 +08:00
|
|
|
|
namespace Wox.Plugin.PluginIndicator
|
2014-01-06 19:03:20 +08:00
|
|
|
|
{
|
2015-11-06 06:47:28 +08:00
|
|
|
|
public class PluginIndicator : IPlugin, IPluginI18n
|
2014-01-06 19:03:20 +08:00
|
|
|
|
{
|
2014-07-05 23:10:34 +08:00
|
|
|
|
private PluginInitContext context;
|
2014-01-06 19:03:20 +08:00
|
|
|
|
|
2015-01-03 15:20:34 +08:00
|
|
|
|
public List<Result> Query(Query query)
|
2014-01-06 19:03:20 +08:00
|
|
|
|
{
|
2015-11-07 11:50:15 +08:00
|
|
|
|
var results = from keyword in PluginManager.NonGlobalPlugins.Keys
|
2015-11-06 06:47:28 +08:00
|
|
|
|
where keyword.StartsWith(query.Terms[0])
|
2015-11-07 11:50:15 +08:00
|
|
|
|
let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata
|
2015-11-06 06:47:28 +08:00
|
|
|
|
select new Result
|
|
|
|
|
{
|
|
|
|
|
Title = keyword,
|
|
|
|
|
SubTitle = $"Activate {metadata.Name} plugin",
|
|
|
|
|
Score = 100,
|
|
|
|
|
IcoPath = metadata.FullIcoPath,
|
2016-01-07 05:34:42 +08:00
|
|
|
|
Action = c =>
|
2015-11-06 06:47:28 +08:00
|
|
|
|
{
|
|
|
|
|
context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeperater}");
|
|
|
|
|
return false;
|
2016-01-07 05:34:42 +08:00
|
|
|
|
}
|
2015-11-06 06:47:28 +08:00
|
|
|
|
};
|
|
|
|
|
return results.ToList();
|
2014-01-06 19:03:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-03 15:20:34 +08:00
|
|
|
|
public void Init(PluginInitContext context)
|
2014-01-06 19:03:20 +08:00
|
|
|
|
{
|
2014-07-05 23:10:34 +08:00
|
|
|
|
this.context = context;
|
2014-01-06 19:03:20 +08:00
|
|
|
|
}
|
2015-02-07 21:27:48 +08:00
|
|
|
|
|
|
|
|
|
public string GetTranslatedPluginTitle()
|
|
|
|
|
{
|
|
|
|
|
return context.API.GetTranslation("wox_plugin_pluginindicator_plugin_name");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetTranslatedPluginDescription()
|
|
|
|
|
{
|
2015-02-08 16:27:41 +08:00
|
|
|
|
return context.API.GetTranslation("wox_plugin_pluginindicator_plugin_description");
|
2015-02-07 21:27:48 +08:00
|
|
|
|
}
|
2014-01-06 19:03:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|