diff --git a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs index fbf514333e..6454013391 100644 --- a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs +++ b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs @@ -45,18 +45,18 @@ namespace Wox.Plugin.PluginIndicator } } - results.AddRange(UserSettingStorage.Instance.WebSearches.Where(o => o.ActionWord.StartsWith(query.Search) && o.Enabled).Select(n => new Result() - { - Title = n.ActionWord, - SubTitle = string.Format("Activate {0} web search", n.ActionWord), - Score = 100, - IcoPath = "Images/work.png", - Action = (c) => - { - context.API.ChangeQuery(n.ActionWord + " "); - return false; - } - })); + //results.AddRange(UserSettingStorage.Instance.WebSearches.Where(o => o.ActionWord.StartsWith(query.Search) && o.Enabled).Select(n => new Result() + //{ + // Title = n.ActionWord, + // SubTitle = string.Format("Activate {0} web search", n.ActionWord), + // Score = 100, + // IcoPath = "Images/work.png", + // Action = (c) => + // { + // context.API.ChangeQuery(n.ActionWord + " "); + // return false; + // } + //})); return results; } diff --git a/Wox.Core/UserSettings/WebSearch.cs b/Plugins/Wox.Plugin.WebSearch/WebSearch.cs similarity index 90% rename from Wox.Core/UserSettings/WebSearch.cs rename to Plugins/Wox.Plugin.WebSearch/WebSearch.cs index aa28a2ff80..b05870cb0f 100644 --- a/Wox.Core/UserSettings/WebSearch.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearch.cs @@ -1,6 +1,6 @@ using System; -namespace Wox.Core.UserSettings +namespace Wox.Plugin.WebSearch { [Serializable] public class WebSearch diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs index f3e9837d65..d771bc3b90 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs @@ -17,8 +17,8 @@ namespace Wox.Plugin.WebSearch { List results = new List(); - Core.UserSettings.WebSearch webSearch = - UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && o.Enabled); + WebSearch webSearch = + WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && o.Enabled); if (webSearch != null) { @@ -46,10 +46,10 @@ namespace Wox.Plugin.WebSearch } }); - if (UserSettingStorage.Instance.EnableWebSearchSuggestion && !string.IsNullOrEmpty(keyword)) + if (WebSearchStorage.Instance.EnableWebSearchSuggestion && !string.IsNullOrEmpty(keyword)) { ISuggestionSource sugg = SuggestionSourceFactory.GetSuggestionSource( - UserSettingStorage.Instance.WebSearchSuggestionSource); + WebSearchStorage.Instance.WebSearchSuggestionSource); if (sugg != null) { var result = sugg.GetSuggestions(keyword); @@ -80,8 +80,8 @@ namespace Wox.Plugin.WebSearch { this.context = context; - if (UserSettingStorage.Instance.WebSearches == null) - UserSettingStorage.Instance.WebSearches = UserSettingStorage.Instance.LoadDefaultWebSearches(); + if (WebSearchStorage.Instance.WebSearches == null) + WebSearchStorage.Instance.WebSearches = WebSearchStorage.Instance.LoadDefaultWebSearches(); } #region ISettingProvider Members diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs index c7e5138d06..f7f09bcf5c 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs @@ -14,7 +14,7 @@ namespace Wox.Plugin.WebSearch private string defaultWebSearchImageDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images\\websearch"); private WebSearchesSetting settingWindow; private bool update; - private Core.UserSettings.WebSearch updateWebSearch; + private WebSearch updateWebSearch; private PluginInitContext context; public WebSearchSetting(WebSearchesSetting settingWidow,PluginInitContext context) @@ -24,9 +24,9 @@ namespace Wox.Plugin.WebSearch InitializeComponent(); } - public void UpdateItem(Core.UserSettings.WebSearch webSearch) + public void UpdateItem(WebSearch webSearch) { - updateWebSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch); + updateWebSearch = WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch); if (updateWebSearch == null || string.IsNullOrEmpty(updateWebSearch.Url)) { @@ -91,13 +91,13 @@ namespace Wox.Plugin.WebSearch if (!update) { - if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == action)) + if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == action)) { string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist"); MessageBox.Show(warning); return; } - UserSettingStorage.Instance.WebSearches.Add(new Core.UserSettings.WebSearch() + WebSearchStorage.Instance.WebSearches.Add(new WebSearch() { ActionWord = action, Enabled = cbEnable.IsChecked ?? false, @@ -110,7 +110,7 @@ namespace Wox.Plugin.WebSearch } else { - if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == action && o != updateWebSearch)) + if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == action && o != updateWebSearch)) { string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist"); MessageBox.Show(warning); diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs new file mode 100644 index 0000000000..bcf5ec616b --- /dev/null +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using Newtonsoft.Json; +using Wox.Core.UserSettings; +using Wox.Infrastructure.Storage; + +namespace Wox.Plugin.WebSearch +{ + public class WebSearchStorage :JsonStrorage + { + [JsonProperty] + public List WebSearches { get; set; } + + [JsonProperty] + public bool EnableWebSearchSuggestion { get; set; } + + [JsonProperty] + public string WebSearchSuggestionSource { get; set; } + + protected override string ConfigFolder + { + get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } + } + + protected override string ConfigName + { + get { return "setting"; } + } + + protected override WebSearchStorage LoadDefault() + { + WebSearches = LoadDefaultWebSearches(); + return this; + } + + public List LoadDefaultWebSearches() + { + List webSearches = new List(); + + WebSearch googleWebSearch = new WebSearch() + { + Title = "Google", + ActionWord = "g", + IconPath = @"Images\websearch\google.png", + Url = "https://www.google.com/search?q={q}", + Enabled = true + }; + webSearches.Add(googleWebSearch); + + + WebSearch wikiWebSearch = new WebSearch() + { + Title = "Wikipedia", + ActionWord = "wiki", + IconPath = @"Images\websearch\wiki.png", + Url = "http://en.wikipedia.org/wiki/{q}", + Enabled = true + }; + webSearches.Add(wikiWebSearch); + + WebSearch findIcon = new WebSearch() + { + Title = "FindIcon", + ActionWord = "findicon", + IconPath = @"Images\websearch\pictures.png", + Url = "http://findicons.com/search/{q}", + Enabled = true + }; + webSearches.Add(findIcon); + + return webSearches; + } + } +} diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs index 474ada7589..1883ce8317 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs @@ -24,9 +24,9 @@ namespace Wox.Plugin.WebSearch private void Setting_Loaded(object sender, RoutedEventArgs e) { - webSearchView.ItemsSource = UserSettingStorage.Instance.WebSearches; - cbEnableWebSearchSuggestion.IsChecked = UserSettingStorage.Instance.EnableWebSearchSuggestion; - comboBoxSuggestionSource.Visibility = UserSettingStorage.Instance.EnableWebSearchSuggestion + webSearchView.ItemsSource = WebSearchStorage.Instance.WebSearches; + cbEnableWebSearchSuggestion.IsChecked = WebSearchStorage.Instance.EnableWebSearchSuggestion; + comboBoxSuggestionSource.Visibility = WebSearchStorage.Instance.EnableWebSearchSuggestion ? Visibility.Visible : Visibility.Collapsed; @@ -35,7 +35,7 @@ namespace Wox.Plugin.WebSearch new ComboBoxItem() {Content = "Google"}, new ComboBoxItem() {Content = "Baidu"}, }; - ComboBoxItem selected = items.FirstOrDefault(o => o.Content.ToString() == UserSettingStorage.Instance.WebSearchSuggestionSource); + ComboBoxItem selected = items.FirstOrDefault(o => o.Content.ToString() == WebSearchStorage.Instance.WebSearchSuggestionSource); if (selected == null) { selected = items[0]; @@ -58,14 +58,14 @@ namespace Wox.Plugin.WebSearch private void btnDeleteWebSearch_OnClick(object sender, RoutedEventArgs e) { - Core.UserSettings.WebSearch selectedWebSearch = webSearchView.SelectedItem as Core.UserSettings.WebSearch; + WebSearch selectedWebSearch = webSearchView.SelectedItem as WebSearch; if (selectedWebSearch != null) { string msg = string.Format(context.API.GetTranslation("wox_plugin_websearch_delete_warning"),selectedWebSearch.Title); if (MessageBox.Show(msg,string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { - UserSettingStorage.Instance.WebSearches.Remove(selectedWebSearch); + WebSearchStorage.Instance.WebSearches.Remove(selectedWebSearch); webSearchView.Items.Refresh(); } } @@ -78,7 +78,7 @@ namespace Wox.Plugin.WebSearch private void btnEditWebSearch_OnClick(object sender, RoutedEventArgs e) { - Core.UserSettings.WebSearch selectedWebSearch = webSearchView.SelectedItem as Core.UserSettings.WebSearch; + WebSearch selectedWebSearch = webSearchView.SelectedItem as WebSearch; if (selectedWebSearch != null) { WebSearchSetting webSearch = new WebSearchSetting(this,context); @@ -95,23 +95,22 @@ namespace Wox.Plugin.WebSearch private void CbEnableWebSearchSuggestion_OnChecked(object sender, RoutedEventArgs e) { comboBoxSuggestionSource.Visibility = Visibility.Visible; - UserSettingStorage.Instance.EnableWebSearchSuggestion = true; - UserSettingStorage.Instance.Save(); + WebSearchStorage.Instance.EnableWebSearchSuggestion = true; + WebSearchStorage.Instance.Save(); } private void CbEnableWebSearchSuggestion_OnUnchecked(object sender, RoutedEventArgs e) { comboBoxSuggestionSource.Visibility = Visibility.Collapsed; - UserSettingStorage.Instance.EnableWebSearchSuggestion = false; - UserSettingStorage.Instance.Save(); + WebSearchStorage.Instance.EnableWebSearchSuggestion = false; + WebSearchStorage.Instance.Save(); } private void ComboBoxSuggestionSource_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { - UserSettingStorage.Instance.WebSearchSuggestionSource = - ((ComboBoxItem) e.AddedItems[0]).Content.ToString(); + WebSearchStorage.Instance.WebSearchSuggestionSource = ((ComboBoxItem) e.AddedItems[0]).Content.ToString(); UserSettingStorage.Instance.Save(); } } diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index ef331ba748..4cacd1a425 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -1,145 +1,147 @@ - - - - - Debug - AnyCPU - {403B57F2-1856-4FC7-8A24-36AB346B763E} - Library - Properties - Wox.Plugin.WebSearch - Wox.Plugin.WebSearch - v3.5 - 512 - ..\..\ - true - - - - true - full - false - ..\..\Output\Debug\Plugins\Wox.Plugin.WebSearch\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - ..\..\Output\Release\Plugins\Wox.Plugin.WebSearch\ - TRACE - prompt - 4 - false - - - - False - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll - - - - - - - - - - - - - - - - - - - - WebSearchesSetting.xaml - - - - WebSearchSetting.xaml - - - - - MSBuild:Compile - Designer - PreserveNewest - - - MSBuild:Compile - Designer - PreserveNewest - - - MSBuild:Compile - Designer - PreserveNewest - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - - - - - - {B749F0DB-8E75-47DB-9E5E-265D16D0C0D2} - Wox.Core - - - {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} - Wox.Infrastructure - - - {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} - Wox.Plugin - - - - - - PreserveNewest - - - - - PreserveNewest - - - - - PreserveNewest - - - - - PreserveNewest - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - + + + + + Debug + AnyCPU + {403B57F2-1856-4FC7-8A24-36AB346B763E} + Library + Properties + Wox.Plugin.WebSearch + Wox.Plugin.WebSearch + v3.5 + 512 + ..\..\ + true + + + + true + full + false + ..\..\Output\Debug\Plugins\Wox.Plugin.WebSearch\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + ..\..\Output\Release\Plugins\Wox.Plugin.WebSearch\ + TRACE + prompt + 4 + false + + + + False + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + WebSearchesSetting.xaml + + + + WebSearchSetting.xaml + + + + + + MSBuild:Compile + Designer + PreserveNewest + + + MSBuild:Compile + Designer + PreserveNewest + + + MSBuild:Compile + Designer + PreserveNewest + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + + + + {B749F0DB-8E75-47DB-9E5E-265D16D0C0D2} + Wox.Core + + + {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} + Wox.Infrastructure + + + {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} + Wox.Plugin + + + + + + PreserveNewest + + + + + PreserveNewest + + + + + PreserveNewest + + + + + PreserveNewest + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + \ No newline at end of file diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index 975c8a7bf5..399992fa6f 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -121,13 +121,10 @@ namespace Wox.Core.Plugin public static bool IsUserPluginQuery(Query query) { if (string.IsNullOrEmpty(query.RawQuery)) return false; - var strings = query.RawQuery.Split(' '); - var actionKeyword = string.Empty; - if (strings.Length > 0) - { - actionKeyword = strings[0].Trim(); - } + if(strings.Length == 1) return false; + + var actionKeyword = strings[0].Trim(); if (string.IsNullOrEmpty(actionKeyword)) return false; return plugins.Any(o => o.Metadata.PluginType == PluginType.User && o.Metadata.ActionKeyword == actionKeyword); diff --git a/Wox.Core/UserSettings/UserSettingStorage.cs b/Wox.Core/UserSettings/UserSettingStorage.cs index bb2cb82189..436cfaf707 100644 --- a/Wox.Core/UserSettings/UserSettingStorage.cs +++ b/Wox.Core/UserSettings/UserSettingStorage.cs @@ -55,9 +55,6 @@ namespace Wox.Core.UserSettings [JsonProperty] public string ResultItemFontStretch { get; set; } - [JsonProperty] - public List WebSearches { get; set; } - [JsonProperty] public double WindowLeft { get; set; } @@ -72,18 +69,14 @@ namespace Wox.Core.UserSettings [JsonProperty] public bool StartWoxOnSystemStartup { get; set; } + [Obsolete] [JsonProperty] public double Opacity { get; set; } + [Obsolete] [JsonProperty] public OpacityMode OpacityMode { get; set; } - [JsonProperty] - public bool EnableWebSearchSuggestion { get; set; } - - [JsonProperty] - public string WebSearchSuggestionSource { get; set; } - [JsonProperty] public bool LeaveCmdOpen { get; set; } @@ -105,44 +98,6 @@ namespace Wox.Core.UserSettings [JsonProperty] public string ProxyPassword { get; set; } - public List LoadDefaultWebSearches() - { - List webSearches = new List(); - - WebSearch googleWebSearch = new WebSearch() - { - Title = "Google", - ActionWord = "g", - IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\google.png", - Url = "https://www.google.com/search?q={q}", - Enabled = true - }; - webSearches.Add(googleWebSearch); - - - WebSearch wikiWebSearch = new WebSearch() - { - Title = "Wikipedia", - ActionWord = "wiki", - IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\wiki.png", - Url = "http://en.wikipedia.org/wiki/{q}", - Enabled = true - }; - webSearches.Add(wikiWebSearch); - - WebSearch findIcon = new WebSearch() - { - Title = "FindIcon", - ActionWord = "findicon", - IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\pictures.png", - Url = "http://findicons.com/search/{q}", - Enabled = true - }; - webSearches.Add(findIcon); - - return webSearches; - } - protected override string ConfigFolder { get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); } @@ -167,7 +122,6 @@ namespace Wox.Core.UserSettings DontPromptUpdateMsg = false; Theme = "Dark"; Language = "en"; - WebSearches = LoadDefaultWebSearches(); CustomizedPluginConfigs = new List(); Hotkey = "Alt + Space"; QueryBoxFont = FontFamily.GenericSansSerif.Name; diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index b9b40bb80a..e4d2764109 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -99,7 +99,6 @@ - diff --git a/Wox.Test/QueryTest.cs b/Wox.Test/QueryTest.cs index e1c6cb20a8..061e7d59f6 100644 --- a/Wox.Test/QueryTest.cs +++ b/Wox.Test/QueryTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using NUnit.Framework; +using Wox.Core.Plugin; using Wox.Plugin; namespace Wox.Test diff --git a/Wox/MainWindow.xaml b/Wox/MainWindow.xaml index bed65cd9ab..bfc5b9871f 100644 --- a/Wox/MainWindow.xaml +++ b/Wox/MainWindow.xaml @@ -13,12 +13,11 @@ AllowDrop="True" ShowInTaskbar="False" Style="{DynamicResource WindowStyle}" - Icon="Images\app.png" - > + Icon="Images\app.png"> - + diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 4f14984be8..dbb12dca6c 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -162,10 +162,6 @@ namespace Wox InitializeComponent(); ThreadPool.SetMaxThreads(30, 10); ThreadPool.SetMinThreads(10, 5); - if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow) - { - this.AllowsTransparency = true; - } WebRequest.RegisterPrefix("data", new DataWebRequestFactory()); GlobalHotkey.Instance.hookedKeyboardCallback += KListener_hookedKeyboardCallback; @@ -241,14 +237,6 @@ namespace Wox } InitProgressbarAnimation(); - - //only works for win7+ - if (UserSettingStorage.Instance.OpacityMode == OpacityMode.DWM) - DwmDropShadow.DropShadowToWindow(this); - - this.Background = Brushes.Transparent; - HwndSource.FromHwnd(new WindowInteropHelper(this).Handle).CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0); - WindowIntelopHelper.DisableControlBox(this); UpdaterManager.Instance.CheckUpdate(); } @@ -354,7 +342,7 @@ namespace Wox Query(q); Dispatcher.DelayInvoke("ShowProgressbar", originQuery => { - if (!queryHasReturn && originQuery == lastQuery) + if (!queryHasReturn && originQuery == lastQuery && !string.IsNullOrEmpty(lastQuery)) { StartProgress(); }