2014-01-06 19:03:20 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2014-01-29 22:44:57 +08:00
|
|
|
|
using Wox.Infrastructure;
|
2014-03-23 16:17:41 +08:00
|
|
|
|
using Wox.Infrastructure.Storage;
|
|
|
|
|
using Wox.Infrastructure.Storage.UserSettings;
|
2014-01-06 19:03:20 +08:00
|
|
|
|
|
2014-03-29 15:52:57 +08:00
|
|
|
|
namespace Wox.Plugin.SystemPlugins
|
2014-01-06 19:03:20 +08:00
|
|
|
|
{
|
2014-01-15 22:45:02 +08:00
|
|
|
|
public class ThirdpartyPluginIndicator : BaseSystemPlugin
|
2014-01-06 19:03:20 +08:00
|
|
|
|
{
|
|
|
|
|
private List<PluginPair> allPlugins = new List<PluginPair>();
|
|
|
|
|
private Action<string> changeQuery;
|
|
|
|
|
|
2014-01-15 22:45:02 +08:00
|
|
|
|
protected override List<Result> QueryInternal(Query query)
|
2014-01-06 19:03:20 +08:00
|
|
|
|
{
|
|
|
|
|
List<Result> results = new List<Result>();
|
|
|
|
|
if (string.IsNullOrEmpty(query.RawQuery)) return results;
|
|
|
|
|
|
2014-01-29 22:44:57 +08:00
|
|
|
|
foreach (PluginMetadata metadata in allPlugins.Select(o => o.Metadata))
|
2014-01-06 19:03:20 +08:00
|
|
|
|
{
|
|
|
|
|
if (metadata.ActionKeyword.StartsWith(query.RawQuery))
|
|
|
|
|
{
|
|
|
|
|
PluginMetadata metadataCopy = metadata;
|
|
|
|
|
Result result = new Result
|
|
|
|
|
{
|
|
|
|
|
Title = metadata.ActionKeyword,
|
2014-01-29 22:44:57 +08:00
|
|
|
|
SubTitle = string.Format("Activate {0} plugin", metadata.Name),
|
2014-01-06 19:03:20 +08:00
|
|
|
|
Score = 50,
|
|
|
|
|
IcoPath = "Images/work.png",
|
2014-02-28 23:21:01 +08:00
|
|
|
|
Action = (c) =>
|
|
|
|
|
{
|
|
|
|
|
changeQuery(metadataCopy.ActionKeyword + " ");
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2014-01-06 19:03:20 +08:00
|
|
|
|
};
|
2014-01-29 22:44:57 +08:00
|
|
|
|
results.Add(result);
|
2014-01-06 19:03:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-29 22:44:57 +08:00
|
|
|
|
|
2014-03-23 16:17:41 +08:00
|
|
|
|
results.AddRange(UserSettingStorage.Instance.WebSearches.Where(o => o.ActionWord.StartsWith(query.RawQuery) && o.Enabled).Select(n => new Result()
|
2014-01-29 22:44:57 +08:00
|
|
|
|
{
|
|
|
|
|
Title = n.ActionWord,
|
2014-02-02 16:15:34 +08:00
|
|
|
|
SubTitle = string.Format("Activate {0} web search", n.ActionWord),
|
2014-01-29 22:44:57 +08:00
|
|
|
|
Score = 50,
|
|
|
|
|
IcoPath = "Images/work.png",
|
2014-02-28 23:21:01 +08:00
|
|
|
|
Action = (c) =>
|
|
|
|
|
{
|
|
|
|
|
changeQuery(n.ActionWord + " ");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-01-29 22:44:57 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2014-01-06 19:03:20 +08:00
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-15 22:45:02 +08:00
|
|
|
|
protected override void InitInternal(PluginInitContext context)
|
2014-01-06 19:03:20 +08:00
|
|
|
|
{
|
|
|
|
|
allPlugins = context.Plugins;
|
|
|
|
|
changeQuery = context.ChangeQuery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-03-28 22:42:28 +08:00
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Plugins"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string IcoPath
|
|
|
|
|
{
|
|
|
|
|
get { return @"Images\work.png"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Description
|
|
|
|
|
{
|
|
|
|
|
get { return base.Description; }
|
|
|
|
|
}
|
2014-01-06 19:03:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|