From 7db73cbd44d0cd51b71dbe105ccf08c99ea9a8b4 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Sat, 7 Nov 2015 02:23:40 +0000 Subject: [PATCH 1/7] tmp --- .../ContextMenuStorage.cs | 3 +- .../PluginIndicator.cs | 5 +- Wox.Core/Plugin/PluginManager.cs | 48 ++++++++----------- Wox/Helper/ListBoxItems.cs | 28 +++++++++++ Wox/MainWindow.xaml.cs | 45 ++++++++++++----- Wox/Properties/Resources.Designer.cs | 26 +++++----- Wox/Properties/Settings.Designer.cs | 10 ++-- Wox/ResultPanel.xaml.cs | 35 +++++++++----- 8 files changed, 125 insertions(+), 75 deletions(-) create mode 100644 Wox/Helper/ListBoxItems.cs diff --git a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs index bbb0d33753..ba36209b6a 100644 --- a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs +++ b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs @@ -1,7 +1,8 @@ using System.Collections.Generic; using System.IO; using System.Reflection; -using Newtonsoft.Json; +using Exceptionless.Json; +using JsonProperty = Newtonsoft.Json.JsonPropertyAttribute; using Wox.Infrastructure.Storage; namespace Wox.Plugin.Everything diff --git a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs index f7b2bd0314..f7f518889c 100644 --- a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs +++ b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs @@ -13,10 +13,9 @@ namespace Wox.Plugin.PluginIndicator public List Query(Query query) { - var results = from plugin in PluginManager.NonGlobalPlugins - select plugin.Metadata into metadata - from keyword in metadata.ActionKeywords + var results = from keyword in PluginManager.NonGlobalPlugins.Keys where keyword.StartsWith(query.Terms[0]) + let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata let customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID) where customizedPluginConfig == null || !customizedPluginConfig.Disabled diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index 6123508c3a..bb7a700796 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -29,8 +29,8 @@ namespace Wox.Core.Plugin public static IEnumerable AllPlugins { get; private set; } - public static IEnumerable GlobalPlugins { get; private set; } - public static IEnumerable NonGlobalPlugins { get; private set; } + public static List GlobalPlugins { get; } = new List(); + public static Dictionary NonGlobalPlugins { get; } = new Dictionary(); private static IEnumerable InstantQueryPlugins { get; set; } public static IPublicAPI API { private set; get; } @@ -104,8 +104,20 @@ namespace Wox.Core.Plugin { InstantQueryPlugins = GetPluginsForInterface(); contextMenuPlugins = GetPluginsForInterface(); - GlobalPlugins = AllPlugins.Where(p => IsGlobalPlugin(p.Metadata)); - NonGlobalPlugins = AllPlugins.Where(p => !IsGlobalPlugin(p.Metadata)); + foreach (var plugin in AllPlugins) + { + if (IsGlobalPlugin(plugin.Metadata)) + { + GlobalPlugins.Add(plugin); + } + else + { + foreach (string actionKeyword in plugin.Metadata.ActionKeywords) + { + NonGlobalPlugins[actionKeyword] = plugin; + } + } + } }); } @@ -123,7 +135,7 @@ namespace Wox.Core.Plugin var search = rawQuery; List actionParameters = terms.ToList(); if (terms.Length == 0) return null; - if (IsVailldActionKeyword(terms[0])) + if (NonGlobalPlugins.ContainsKey(terms[0])) { actionKeyword = terms[0]; actionParameters = terms.Skip(1).ToList(); @@ -143,8 +155,8 @@ namespace Wox.Core.Plugin public static void QueryForAllPlugins(Query query) { - var pluginPairs = GetPluginForActionKeyword(query.ActionKeyword) != null ? - new List { GetPluginForActionKeyword(query.ActionKeyword) } : GlobalPlugins; + var pluginPairs = NonGlobalPlugins.ContainsKey(query.ActionKeyword) ? + new List { NonGlobalPlugins[query.ActionKeyword] } : GlobalPlugins; foreach (var plugin in pluginPairs) { var customizedPluginConfig = UserSettingStorage.Instance. @@ -187,21 +199,6 @@ namespace Wox.Core.Plugin } } - /// - /// Check if a query contains valid action keyword - /// - /// - /// - private static bool IsVailldActionKeyword(string actionKeyword) - { - if (string.IsNullOrEmpty(actionKeyword) || actionKeyword == Query.GlobalPluginWildcardSign) return false; - PluginPair pair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeywords.Contains(actionKeyword)); - if (pair == null) return false; - var customizedPluginConfig = UserSettingStorage.Instance. - CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pair.Metadata.ID); - return customizedPluginConfig == null || !customizedPluginConfig.Disabled; - } - private static bool IsGlobalPlugin(PluginMetadata metadata) { return metadata.ActionKeywords.Contains(Query.GlobalPluginWildcardSign); @@ -225,13 +222,6 @@ namespace Wox.Core.Plugin return AllPlugins.FirstOrDefault(o => o.Metadata.ID == id); } - private static PluginPair GetPluginForActionKeyword(string actionKeyword) - { - //if a query doesn't contain a vaild action keyword, it should be a query for system plugin - if (string.IsNullOrEmpty(actionKeyword) || actionKeyword == Query.GlobalPluginWildcardSign) return null; - return NonGlobalPlugins.FirstOrDefault(o => o.Metadata.ActionKeywords.Contains(actionKeyword)); - } - public static IEnumerable GetPluginsForInterface() where T : IFeatures { return AllPlugins.Where(p => p.Plugin is T); diff --git a/Wox/Helper/ListBoxItems.cs b/Wox/Helper/ListBoxItems.cs new file mode 100644 index 0000000000..28a3e0062b --- /dev/null +++ b/Wox/Helper/ListBoxItems.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Linq; +using Wox.Plugin; + +namespace Wox.Helper +{ + class ListBoxItems : ObservableCollection + { + public void RemoveAll(Predicate predicate) + { + CheckReentrancy(); + + List itemsToRemove = Items.Where(x => predicate(x)).ToList(); + if (itemsToRemove.Count > 0) + { + itemsToRemove.ForEach(item => Items.Remove(item)); + + OnPropertyChanged(new PropertyChangedEventArgs("Count")); + OnPropertyChanged(new PropertyChangedEventArgs("Item[]")); + OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, itemsToRemove)); + } + } + } +} diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 13481cd019..61d56a032b 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -43,11 +43,11 @@ namespace Wox private readonly Storyboard progressBarStoryboard = new Storyboard(); private NotifyIcon notifyIcon; - private bool queryHasReturn; - private string lastQuery; + private bool _queryHasReturn; + private Query _lastQuery = new Query(); private ToolTip toolTip = new ToolTip(); - private bool ignoreTextChange = false; + private bool _ignoreTextChange = false; private List CurrentContextMenus = new List(); private string textBeforeEnterContextMenuMode; @@ -72,7 +72,7 @@ namespace Wox { Dispatcher.Invoke(new Action(() => { - ignoreTextChange = true; + _ignoreTextChange = true; tbQuery.Text = query; tbQuery.CaretIndex = tbQuery.Text.Length; if (selectAll) @@ -441,10 +441,10 @@ namespace Wox private void TbQuery_OnTextChanged(object sender, TextChangedEventArgs e) { - - if (ignoreTextChange) { ignoreTextChange = false; return; } - if (!string.IsNullOrEmpty(tbQuery.Text.Trim())) + if (_ignoreTextChange) { _ignoreTextChange = false; return; } + string query = tbQuery.Text.Trim(); + if (!string.IsNullOrEmpty(query)) { toolTip.IsOpen = false; if (IsInContextMenuMode) @@ -453,10 +453,10 @@ namespace Wox return; } - Query(tbQuery.Text); + Query(query); Dispatcher.DelayInvoke("ShowProgressbar", () => { - if (!string.IsNullOrEmpty(tbQuery.Text.Trim()) && tbQuery.Text != lastQuery && !queryHasReturn) + if (!string.IsNullOrEmpty(query) && query != _lastQuery.RawQuery && !_queryHasReturn) { StartProgress(); } @@ -479,7 +479,28 @@ namespace Wox var query = PluginManager.QueryInit(text); if (query != null) { - lastQuery = query.RawQuery; + // handle the exclusiveness of plugin using action keyword + string lastKeyword = _lastQuery.ActionKeyword; + string keyword = query.ActionKeyword; + if (string.IsNullOrEmpty(lastKeyword)) + { + if (!string.IsNullOrEmpty(keyword)) + { + pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword]); + } + } + else + { + if (string.IsNullOrEmpty(keyword)) + { + pnlResult.RemoveResultsFor(PluginManager.NonGlobalPlugins[lastKeyword]); + } + else if (lastKeyword != keyword) + { + pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword]); + } + } + _lastQuery = query; PluginManager.QueryForAllPlugins(query); } StopProgress(); @@ -814,7 +835,7 @@ namespace Wox private void UpdateResultView(List list) { - queryHasReturn = true; + _queryHasReturn = true; progressBar.Dispatcher.Invoke(new Action(StopProgress)); if (list == null || list.Count == 0) return; @@ -824,7 +845,7 @@ namespace Wox { o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o) * 5; }); - List l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList(); + List l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == _lastQuery.RawQuery).ToList(); UpdateResultViewInternal(l); } } diff --git a/Wox/Properties/Resources.Designer.cs b/Wox/Properties/Resources.Designer.cs index 7665c71436..20e0fb2257 100644 --- a/Wox/Properties/Resources.Designer.cs +++ b/Wox/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// 此代码由工具生成。 -// 运行时版本:4.0.30319.0 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -13,12 +13,12 @@ namespace Wox.Properties { /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] @@ -33,7 +33,7 @@ namespace Wox.Properties { } /// - /// 返回此类使用的缓存的 ResourceManager 实例。 + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ namespace Wox.Properties { } /// - /// 使用此强类型资源类,为所有资源查找 - /// 重写当前线程的 CurrentUICulture 属性。 + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ namespace Wox.Properties { } /// - /// 查找类似于 (Icon) 的 System.Drawing.Icon 类型的本地化资源。 + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// internal static System.Drawing.Icon app { get { diff --git a/Wox/Properties/Settings.Designer.cs b/Wox/Properties/Settings.Designer.cs index eb3d4dc309..7a4226349e 100644 --- a/Wox/Properties/Settings.Designer.cs +++ b/Wox/Properties/Settings.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// 此代码由工具生成。 -// 运行时版本:4.0.30319.0 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -12,7 +12,7 @@ namespace Wox.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/Wox/ResultPanel.xaml.cs b/Wox/ResultPanel.xaml.cs index 3115ece6ef..3d8510f818 100644 --- a/Wox/ResultPanel.xaml.cs +++ b/Wox/ResultPanel.xaml.cs @@ -9,6 +9,7 @@ using System.Windows.Media; using System.Linq; using System.Runtime.Remoting.Contexts; using Wox.Core.UserSettings; +using Wox.Helper; using Wox.Plugin; using Wox.Storage; @@ -20,7 +21,7 @@ namespace Wox public event Action LeftMouseClickEvent; public event Action RightMouseClickEvent; public event Action ItemDropEvent; - private readonly ObservableCollection _results; //todo, for better performance, override the default linear search + private readonly ListBoxItems _results; //todo, for better performance, override the default linear search private readonly object _resultsUpdateLock = new object(); protected virtual void OnRightMouseClick(Result result) @@ -38,6 +39,25 @@ namespace Wox public int MaxResultsToShow { get { return UserSettingStorage.Instance.MaxResultsToShow * 50; } } + internal void RemoveResultsFor(PluginPair plugin) + { + lock (_resultsUpdateLock) + { + _results.RemoveAll(r => r.PluginID == plugin.Metadata.ID); + } + } + + internal void RemoveResultsExcept(PluginPair plugin) + { + lock (_resultsUpdateLock) + { + _results.RemoveAll(r => r.PluginID != plugin.Metadata.ID); + } + } + + + + public void AddResults(List newResults) { if (newResults != null && newResults.Count > 0) @@ -45,16 +65,7 @@ namespace Wox lock (_resultsUpdateLock) { var pluginId = newResults[0].PluginID; - var actionKeyword = newResults[0].OriginQuery.ActionKeyword; - List oldResults; - if (string.IsNullOrEmpty(actionKeyword)) - { - oldResults = _results.Where(r => r.PluginID == pluginId).ToList(); - } - else - { - oldResults = _results.ToList(); - } + var oldResults = _results.Where(r => r.PluginID == pluginId).ToList(); // intersection of A (old results) and B (new newResults) var intersection = oldResults.Intersect(newResults).ToList(); @@ -236,7 +247,7 @@ namespace Wox public ResultPanel() { InitializeComponent(); - _results = new ObservableCollection(); + _results = new ListBoxItems(); lbResults.ItemsSource = _results; } From 08594f0b96b235f9de42d4456f775401042ef426 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Sat, 7 Nov 2015 03:03:54 +0000 Subject: [PATCH 2/7] Upgrade to .net 4.5 --- Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj | 13 ++++---- Plugins/Wox.Plugin.CMD/packages.config | 4 +-- .../Wox.Plugin.Caculator.csproj | 4 +-- Plugins/Wox.Plugin.Caculator/packages.config | 2 +- .../Wox.Plugin.Color/Wox.Plugin.Color.csproj | 2 +- .../Wox.Plugin.ControlPanel.csproj | 2 +- .../ContextMenuStorage.cs | 1 - .../Wox.Plugin.Everything.csproj | 18 ++++++---- Plugins/Wox.Plugin.Everything/packages.config | 3 +- .../Wox.Plugin.Folder.csproj | 10 +++--- Plugins/Wox.Plugin.Folder/packages.config | 2 +- .../Wox.Plugin.PluginIndicator.csproj | 2 +- .../Wox.Plugin.PluginManagement.csproj | 6 ++-- .../packages.config | 2 +- .../Wox.Plugin.Program.csproj | 8 +++-- Plugins/Wox.Plugin.Program/packages.config | 2 +- Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj | 6 ++-- Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj | 2 +- .../Wox.Plugin.WebSearch.csproj | 7 ++-- Plugins/Wox.Plugin.WebSearch/packages.config | 2 +- Wox.Core/Wox.Core.csproj | 9 ++--- Wox.Core/packages.config | 6 ++-- Wox.CrashReporter/Wox.CrashReporter.csproj | 15 ++++++--- Wox.CrashReporter/packages.config | 2 +- Wox.Infrastructure/Wox.Infrastructure.csproj | 12 ++++--- Wox.Infrastructure/packages.config | 6 ++-- Wox.Plugin/Wox.Plugin.csproj | 8 +++-- Wox.Test/Wox.Test.csproj | 13 +++++--- Wox.Test/packages.config | 4 +-- .../Wox.UpdateFeedGenerator.csproj | 17 ++++++---- Wox.UpdateFeedGenerator/app.config | 3 ++ Wox.UpdateFeedGenerator/packages.config | 4 +-- Wox/App.config | 5 ++- Wox/Wox.csproj | 33 ++++++++++++++----- Wox/packages.config | 14 ++++---- 35 files changed, 150 insertions(+), 99 deletions(-) create mode 100644 Wox.UpdateFeedGenerator/app.config diff --git a/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj b/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj index 2b7280a2b5..cb10d95247 100644 --- a/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj +++ b/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.CMD Wox.Plugin.CMD - v3.5 + v4.5.2 512 ..\..\ @@ -34,8 +34,8 @@ false - - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll True @@ -43,13 +43,15 @@ + - + ..\..\packages\InputSimulator.1.0.4.0\lib\net20\WindowsInput.dll + True @@ -110,5 +112,4 @@ --> - - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.CMD/packages.config b/Plugins/Wox.Plugin.CMD/packages.config index 4687456d1a..0be4b18f6f 100644 --- a/Plugins/Wox.Plugin.CMD/packages.config +++ b/Plugins/Wox.Plugin.CMD/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj b/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj index 907c4ff929..e28fab5d13 100644 --- a/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj +++ b/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.Caculator Wox.Plugin.Caculator - v3.5 + v4.5.2 512 ..\..\ @@ -39,8 +39,8 @@ - False ..\..\packages\YAMP.1.4.0\lib\net35\YAMP.dll + True diff --git a/Plugins/Wox.Plugin.Caculator/packages.config b/Plugins/Wox.Plugin.Caculator/packages.config index 4e151aa36f..ef1566573c 100644 --- a/Plugins/Wox.Plugin.Caculator/packages.config +++ b/Plugins/Wox.Plugin.Caculator/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj b/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj index 847df6d016..eebd501f0f 100644 --- a/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj +++ b/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.Color Wox.Plugin.Color - v3.5 + v4.5.2 512 diff --git a/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj b/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj index 86f8a2c2a8..9b19f29657 100644 --- a/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj +++ b/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.ControlPanel Wox.Plugin.ControlPanel - v3.5 + v4.5.2 512 diff --git a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs index ba36209b6a..1971cf95ae 100644 --- a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs +++ b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.IO; using System.Reflection; -using Exceptionless.Json; using JsonProperty = Newtonsoft.Json.JsonPropertyAttribute; using Wox.Infrastructure.Storage; diff --git a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj index 1b8afe4139..3df41be678 100644 --- a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj +++ b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,9 +9,10 @@ Properties Wox.Plugin.Everything Wox.Plugin.Everything - v3.5 + v4.5.2 512 ..\Wox\ + true @@ -22,6 +23,7 @@ prompt 4 AnyCPU + false pdbonly @@ -30,14 +32,19 @@ TRACE prompt 4 + false + + ..\..\packages\Exceptionless.Portable.3.1.1416\lib\net45\Exceptionless.Portable.dll + True + - False - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + True @@ -137,5 +144,4 @@ --> - - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Everything/packages.config b/Plugins/Wox.Plugin.Everything/packages.config index 7a13476a54..654e648df6 100644 --- a/Plugins/Wox.Plugin.Everything/packages.config +++ b/Plugins/Wox.Plugin.Everything/packages.config @@ -1,4 +1,5 @@  - + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj b/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj index 748cd7c6d8..e4cc76f35b 100644 --- a/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj +++ b/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.Folder Wox.Plugin.Folder - v3.5 + v4.5.2 512 ..\..\ @@ -34,8 +34,8 @@ false - - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll True @@ -43,6 +43,7 @@ + @@ -111,5 +112,4 @@ --> - - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Folder/packages.config b/Plugins/Wox.Plugin.Folder/packages.config index 7a13476a54..0b84f87d4d 100644 --- a/Plugins/Wox.Plugin.Folder/packages.config +++ b/Plugins/Wox.Plugin.Folder/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.PluginIndicator/Wox.Plugin.PluginIndicator.csproj b/Plugins/Wox.Plugin.PluginIndicator/Wox.Plugin.PluginIndicator.csproj index e57ab20a8d..5ec360cd3d 100644 --- a/Plugins/Wox.Plugin.PluginIndicator/Wox.Plugin.PluginIndicator.csproj +++ b/Plugins/Wox.Plugin.PluginIndicator/Wox.Plugin.PluginIndicator.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.PluginIndicator Wox.Plugin.PluginIndicator - v3.5 + v4.5.2 512 diff --git a/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj b/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj index f88fb7d916..870bf34574 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj +++ b/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.PluginManagement Wox.Plugin.PluginManagement - v3.5 + v4.5.2 512 ..\..\ @@ -34,8 +34,8 @@ false - - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll True diff --git a/Plugins/Wox.Plugin.PluginManagement/packages.config b/Plugins/Wox.Plugin.PluginManagement/packages.config index 7a13476a54..0b84f87d4d 100644 --- a/Plugins/Wox.Plugin.PluginManagement/packages.config +++ b/Plugins/Wox.Plugin.PluginManagement/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj index 84b26a6cd1..4294512e26 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.Program Wox.Plugin.Program - v3.5 + v4.5.2 512 ..\..\ @@ -34,15 +34,17 @@ false + - False - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + True + diff --git a/Plugins/Wox.Plugin.Program/packages.config b/Plugins/Wox.Plugin.Program/packages.config index 7a13476a54..0b84f87d4d 100644 --- a/Plugins/Wox.Plugin.Program/packages.config +++ b/Plugins/Wox.Plugin.Program/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj b/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj index 2bfb924a5c..1b303bcb7d 100644 --- a/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj +++ b/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.Sys Wox.Plugin.Sys - v3.5 + v4.5.2 512 ..\..\ @@ -39,6 +39,7 @@ + @@ -129,5 +130,4 @@ --> - - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj b/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj index 23e5ac1a8f..ef17910a3c 100644 --- a/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj +++ b/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.Url Wox.Plugin.Url - v3.5 + v4.5.2 512 diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index 32a1b26e4a..17ee860d8f 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -9,7 +9,7 @@ Properties Wox.Plugin.WebSearch Wox.Plugin.WebSearch - v3.5 + v4.5.2 512 ..\..\ @@ -35,13 +35,14 @@ - False - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + True + diff --git a/Plugins/Wox.Plugin.WebSearch/packages.config b/Plugins/Wox.Plugin.WebSearch/packages.config index 7a13476a54..0b84f87d4d 100644 --- a/Plugins/Wox.Plugin.WebSearch/packages.config +++ b/Plugins/Wox.Plugin.WebSearch/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index c7e8072a24..c6160c84e5 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -9,7 +9,7 @@ Properties Wox.Core Wox.Core - v3.5 + v4.5.2 512 ..\ @@ -35,16 +35,16 @@ - False ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + True ..\packages\NAppUpdate.Framework.0.3.2.0\lib\net20\NAppUpdate.Framework.dll True - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + True @@ -52,6 +52,7 @@ + diff --git a/Wox.Core/packages.config b/Wox.Core/packages.config index 2825ea4cc2..93b11a0396 100644 --- a/Wox.Core/packages.config +++ b/Wox.Core/packages.config @@ -1,6 +1,6 @@  - - - + + + \ No newline at end of file diff --git a/Wox.CrashReporter/Wox.CrashReporter.csproj b/Wox.CrashReporter/Wox.CrashReporter.csproj index 0194c1d262..dd3f3b3160 100644 --- a/Wox.CrashReporter/Wox.CrashReporter.csproj +++ b/Wox.CrashReporter/Wox.CrashReporter.csproj @@ -9,7 +9,7 @@ Properties Wox.CrashReporter Wox.CrashReporter - v3.5 + v4.5.2 512 ..\ @@ -34,13 +34,19 @@ false - - ..\packages\Exceptionless.1.5.2121\lib\net35\Exceptionless.dll + + ..\packages\Exceptionless.1.5.2121\lib\net45\Exceptionless.dll + True + + + ..\packages\Exceptionless.1.5.2121\lib\net45\Exceptionless.Models.dll + True + @@ -95,5 +101,4 @@ --> - - + \ No newline at end of file diff --git a/Wox.CrashReporter/packages.config b/Wox.CrashReporter/packages.config index aaa9e6ed9c..a8a044e437 100644 --- a/Wox.CrashReporter/packages.config +++ b/Wox.CrashReporter/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index e3740ee2cc..a02fd514e3 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,7 +9,7 @@ Properties Wox.Infrastructure Wox.Infrastructure - v3.5 + v4.5.2 512 ..\ @@ -37,11 +37,11 @@ - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + True - ..\packages\NLog.4.2.0\lib\net35\NLog.dll + ..\packages\NLog.4.2.0\lib\net45\NLog.dll True @@ -78,6 +78,8 @@ Always + + Designer diff --git a/Wox.Infrastructure/packages.config b/Wox.Infrastructure/packages.config index 0c8252da99..3023f2583f 100644 --- a/Wox.Infrastructure/packages.config +++ b/Wox.Infrastructure/packages.config @@ -1,6 +1,6 @@  - - - + + + \ No newline at end of file diff --git a/Wox.Plugin/Wox.Plugin.csproj b/Wox.Plugin/Wox.Plugin.csproj index 11c1b4c89b..5c4fb10f00 100644 --- a/Wox.Plugin/Wox.Plugin.csproj +++ b/Wox.Plugin/Wox.Plugin.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,8 +9,9 @@ Properties Wox.Plugin Wox.Plugin - v3.5 + v4.5.2 512 + true @@ -21,6 +22,7 @@ prompt 4 AnyCPU + false pdbonly @@ -29,12 +31,14 @@ TRACE prompt 4 + false + diff --git a/Wox.Test/Wox.Test.csproj b/Wox.Test/Wox.Test.csproj index 8d54d3612e..867c3ac771 100644 --- a/Wox.Test/Wox.Test.csproj +++ b/Wox.Test/Wox.Test.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,7 +9,7 @@ Properties Wox.Test Wox.Test - v3.5 + v4.5.2 512 ..\ @@ -34,9 +34,13 @@ false + + ..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll + True + - False ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + True @@ -77,5 +81,4 @@ --> - - + \ No newline at end of file diff --git a/Wox.Test/packages.config b/Wox.Test/packages.config index 565203e846..8bd8a9d0e8 100644 --- a/Wox.Test/packages.config +++ b/Wox.Test/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj b/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj index 8801cc14a6..b05de76110 100644 --- a/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj +++ b/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj @@ -9,9 +9,10 @@ Properties Wox.UpdateFeedGenerator Wox.UpdateFeedGenerator - v3.5 + v4.5.2 512 ..\ + AnyCPU @@ -22,6 +23,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -31,6 +33,7 @@ TRACE prompt 4 + false @@ -38,8 +41,8 @@ True - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + True @@ -57,7 +60,10 @@ - + + + Designer + @@ -74,5 +80,4 @@ --> - - + \ No newline at end of file diff --git a/Wox.UpdateFeedGenerator/app.config b/Wox.UpdateFeedGenerator/app.config new file mode 100644 index 0000000000..ff99501038 --- /dev/null +++ b/Wox.UpdateFeedGenerator/app.config @@ -0,0 +1,3 @@ + + + diff --git a/Wox.UpdateFeedGenerator/packages.config b/Wox.UpdateFeedGenerator/packages.config index 9661aa0af8..23f4f18934 100644 --- a/Wox.UpdateFeedGenerator/packages.config +++ b/Wox.UpdateFeedGenerator/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/Wox/App.config b/Wox/App.config index 55ab1e0d9d..1c9852a233 100644 --- a/Wox/App.config +++ b/Wox/App.config @@ -1,12 +1,15 @@ + +
+ - + \ No newline at end of file diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index ff6ac6882c..80a69120c1 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,7 +9,7 @@ Properties Wox Wox - v3.5 + v4.5.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 @@ -61,21 +61,30 @@ - False - ..\packages\Exceptionless.1.5.2121\lib\net35\Exceptionless.dll + ..\packages\Exceptionless.1.5.2121\lib\net45\Exceptionless.dll + True - + + ..\packages\Exceptionless.1.5.2121\lib\net45\Exceptionless.Models.dll + True + + + ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + True + + ..\packages\MarkdownSharp.1.13.0.0\lib\35\MarkdownSharp.dll + True - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + True - False ..\packages\NHotkey.1.2.1\lib\net20\NHotkey.dll + True - + ..\packages\NHotkey.Wpf.1.2.1\lib\net35\NHotkey.Wpf.dll True @@ -89,6 +98,7 @@ + @@ -98,6 +108,10 @@ + + ..\packages\InputSimulator.1.0.4.0\lib\net20\WindowsInput.dll + True + @@ -106,6 +120,7 @@ + diff --git a/Wox/packages.config b/Wox/packages.config index 054bbd20c3..ed8b710f14 100644 --- a/Wox/packages.config +++ b/Wox/packages.config @@ -1,10 +1,10 @@  - - - - - - - + + + + + + + \ No newline at end of file From 7de0a0a44a3bec8b935574d10989f0410e6304a4 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Thu, 12 Nov 2015 22:14:22 +0000 Subject: [PATCH 3/7] Fix "The type initializer for 'System.Windows.Application' threw an exception." --- Wox/App.config | 7 ------- Wox/Wox.csproj | 3 --- 2 files changed, 10 deletions(-) delete mode 100644 Wox/App.config diff --git a/Wox/App.config b/Wox/App.config deleted file mode 100644 index cb06db06c4..0000000000 --- a/Wox/App.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index dfffcb3558..29065f7681 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -295,9 +295,6 @@ ResXFileCodeGenerator Resources.Designer.cs - - Designer - SettingsSingleFileGenerator Settings.Designer.cs From ebae67596162fe3a5fe21cbfdf797a1da8afebda Mon Sep 17 00:00:00 2001 From: bao-qian Date: Sun, 13 Dec 2015 13:36:29 +0000 Subject: [PATCH 4/7] Fixup missing reference --- Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj index 6ffb3aecdf..069e266aa4 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -34,6 +34,7 @@ false + ..\..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll True From 4d25d505e0cd5af772f16fc7ae738a1253b7027c Mon Sep 17 00:00:00 2001 From: bao-qian Date: Sat, 2 Jan 2016 04:34:20 +0000 Subject: [PATCH 5/7] Fix color of selected item and mouse item This is part of .net 4.5 fix, check #393 to see more --- Wox/ResultPanel.xaml | 78 +++++++++++++++++++++++++++--------- Wox/Themes/BlurBlack.xaml | 2 +- Wox/Themes/BlurWhite.xaml | 2 +- Wox/Themes/Dark.xaml | 2 +- Wox/Themes/Gray.xaml | 2 +- Wox/Themes/Light.xaml | 2 +- Wox/Themes/Metro Server.xaml | 2 +- Wox/Themes/Pink.xaml | 2 +- 8 files changed, 65 insertions(+), 27 deletions(-) diff --git a/Wox/ResultPanel.xaml b/Wox/ResultPanel.xaml index 83e3f4b0e3..6abd51faec 100644 --- a/Wox/ResultPanel.xaml +++ b/Wox/ResultPanel.xaml @@ -7,44 +7,82 @@ xmlns:converters="clr-namespace:Wox.Converters" mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100"> - - - - - - - + - + - - + + - - + - - + + - - + + - + - - - + + + + + + + \ No newline at end of file diff --git a/Wox/Themes/BlurBlack.xaml b/Wox/Themes/BlurBlack.xaml index dc1c5ec540..ebd1ef0df7 100644 --- a/Wox/Themes/BlurBlack.xaml +++ b/Wox/Themes/BlurBlack.xaml @@ -46,7 +46,7 @@ - #356ef3 + #356ef3 - #356ef3 + #356ef3 - #4F6180 + #4F6180 - #00AAF6 + #00AAF6 - #3875D7 + #3875D7 - #006ac1 + #006ac1 - #cc1081 + #cc1081 \ No newline at end of file From f9e27ef67c6a27034acb049fa34650f7c0c1875d Mon Sep 17 00:00:00 2001 From: bao-qian Date: Sat, 2 Jan 2016 06:59:06 +0000 Subject: [PATCH 6/7] Fix UI flickering under .net 4.5 1. This is part of .net 4.5 fix, check #393 to see more 2. This bug is introduced since commit df4ca3fecc9784a3b55f93806d8b2a662523056f --- Plugins/Wox.Plugin.Program/Programs.cs | 7 +++-- Wox.Plugin/Result.cs | 6 ++--- Wox/ResultPanel.xaml.cs | 37 ++++++++++++++------------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index 347f640b8a..08e384fd04 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -30,9 +30,9 @@ namespace Wox.Plugin.Program { var fuzzyMather = FuzzyMatcher.Create(query.Search); - var results = programs.Where(o => MatchProgram(o, fuzzyMather)). + var results = programs.Where(p => MatchProgram(p, fuzzyMather)). Select(ScoreFilter). - OrderByDescending(o => o.Score) + OrderByDescending(p => p.Score) .Select(c => new Result() { Title = c.Title, @@ -62,8 +62,7 @@ namespace Wox.Plugin.Program { var scores = new List { program.Title, program.PinyinTitle, program.AbbrTitle, program.ExecuteName }; program.Score = scores.Select(s => matcher.Evaluate(s ?? string.Empty).Score).Max(); - if (program.Score > 0) return true; - else return false; + return program.Score > 0; } public void Init(PluginInitContext context) diff --git a/Wox.Plugin/Result.cs b/Wox.Plugin/Result.cs index 992c50a5d1..ced01e38b3 100644 --- a/Wox.Plugin/Result.cs +++ b/Wox.Plugin/Result.cs @@ -48,8 +48,7 @@ namespace Wox.Plugin if (r != null) { var equality = string.Equals(r.Title, Title) && - string.Equals(r.SubTitle, SubTitle) && - r.Score == Score; + string.Equals(r.SubTitle, SubTitle); return equality; } else @@ -61,8 +60,7 @@ namespace Wox.Plugin public override int GetHashCode() { var hashcode = (Title?.GetHashCode() ?? 0) ^ - (SubTitle?.GetHashCode() ?? 0) ^ - (Score.GetHashCode()); + (SubTitle?.GetHashCode() ?? 0) ; return hashcode; } diff --git a/Wox/ResultPanel.xaml.cs b/Wox/ResultPanel.xaml.cs index 121ee9b852..d2daa2bb5a 100644 --- a/Wox/ResultPanel.xaml.cs +++ b/Wox/ResultPanel.xaml.cs @@ -58,16 +58,19 @@ namespace Wox public void AddResults(List newResults, string resultId) { + // todo check count in the previous call + if (newResults.Count == 0) return; lock (_resultsUpdateLock) { - var resultCopy = _results.ToList(); - var oldResults = resultCopy.Where(r => r.PluginID == resultId).ToList(); + // todo use async to do new result calculation + var resultsCopy = _results.ToList(); + var oldResults = resultsCopy.Where(r => r.PluginID == resultId).ToList(); // intersection of A (old results) and B (new newResults) var intersection = oldResults.Intersect(newResults).ToList(); // remove result of relative complement of B in A foreach (var result in oldResults.Except(intersection)) { - resultCopy.Remove(result); + resultsCopy.Remove(result); } // update scores @@ -80,31 +83,31 @@ namespace Wox } // update index for result in intersection of A and B - foreach (var result in intersection) + foreach (var commonResult in intersection) { - int oldIndex = resultCopy.IndexOf(result); - int oldScore = resultCopy[oldIndex].Score; - if (result.Score != oldScore) + int oldIndex = resultsCopy.IndexOf(commonResult); + int oldScore = resultsCopy[oldIndex].Score; + int newScore = newResults[newResults.IndexOf(commonResult)].Score; + if (newScore != oldScore) { - int newIndex = InsertIndexOf(result.Score, resultCopy); - if (newIndex != oldIndex) - { - var item = resultCopy[oldIndex]; - resultCopy.RemoveAt(oldIndex); - resultCopy.Insert(newIndex, item); - } + var oldResult = resultsCopy[oldIndex]; + oldResult.Score = newScore; + resultsCopy.RemoveAt(oldIndex); + int newIndex = InsertIndexOf(newScore, resultsCopy); + resultsCopy.Insert(newIndex, oldResult); + } } // insert result in relative complement of A in B foreach (var result in newResults.Except(intersection)) { - int newIndex = InsertIndexOf(result.Score, resultCopy); - resultCopy.Insert(newIndex, result); + int newIndex = InsertIndexOf(result.Score, resultsCopy); + resultsCopy.Insert(newIndex, result); } // update UI in one run, so it can avoid UI flickering - _results.Update(resultCopy); + _results.Update(resultsCopy); lbResults.Margin = lbResults.Items.Count > 0 ? new Thickness { Top = 8 } : new Thickness { Top = 0 }; SelectFirst(); From a3ca1febbc4a77f034453a43ed4978a7a53387be Mon Sep 17 00:00:00 2001 From: bao-qian Date: Sat, 2 Jan 2016 23:22:58 +0000 Subject: [PATCH 7/7] ResultPanel should be empty when there is no result --- Wox/ResultPanel.xaml.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Wox/ResultPanel.xaml.cs b/Wox/ResultPanel.xaml.cs index d2daa2bb5a..534a561c97 100644 --- a/Wox/ResultPanel.xaml.cs +++ b/Wox/ResultPanel.xaml.cs @@ -58,8 +58,6 @@ namespace Wox public void AddResults(List newResults, string resultId) { - // todo check count in the previous call - if (newResults.Count == 0) return; lock (_resultsUpdateLock) { // todo use async to do new result calculation