From b49209a0d952cee2b12a6f7f7351c65f500aa2a2 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sun, 18 Jan 2015 18:21:48 +0800 Subject: [PATCH] Add query history plugin & upgrade all third-party packages --- Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj | 2 +- Plugins/Wox.Plugin.CMD/packages.config | 2 +- Plugins/Wox.Plugin.Folder/FolderPlugin.cs | 2 +- .../Wox.Plugin.Folder.csproj | 6 +- Plugins/Wox.Plugin.Folder/packages.config | 2 +- .../Wox.Plugin.PluginManagement.csproj | 6 +- .../packages.config | 2 +- .../Wox.Plugin.Program.csproj | 6 +- Plugins/Wox.Plugin.Program/packages.config | 2 +- .../Wox.Plugin.QueryHistory/HistoryItem.cs | 53 ++++++++++ .../Images/history.png | Bin 0 -> 4219 bytes .../Properties/AssemblyInfo.cs | 36 +++++++ .../Wox.Plugin.QueryHistory/QueryHistory.cs | 51 ++++++++++ .../QueryHistoryStorage.cs | 83 ++++++++++++++++ .../Wox.Plugin.QueryHistory.csproj | 92 ++++++++++++++++++ .../Wox.Plugin.QueryHistory/packages.config | 4 + Plugins/Wox.Plugin.QueryHistory/plugin.json | 12 +++ .../Wox.Plugin.WebSearch/WebSearchPlugin.cs | 2 +- .../Wox.Plugin.WebSearch.csproj | 2 +- Plugins/Wox.Plugin.WebSearch/packages.config | 2 +- .../SystemPluginQueryDispatcher.cs | 9 -- Wox.Core/UserSettings/UserSettingStorage.cs | 9 +- Wox.Core/Wox.Core.csproj | 2 +- Wox.Core/packages.config | 2 +- Wox.Infrastructure/Wox.Infrastructure.csproj | 2 +- Wox.Infrastructure/packages.config | 2 +- Wox.Plugin/EventHandler.cs | 8 +- Wox.Plugin/IPublicAPI.cs | 13 ++- Wox.Test/Wox.Test.csproj | 4 +- Wox.Test/packages.config | 2 +- Wox.sln | 7 ++ Wox/MainWindow.xaml.cs | 53 ++++++++-- Wox/Wox.csproj | 10 +- Wox/packages.config | 6 +- 34 files changed, 445 insertions(+), 51 deletions(-) create mode 100644 Plugins/Wox.Plugin.QueryHistory/HistoryItem.cs create mode 100644 Plugins/Wox.Plugin.QueryHistory/Images/history.png create mode 100644 Plugins/Wox.Plugin.QueryHistory/Properties/AssemblyInfo.cs create mode 100644 Plugins/Wox.Plugin.QueryHistory/QueryHistory.cs create mode 100644 Plugins/Wox.Plugin.QueryHistory/QueryHistoryStorage.cs create mode 100644 Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj create mode 100644 Plugins/Wox.Plugin.QueryHistory/packages.config create mode 100644 Plugins/Wox.Plugin.QueryHistory/plugin.json diff --git a/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj b/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj index 83d5cd93a4..bb495a5761 100644 --- a/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj +++ b/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj @@ -40,7 +40,7 @@ ..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll - ..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll True diff --git a/Plugins/Wox.Plugin.CMD/packages.config b/Plugins/Wox.Plugin.CMD/packages.config index a56b48a806..9b94c8e082 100644 --- a/Plugins/Wox.Plugin.CMD/packages.config +++ b/Plugins/Wox.Plugin.CMD/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs index 0d50ce0ca0..32b41578f5 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs @@ -31,7 +31,7 @@ namespace Wox.Plugin.Folder } } - private void ApiBackKeyDownEvent(object sender, WoxKeyDownEventArgs e) + private void ApiBackKeyDownEvent(WoxKeyDownEventArgs e) { string query = e.Query; if (Directory.Exists(query)) diff --git a/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj b/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj index 30cc7ea875..3f7e303731 100644 --- a/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj +++ b/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj @@ -39,9 +39,9 @@ False ..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll - - False - ..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll + + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + True diff --git a/Plugins/Wox.Plugin.Folder/packages.config b/Plugins/Wox.Plugin.Folder/packages.config index 6c533b9f5c..8b4715c3c9 100644 --- a/Plugins/Wox.Plugin.Folder/packages.config +++ b/Plugins/Wox.Plugin.Folder/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj b/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj index 9a3faefbd1..b7e35ad144 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj +++ b/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj @@ -35,9 +35,9 @@ false - - False - ..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll + + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + True diff --git a/Plugins/Wox.Plugin.PluginManagement/packages.config b/Plugins/Wox.Plugin.PluginManagement/packages.config index 4185726464..7a13476a54 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 fe3ac8026f..62d515d85f 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -39,9 +39,9 @@ ..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll True - - ..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll - True + + False + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll diff --git a/Plugins/Wox.Plugin.Program/packages.config b/Plugins/Wox.Plugin.Program/packages.config index 6c533b9f5c..8b4715c3c9 100644 --- a/Plugins/Wox.Plugin.Program/packages.config +++ b/Plugins/Wox.Plugin.Program/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.QueryHistory/HistoryItem.cs b/Plugins/Wox.Plugin.QueryHistory/HistoryItem.cs new file mode 100644 index 0000000000..0921a95203 --- /dev/null +++ b/Plugins/Wox.Plugin.QueryHistory/HistoryItem.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Wox.Plugin.QueryHistory +{ + public class HistoryItem + { + public string Query { get; set; } + public DateTime ExecutedDateTime { get; set; } + + public string GetTimeAgo() + { + return DateTimeAgo(ExecutedDateTime); + } + + private string DateTimeAgo(DateTime dt) + { + TimeSpan span = DateTime.Now - dt; + if (span.Days > 365) + { + int years = (span.Days / 365); + if (span.Days % 365 != 0) + years += 1; + return String.Format("about {0} {1} ago", + years, years == 1 ? "year" : "years"); + } + if (span.Days > 30) + { + int months = (span.Days / 30); + if (span.Days % 31 != 0) + months += 1; + return String.Format("about {0} {1} ago", + months, months == 1 ? "month" : "months"); + } + if (span.Days > 0) + return String.Format("about {0} {1} ago", + span.Days, span.Days == 1 ? "day" : "days"); + if (span.Hours > 0) + return String.Format("about {0} {1} ago", + span.Hours, span.Hours == 1 ? "hour" : "hours"); + if (span.Minutes > 0) + return String.Format("about {0} {1} ago", + span.Minutes, span.Minutes == 1 ? "minute" : "minutes"); + if (span.Seconds > 5) + return String.Format("about {0} seconds ago", span.Seconds); + if (span.Seconds <= 5) + return "just now"; + return string.Empty; + } + } +} diff --git a/Plugins/Wox.Plugin.QueryHistory/Images/history.png b/Plugins/Wox.Plugin.QueryHistory/Images/history.png new file mode 100644 index 0000000000000000000000000000000000000000..6bb070398fdac483d4a9a5d6ce14440334efd927 GIT binary patch literal 4219 zcmV->5QOiEP)QnwUV9PP3!h_+jH7m^T?IESxzJY#$8@!aqF9pC=(-kW)ogaz8& zR(;Y>W54+wpU?OF{l32e{+~a}k6^4C`c(b*;RXP7Nt1p<=#%~@AU^JxplN>70Yv1O5Le3B;q4#G};3I z(sqh4?W|I*T%hIR8IfB&z4*O%rsk)n$^a|?uHX2_CGt@TDDcc903HL-vFrZ(w&~-W z_v`D|9qJtD-x`lZ5YwZGMs(<^4psB4iwgmyzedS{l z2-|rKKyvij9V6*O2kuYr+5Oq>bh?KiQED_$F-=&m(;7+SiH;~FLjsZi4nQmtK`Nd^ zS278W6qL)wV);Mcd8YFETi=*Ic`^&20Z$`g|G4bYJ_NiDPwL$}?!4oM?jwhPW9{CX zAC4vBiIrLv^Q)_p+XLfU_EsGm`BDiD*Y*+p5G7s`MB7nN^V4!1 zR2vOws)pX-kulzz+0t#qmkMXk74RYcaHZ8%pI96~X4{c__VwI%$LG6;hc++QYN%RP z+u{_SmI(IjoZUEmwqahFc3LHjX6}`Q0A4Edg|9tV zsGoRWO2^gE9^1q7YN`o0@6*3&GGM=uLH@HaB;o{K6|=zVPN- zZvzNIZg}1{6AD6Q6hP|H^SSC!@_9fJ6_Qk9<^_#z!w`VR&5Sc!32LOx4V$Sf^ zYxss6Z_o!fjlnPs+p1QX;9Mfe#6-f)FKXr2->M|GZZY((&PdCg04^8=7w8-s9OW)+ z6i=Ky<B*|2Z#{xy$2^e2eN(^a$4>fsBierlqc{o}7zNC?N5Hjl>R zZ2Y!;vF#82>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xf|pB76Yj*sIW|50JV|*rBz-5K zd1+;?Nra>nRIMs%BC%FYBvOi|c{OK$0m(U57Z#vx+MFJ{=ib4Aj-*x1<;t#Y1FdT$ zH`Eva-qGD{@3{N!p5ezHA1`%wX7XnzAem@08wdemnc&&%JUesxRp~fy`?g<1d&#}6 zHX1H1b^#ayuu)5;?lgAo`jkGnwqK3Mp=fRUKhOR&9htR*NcF8j(y{~=7i;FsOfjgq z69I|!SNC9WptBK+Y2~FQlos-kj9(VzNC-&N1Y2BOVkb|$CTg{p089eN0jT)GxU4c4 zCebYJ!t;kwt+Vs?==SaV^|eE5)mR*AB;sZ2D}>BQECwT)gpo|PP3$!4u<8wP%eqVe z%~Kk4AuS6$pUbm}GjE7`{a*k~!L$1hE$)UNiB^SKkn0xZ@-ipJQffzM2L6%rN_j$Z z4yVz8SuT66RDxM9!)=(5jJ4wq!n5lEm!=6ed2W)OKlg2En%@R610e5%4{zz4&j%48 zzjO0SlsGTSQmH6PrKr-;nITD$rp-3d2cZ`2vA?-$yPcEEK#mJ(HXy1M(>;0on3$h` znHc*nfLR}W376RYM)cWy@gaNFhOyceo)g z0LDR#LAoxaX?jv`)CHTEm}D2uy)G-2mqBy}z(sfwCy;#j`nB!(SeJYNG64Dk3<4NX z4C4m1J2S2g4vuI&y=g_$K#Jm-R`akI>^;2gv*Mo}cyXm97ZX^A3PTAM_Hu zO#6{8`TkqitN_vgdI9tS=z*dPDN$pil1L1z9UXm2M`xEBPb6W)q9A}A+m&{sLG^lt z>h)zZ&3SU2Nf71Wg~nw7EAY(aM|RD6X}`-Zx_vTTeoF!9gje>9`Gf;C1g01yvziaI z; Query(Query query) + { + var histories = QueryHistoryStorage.Instance.GetHistory(); + string filter = query.GetAllRemainingParameter(); + if (!string.IsNullOrEmpty(filter)) + { + histories = histories.Where(o => o.Query.Contains(filter)).ToList(); + } + return histories.Select(history => new Result() + { + Title = history.Query, + SubTitle = history.GetTimeAgo(), + IcoPath = "Images\\history.png", + Action = _ => + { + context.API.ChangeQuery(history.Query); + return false; + } + }).ToList(); + } + + public void Init(PluginInitContext context) + { + this.context = context; + context.API.AfterWoxQueryEvent += API_AfterWoxQueryEvent; + context.API.BeforeWoxQueryEvent += API_BeforeWoxQueryEvent; + } + + void API_BeforeWoxQueryEvent(WoxQueryEventArgs e) + { + Thread.Sleep(5000); + } + + private void API_AfterWoxQueryEvent(WoxQueryEventArgs e) + { + QueryHistoryStorage.Instance.Add(e.Query.RawQuery); + } + } +} diff --git a/Plugins/Wox.Plugin.QueryHistory/QueryHistoryStorage.cs b/Plugins/Wox.Plugin.QueryHistory/QueryHistoryStorage.cs new file mode 100644 index 0000000000..3d10f4a491 --- /dev/null +++ b/Plugins/Wox.Plugin.QueryHistory/QueryHistoryStorage.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using Newtonsoft.Json; +using Wox.Core.Exception; +using Wox.Infrastructure.Storage; + +namespace Wox.Plugin.QueryHistory +{ + public class QueryHistoryStorage : JsonStrorage + { + [JsonProperty] + private List History = new List(); + + private int MaxHistory = 300; + private int cursor = 0; + + protected override string ConfigFolder + { + get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } + } + + protected override string ConfigName + { + get { return "QueryHistory"; } + } + + public HistoryItem Pop() + { + if (History.Count == 0) return null; + + if (cursor > History.Count - 1) + { + cursor = History.Count - 1; + } + if (cursor < 0) + { + cursor = 0; + } + + return History[cursor--]; + } + + public void Reset() + { + cursor = History.Count - 1; + } + + public void Add(string query) + { + if (string.IsNullOrEmpty(query)) return; + if (History.Count > MaxHistory) + { + History.RemoveAt(0); + } + + if (History.Count > 0 && History.Last().Query == query) + { + History.Last().ExecutedDateTime = DateTime.Now; + } + else + { + History.Add(new HistoryItem() + { + Query = query, + ExecutedDateTime = DateTime.Now + }); + } + + if (History.Count % 5 == 0) + { + Save(); + } + } + + public List GetHistory() + { + return History.OrderByDescending(o => o.ExecutedDateTime).ToList(); + } + } +} diff --git a/Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj b/Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj new file mode 100644 index 0000000000..9ae22def69 --- /dev/null +++ b/Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj @@ -0,0 +1,92 @@ + + + + + Debug + AnyCPU + {B552DCB6-692E-4B1D-9E0B-9096A2A7E6B0} + Library + Properties + Wox.Plugin.QueryHistory + Wox.Plugin.QueryHistory + v3.5 + 512 + ..\..\ + true + + + true + full + false + ..\..\Output\Debug\Plugins\Wox.Plugin.QueryHistory\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\Output\Release\Plugins\Wox.Plugin.Program\ + TRACE + prompt + 4 + + + + False + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + {B749F0DB-8E75-47DB-9E5E-265D16D0C0D2} + Wox.Core + + + {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} + Wox.Infrastructure + + + {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} + Wox.Plugin + + + + + + PreserveNewest + + + + + PreserveNewest + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.QueryHistory/packages.config b/Plugins/Wox.Plugin.QueryHistory/packages.config new file mode 100644 index 0000000000..7a13476a54 --- /dev/null +++ b/Plugins/Wox.Plugin.QueryHistory/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.QueryHistory/plugin.json b/Plugins/Wox.Plugin.QueryHistory/plugin.json new file mode 100644 index 0000000000..959874b682 --- /dev/null +++ b/Plugins/Wox.Plugin.QueryHistory/plugin.json @@ -0,0 +1,12 @@ +{ + "ID":"54F327C503414B9489CDD331EE9472EF", + "ActionKeyword":"history", + "Name":"Query History", + "Description":"Remember Wox query history", + "Author":"qianlifeng", + "Version":"1.0.0", + "Language":"csharp", + "Website":"http://www.getwox.com/plugin", + "ExecuteFileName":"Wox.Plugin.QueryHistory.dll", + "IcoPath":"Images\\history.png" +} \ No newline at end of file diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs index f7bd002aa5..11989fb32c 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs @@ -44,7 +44,7 @@ namespace Wox.Plugin.WebSearch return true; } } - }); + },true); if (UserSettingStorage.Instance.EnableWebSearchSuggestion && !string.IsNullOrEmpty(keyword)) { diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index fbace415a0..a78368bfa1 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -41,7 +41,7 @@ False - ..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll diff --git a/Plugins/Wox.Plugin.WebSearch/packages.config b/Plugins/Wox.Plugin.WebSearch/packages.config index 6c533b9f5c..8b4715c3c9 100644 --- a/Plugins/Wox.Plugin.WebSearch/packages.config +++ b/Plugins/Wox.Plugin.WebSearch/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs b/Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs index c69e591328..e8ef1ee4fe 100644 --- a/Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs +++ b/Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs @@ -16,15 +16,6 @@ namespace Wox.Core.Plugin.QueryDispatcher public void Dispatch(Query query) { var queryPlugins = allSytemPlugins; - if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == query.ActionName && o.Enabled)) - { - //websearch mode - queryPlugins = new List() - { - allSytemPlugins.First(o => o.Metadata.ID == "565B73353DBF4806919830B9202EE3BF") - }; - } - foreach (PluginPair pair in queryPlugins) { PluginPair pair1 = pair; diff --git a/Wox.Core/UserSettings/UserSettingStorage.cs b/Wox.Core/UserSettings/UserSettingStorage.cs index 100d7c4fde..9b1af13a61 100644 --- a/Wox.Core/UserSettings/UserSettingStorage.cs +++ b/Wox.Core/UserSettings/UserSettingStorage.cs @@ -167,7 +167,14 @@ namespace Wox.Core.UserSettings OpacityMode = OpacityMode.Normal; LeaveCmdOpen = false; HideWhenDeactive = false; - + CustomPluginHotkeys = new List() + { + new CustomPluginHotkey() + { + ActionKeyword = "history ", + Hotkey = "Alt + H" + } + }; return this; } diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index 05aff0cd08..87cbaa4e5b 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -41,7 +41,7 @@ False - ..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll diff --git a/Wox.Core/packages.config b/Wox.Core/packages.config index 6311fc40d5..09e1c4eff1 100644 --- a/Wox.Core/packages.config +++ b/Wox.Core/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index fdb44026ea..1e897d3d26 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -44,7 +44,7 @@ False - ..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll diff --git a/Wox.Infrastructure/packages.config b/Wox.Infrastructure/packages.config index 6c533b9f5c..8b4715c3c9 100644 --- a/Wox.Infrastructure/packages.config +++ b/Wox.Infrastructure/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/Wox.Plugin/EventHandler.cs b/Wox.Plugin/EventHandler.cs index f3ef7e2e2d..f3c6121f92 100644 --- a/Wox.Plugin/EventHandler.cs +++ b/Wox.Plugin/EventHandler.cs @@ -6,7 +6,8 @@ using System.Windows.Input; namespace Wox.Plugin { - public delegate void WoxKeyDownEventHandler(object sender, WoxKeyDownEventArgs e); + public delegate void WoxKeyDownEventHandler(WoxKeyDownEventArgs e); + public delegate void AfterWoxQueryEventHandler(WoxQueryEventArgs e); /// /// Global keyboard events @@ -22,4 +23,9 @@ namespace Wox.Plugin public string Query { get; set; } public KeyEventArgs keyEventArgs { get; set; } } + + public class WoxQueryEventArgs + { + public Query Query { get; set; } + } } diff --git a/Wox.Plugin/IPublicAPI.cs b/Wox.Plugin/IPublicAPI.cs index 231faf4a7f..9188d9afd3 100644 --- a/Wox.Plugin/IPublicAPI.cs +++ b/Wox.Plugin/IPublicAPI.cs @@ -12,7 +12,8 @@ namespace Wox.Plugin /// /// /// - void PushResults(Query query,PluginMetadata plugin, List results); + /// + void PushResults(Query query,PluginMetadata plugin, List results,bool clearBeforeInsert = false); bool ShellRun(string cmd, bool runAsAdministrator = false); @@ -43,5 +44,15 @@ namespace Wox.Plugin event WoxKeyDownEventHandler BackKeyDownEvent; event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent; + + /// + /// fired after wox execute a query + /// + event AfterWoxQueryEventHandler AfterWoxQueryEvent; + + /// + /// fired before wox start to execute a query + /// + event AfterWoxQueryEventHandler BeforeWoxQueryEvent; } } diff --git a/Wox.Test/Wox.Test.csproj b/Wox.Test/Wox.Test.csproj index 122f1f9520..8ddecc0bac 100644 --- a/Wox.Test/Wox.Test.csproj +++ b/Wox.Test/Wox.Test.csproj @@ -39,9 +39,9 @@ ..\packages\Moq.4.2.1409.1722\lib\net35\Moq.dll True - + False - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll diff --git a/Wox.Test/packages.config b/Wox.Test/packages.config index 27bc1f3865..565203e846 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.sln b/Wox.sln index 089fe39c81..cd2007ff85 100644 --- a/Wox.sln +++ b/Wox.sln @@ -39,6 +39,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Color", "Plugins EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.CrashReporter", "Wox.CrashReporter\Wox.CrashReporter.csproj", "{2FEB2298-7653-4009-B1EA-FFFB1A768BCC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.QueryHistory", "Plugins\Wox.Plugin.QueryHistory\Wox.Plugin.QueryHistory.csproj", "{B552DCB6-692E-4B1D-9E0B-9096A2A7E6B0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -113,6 +115,10 @@ Global {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Debug|Any CPU.Build.0 = Debug|Any CPU {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|Any CPU.ActiveCfg = Release|Any CPU {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|Any CPU.Build.0 = Release|Any CPU + {B552DCB6-692E-4B1D-9E0B-9096A2A7E6B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B552DCB6-692E-4B1D-9E0B-9096A2A7E6B0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B552DCB6-692E-4B1D-9E0B-9096A2A7E6B0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B552DCB6-692E-4B1D-9E0B-9096A2A7E6B0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -129,5 +135,6 @@ Global {0B9DE348-9361-4940-ADB6-F5953BFFCCEC} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} {A3DCCBCA-ACC1-421D-B16E-210896234C26} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} {F35190AA-4758-4D9E-A193-E3BDF6AD3567} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} + {B552DCB6-692E-4B1D-9E0B-9096A2A7E6B0} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} EndGlobalSection EndGlobal diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index a61d37ff83..e80c981372 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -132,8 +132,10 @@ namespace Wox public event WoxKeyDownEventHandler BackKeyDownEvent; public event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent; + public event AfterWoxQueryEventHandler AfterWoxQueryEvent; + public event AfterWoxQueryEventHandler BeforeWoxQueryEvent; - public void PushResults(Query query, PluginMetadata plugin, List results) + public void PushResults(Query query, PluginMetadata plugin, List results, bool clearBeforeInsert = false) { results.ForEach(o => { @@ -147,7 +149,7 @@ namespace Wox } o.OriginQuery = query; }); - OnUpdateResultView(results); + OnUpdateResultView(results, clearBeforeInsert); } #endregion @@ -360,6 +362,7 @@ namespace Wox }, TimeSpan.FromMilliseconds(100), null); queryHasReturn = false; var q = new Query(lastQuery); + FireBeforeWoxQueryEvent(q); Query(q); BackToResultMode(); Dispatcher.DelayInvoke("ShowProgressbar", originQuery => @@ -369,9 +372,42 @@ namespace Wox StartProgress(); } }, TimeSpan.FromMilliseconds(150), lastQuery); + FireAfterWoxQueryEvent(q); }, TimeSpan.FromMilliseconds(ShouldNotDelayQuery ? 0 : 200)); } + private void FireAfterWoxQueryEvent(Query q) + { + if (AfterWoxQueryEvent != null) + { + //We shouldn't let those events slow down real query + //so I put it in the new thread + ThreadPool.QueueUserWorkItem(o => + { + AfterWoxQueryEvent(new WoxQueryEventArgs() + { + Query = q + }); + }); + } + } + + private void FireBeforeWoxQueryEvent(Query q) + { + if (BeforeWoxQueryEvent != null) + { + //We shouldn't let those events slow down real query + //so I put it in the new thread + ThreadPool.QueueUserWorkItem(o => + { + BeforeWoxQueryEvent(new WoxQueryEventArgs() + { + Query = q + }); + }); + } + } + private void Query(Query q) { try @@ -532,7 +568,7 @@ namespace Wox case Key.Back: if (BackKeyDownEvent != null) { - BackKeyDownEvent(tbQuery, new WoxKeyDownEventArgs() + BackKeyDownEvent(new WoxKeyDownEventArgs() { Query = tbQuery.Text, keyEventArgs = e @@ -623,7 +659,7 @@ namespace Wox } } - private void OnUpdateResultView(List list) + private void OnUpdateResultView(List list, bool clearBeforeInsert = false) { queryHasReturn = true; progressBar.Dispatcher.Invoke(new Action(StopProgress)); @@ -639,8 +675,13 @@ namespace Wox }); List l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList(); Dispatcher.Invoke(new Action(() => - pnlResult.AddResults(l)) - ); + { + if (clearBeforeInsert) + { + pnlResult.Clear(); + } + pnlResult.AddResults(l); + })); } } diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 159ee42067..3de730a3c6 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -72,14 +72,14 @@ False - ..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll - - ..\packages\NHotkey.1.1.0.0\lib\NHotkey.dll - True + + False + ..\packages\NHotkey.1.2.1\lib\net20\NHotkey.dll - ..\packages\NHotkey.Wpf.1.1.0.0\lib\NHotkey.Wpf.dll + ..\packages\NHotkey.Wpf.1.2.1\lib\net35\NHotkey.Wpf.dll True diff --git a/Wox/packages.config b/Wox/packages.config index 3db4249dc3..5c9cf4a6fb 100644 --- a/Wox/packages.config +++ b/Wox/packages.config @@ -2,8 +2,8 @@ - - - + + + \ No newline at end of file