mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
@@ -12,7 +12,7 @@ using Control = System.Windows.Controls.Control;
|
||||
|
||||
namespace Wox.Plugin.CMD
|
||||
{
|
||||
public class CMD : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IExclusiveQuery, IContextMenu
|
||||
public class CMD : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IContextMenu
|
||||
{
|
||||
private PluginInitContext context;
|
||||
private bool WinRStroked;
|
||||
@@ -202,11 +202,6 @@ namespace Wox.Plugin.CMD
|
||||
|
||||
public bool IsInstantQuery(string query) => false;
|
||||
|
||||
public bool IsExclusiveQuery(Query query)
|
||||
{
|
||||
return query.Search.StartsWith(">");
|
||||
}
|
||||
|
||||
public List<Result> LoadContextMenus(Result selectedResult)
|
||||
{
|
||||
return new List<Result>()
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<system:String x:Key="wox_plugin_websearch_input_title">Please input title</system:String>
|
||||
<system:String x:Key="wox_plugin_websearch_input_action_keyword">Please input action keyword</system:String>
|
||||
<system:String x:Key="wox_plugin_websearch_input_url">Please input URL</system:String>
|
||||
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">ActionWord has existed, please input a new one</system:String>
|
||||
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">ActionKeyword has existed, please input a new one</system:String>
|
||||
<system:String x:Key="wox_plugin_websearch_succeed">Succeed</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_websearch_plugin_name">Web Searches</system:String>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Wox.Plugin.WebSearch
|
||||
public class WebSearch
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string ActionWord { get; set; }
|
||||
public string ActionKeyword { get; set; }
|
||||
public string IconPath { get; set; }
|
||||
public string Url { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
@@ -8,7 +8,7 @@ using Wox.Plugin.WebSearch.SuggestionSources;
|
||||
|
||||
namespace Wox.Plugin.WebSearch
|
||||
{
|
||||
public class WebSearchPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IExclusiveQuery
|
||||
public class WebSearchPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery
|
||||
{
|
||||
private PluginInitContext context;
|
||||
private IDisposable suggestionTimer;
|
||||
@@ -16,17 +16,12 @@ namespace Wox.Plugin.WebSearch
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
if (!query.Search.Contains(' '))
|
||||
{
|
||||
return results;
|
||||
}
|
||||
|
||||
WebSearch webSearch =
|
||||
WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && o.Enabled);
|
||||
WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionKeyword == query.ActionKeyword && o.Enabled);
|
||||
|
||||
if (webSearch != null)
|
||||
{
|
||||
string keyword = query.SecondToEndSearch;
|
||||
string keyword = query.ActionKeyword;
|
||||
string title = keyword;
|
||||
string subtitle = context.API.GetTranslation("wox_plugin_websearch_search") + " " + webSearch.Title;
|
||||
if (string.IsNullOrEmpty(keyword))
|
||||
@@ -122,14 +117,5 @@ namespace Wox.Plugin.WebSearch
|
||||
|
||||
public bool IsInstantQuery(string query) => false;
|
||||
|
||||
public bool IsExclusiveQuery(Query query)
|
||||
{
|
||||
var strings = query.RawQuery.Split(' ');
|
||||
if (strings.Length > 1)
|
||||
{
|
||||
return WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == strings[0] && o.Enabled);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace Wox.Plugin.WebSearch
|
||||
cbEnable.IsChecked = webSearch.Enabled;
|
||||
tbTitle.Text = webSearch.Title;
|
||||
tbUrl.Text = webSearch.Url;
|
||||
tbActionword.Text = webSearch.ActionWord;
|
||||
tbActionword.Text = webSearch.ActionKeyword;
|
||||
}
|
||||
|
||||
private void ShowIcon(string path)
|
||||
@@ -90,7 +90,7 @@ namespace Wox.Plugin.WebSearch
|
||||
|
||||
if (!update)
|
||||
{
|
||||
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == action))
|
||||
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionKeyword == action))
|
||||
{
|
||||
string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist");
|
||||
MessageBox.Show(warning);
|
||||
@@ -98,7 +98,7 @@ namespace Wox.Plugin.WebSearch
|
||||
}
|
||||
WebSearchStorage.Instance.WebSearches.Add(new WebSearch()
|
||||
{
|
||||
ActionWord = action,
|
||||
ActionKeyword = action,
|
||||
Enabled = cbEnable.IsChecked ?? false,
|
||||
IconPath = tbIconPath.Text,
|
||||
Url = url,
|
||||
@@ -109,13 +109,13 @@ namespace Wox.Plugin.WebSearch
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == action && o != updateWebSearch))
|
||||
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionKeyword == action && o != updateWebSearch))
|
||||
{
|
||||
string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist");
|
||||
MessageBox.Show(warning);
|
||||
return;
|
||||
}
|
||||
updateWebSearch.ActionWord = action;
|
||||
updateWebSearch.ActionKeyword = action;
|
||||
updateWebSearch.IconPath = tbIconPath.Text;
|
||||
updateWebSearch.Enabled = cbEnable.IsChecked ?? false;
|
||||
updateWebSearch.Url = url;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Wox.Plugin.WebSearch
|
||||
WebSearch googleWebSearch = new WebSearch()
|
||||
{
|
||||
Title = "Google",
|
||||
ActionWord = "g",
|
||||
ActionKeyword = "g",
|
||||
IconPath = @"Images\websearch\google.png",
|
||||
Url = "https://www.google.com/search?q={q}",
|
||||
Enabled = true
|
||||
@@ -51,7 +51,7 @@ namespace Wox.Plugin.WebSearch
|
||||
WebSearch wikiWebSearch = new WebSearch()
|
||||
{
|
||||
Title = "Wikipedia",
|
||||
ActionWord = "wiki",
|
||||
ActionKeyword = "wiki",
|
||||
IconPath = @"Images\websearch\wiki.png",
|
||||
Url = "http://en.wikipedia.org/wiki/{q}",
|
||||
Enabled = true
|
||||
@@ -61,7 +61,7 @@ namespace Wox.Plugin.WebSearch
|
||||
WebSearch findIcon = new WebSearch()
|
||||
{
|
||||
Title = "FindIcon",
|
||||
ActionWord = "findicon",
|
||||
ActionKeyword = "findicon",
|
||||
IconPath = @"Images\websearch\pictures.png",
|
||||
Url = "http://findicons.com/search/{q}",
|
||||
Enabled = true
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<GridViewColumn Header="{DynamicResource wox_plugin_websearch_action_keyword}" Width="180">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding ActionWord}"/>
|
||||
<TextBlock Text="{Binding ActionKeyword}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<Compile Include="WebSearchesSetting.xaml.cs">
|
||||
<DependentUpon>WebSearchesSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WebQueryPlugin.cs" />
|
||||
<Compile Include="WebSearchPlugin.cs" />
|
||||
<Compile Include="WebSearchSetting.xaml.cs">
|
||||
<DependentUpon>WebSearchSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -135,5 +135,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
|
||||
</Project>
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ID":"565B73353DBF4806919830B9202EE3BF",
|
||||
"ActionKeyword":"*",
|
||||
"ActionKeywords": ["g", "wiki", "findicon"],
|
||||
"Name":"Web Searches",
|
||||
"Description":"Provide the web search ability",
|
||||
"Author":"qianlifeng",
|
||||
|
||||
Reference in New Issue
Block a user