PowerToys/WinAlfred.Plugin.System/ThirdpartyPluginIndicator.cs

47 lines
1.5 KiB
C#
Raw Normal View History

2014-01-06 12:03:20 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WinAlfred.Plugin.System
{
2014-01-15 15:45:02 +01:00
public class ThirdpartyPluginIndicator : BaseSystemPlugin
2014-01-06 12:03:20 +01:00
{
private List<PluginPair> allPlugins = new List<PluginPair>();
private Action<string> changeQuery;
2014-01-15 15:45:02 +01:00
protected override List<Result> QueryInternal(Query query)
2014-01-06 12:03:20 +01:00
{
List<Result> results = new List<Result>();
if (string.IsNullOrEmpty(query.RawQuery)) return results;
foreach (PluginMetadata metadata in allPlugins.Select(o=>o.Metadata))
{
if (metadata.ActionKeyword.StartsWith(query.RawQuery))
{
PluginMetadata metadataCopy = metadata;
Result result = new Result
{
Title = metadata.ActionKeyword,
2014-01-27 13:45:26 +01:00
SubTitle = string.Format("Activate {0} workflow",metadata.Name),
2014-01-06 12:03:20 +01:00
Score = 50,
IcoPath = "Images/work.png",
Action = () => changeQuery(metadataCopy.ActionKeyword + " "),
2014-01-15 15:45:02 +01:00
DontHideWinAlfredAfterSelect = true
2014-01-06 12:03:20 +01:00
};
results.Add(result);
}
}
return results;
}
2014-01-15 15:45:02 +01:00
protected override void InitInternal(PluginInitContext context)
2014-01-06 12:03:20 +01:00
{
allPlugins = context.Plugins;
changeQuery = context.ChangeQuery;
}
}
}