Implement IInstantSearch for CMD and WebSearch plugin

This commit is contained in:
qianlifeng
2015-01-27 22:59:03 +08:00
parent 4ecff94aec
commit 9f64a384d6
7 changed files with 99 additions and 13 deletions

View File

@@ -6,12 +6,13 @@ using System.Reflection;
using System.Windows.Forms;
using WindowsInput;
using WindowsInput.Native;
using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey;
using Control = System.Windows.Controls.Control;
namespace Wox.Plugin.CMD
{
public class CMD : IPlugin, ISettingProvider, IPluginI18n
public class CMD : IPlugin, ISettingProvider, IPluginI18n, IInstantSearch
{
private PluginInitContext context;
private bool WinRStroked;
@@ -37,6 +38,7 @@ namespace Wox.Plugin.CMD
context.API.PushResults(query, context.CurrentPluginMetadata, history);
pushedResults.AddRange(history);
try
{
string basedir = null;
@@ -72,6 +74,7 @@ namespace Wox.Plugin.CMD
}
}
catch (Exception) { }
}
return results;
}
@@ -207,5 +210,11 @@ namespace Wox.Plugin.CMD
{
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
public bool IsInstantSearch(string query)
{
if (query.StartsWith(">")) return true;
return false;
}
}
}
}

View File

@@ -9,7 +9,7 @@ using Wox.Plugin.WebSearch.SuggestionSources;
namespace Wox.Plugin.WebSearch
{
public class WebSearchPlugin : IPlugin, ISettingProvider,IPluginI18n
public class WebSearchPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantSearch
{
private PluginInitContext context;
@@ -97,5 +97,16 @@ namespace Wox.Plugin.WebSearch
{
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
public bool IsInstantSearch(string query)
{
var strings = query.Split(' ');
if (strings.Length > 1)
{
return WebSearchStorage.Instance.EnableWebSearchSuggestion &&
WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == strings[0] && o.Enabled);
}
return false;
}
}
}