diff --git a/Plugins/Wox.Plugin.QueryHistory/QueryHistory.cs b/Plugins/Wox.Plugin.QueryHistory/QueryHistory.cs
index 7f74a9e0bd..838e08bfe1 100644
--- a/Plugins/Wox.Plugin.QueryHistory/QueryHistory.cs
+++ b/Plugins/Wox.Plugin.QueryHistory/QueryHistory.cs
@@ -34,8 +34,6 @@ namespace Wox.Plugin.QueryHistory
public void Init(PluginInitContext context)
{
this.context = context;
- context.API.AfterWoxQueryEvent += API_AfterWoxQueryEvent;
- context.API.BeforeWoxQueryEvent += API_BeforeWoxQueryEvent;
}
void API_BeforeWoxQueryEvent(WoxQueryEventArgs e)
diff --git a/Wox.CrashReporter/ReportWindow.xaml.cs b/Wox.CrashReporter/ReportWindow.xaml.cs
index c5a7d1a577..67c8b1d1a0 100644
--- a/Wox.CrashReporter/ReportWindow.xaml.cs
+++ b/Wox.CrashReporter/ReportWindow.xaml.cs
@@ -55,13 +55,18 @@ namespace Wox.CrashReporter
private void SendReport()
{
- string reproduceSteps =
- new TextRange(tbReproduceSteps.Document.ContentStart, tbReproduceSteps.Document.ContentEnd).Text;
- exception.ToExceptionless()
- .SetUserDescription(reproduceSteps)
- .Submit();
- ExceptionlessClient.Current.ProcessQueue();
- Close();
+ ThreadPool.QueueUserWorkItem(o =>
+ {
+ string reproduceSteps = new TextRange(tbReproduceSteps.Document.ContentStart, tbReproduceSteps.Document.ContentEnd).Text;
+ exception.ToExceptionless()
+ .SetUserDescription(reproduceSteps)
+ .Submit();
+ ExceptionlessClient.Current.ProcessQueue();
+ Dispatcher.Invoke(new Action(() =>
+ {
+ Close();
+ }));
+ });
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
diff --git a/Wox.Plugin/IPublicAPI.cs b/Wox.Plugin/IPublicAPI.cs
index 3b2691177e..7928440adf 100644
--- a/Wox.Plugin/IPublicAPI.cs
+++ b/Wox.Plugin/IPublicAPI.cs
@@ -46,7 +46,7 @@ namespace Wox.Plugin
/// Just change the query text, this won't raise search
///
///
- void ChangeQueryText(string query);
+ void ChangeQueryText(string query, bool selectAll = false);
///
/// Close Wox
@@ -122,16 +122,6 @@ namespace Wox.Plugin
///
event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent;
- ///
- /// Fired after wox execute a query
- ///
- event AfterWoxQueryEventHandler AfterWoxQueryEvent;
-
- ///
- /// Fired before wox start to execute a query
- ///
- event AfterWoxQueryEventHandler BeforeWoxQueryEvent;
-
///
/// Fired after drop to result item of current plugin
///
diff --git a/Wox.sln b/Wox.sln
index 1759a11e0a..07ab868b2d 100644
--- a/Wox.sln
+++ b/Wox.sln
@@ -39,8 +39,6 @@ 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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.UpdateFeedGenerator", "Wox.UpdateFeedGenerator\Wox.UpdateFeedGenerator.csproj", "{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Plugins\Wox.Plugin.Everything\Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}"
@@ -119,10 +117,6 @@ 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
{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -147,7 +141,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}
{230AE83F-E92E-4E69-8355-426B305DA9C0} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
EndGlobalSection
EndGlobal
diff --git a/Wox/App.config b/Wox/App.config
index ab8b3cde5f..55ab1e0d9d 100644
--- a/Wox/App.config
+++ b/Wox/App.config
@@ -1,8 +1,5 @@
-
-
-
@@ -12,5 +9,4 @@
-
\ No newline at end of file
diff --git a/Wox/Images/history.png b/Wox/Images/history.png
new file mode 100644
index 0000000000..6bb070398f
Binary files /dev/null and b/Wox/Images/history.png differ
diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs
index 7cea6f4a7d..e04fd218cf 100644
--- a/Wox/MainWindow.xaml.cs
+++ b/Wox/MainWindow.xaml.cs
@@ -68,13 +68,17 @@ namespace Wox
}));
}
- public void ChangeQueryText(string query)
+ public void ChangeQueryText(string query, bool selectAll = false)
{
Dispatcher.Invoke(new Action(() =>
{
ignoreTextChange = true;
tbQuery.Text = query;
tbQuery.CaretIndex = tbQuery.Text.Length;
+ if (selectAll)
+ {
+ tbQuery.SelectAll();
+ }
}));
}
@@ -144,8 +148,6 @@ namespace Wox
public event WoxKeyDownEventHandler BackKeyDownEvent;
public event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent;
- public event AfterWoxQueryEventHandler AfterWoxQueryEvent;
- public event AfterWoxQueryEventHandler BeforeWoxQueryEvent;
public event ResultItemDropEventHandler ResultItemDropEvent;
public void PushResults(Query query, PluginMetadata plugin, List results)
@@ -433,7 +435,6 @@ namespace Wox
queryHasReturn = false;
Query query = new Query(lastQuery);
query.IsIntantQuery = searchDelay == 0;
- FireBeforeWoxQueryEvent(query);
Query(query);
Dispatcher.DelayInvoke("ShowProgressbar", originQuery =>
{
@@ -442,10 +443,15 @@ namespace Wox
StartProgress();
}
}, TimeSpan.FromMilliseconds(150), tbQuery.Text);
- FireAfterWoxQueryEvent(query);
+ //reset query history index after user start new query
+ ResetQueryHistoryIndex();
}, TimeSpan.FromMilliseconds(searchDelay));
}
+ private void ResetQueryHistoryIndex()
+ {
+ QueryHistoryStorage.Instance.Reset();
+ }
private int GetSearchDelay(string query)
{
if (!string.IsNullOrEmpty(query) && PluginManager.IsInstantQuery(query))
@@ -458,38 +464,6 @@ namespace Wox
return 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)
{
PluginManager.Query(q);
@@ -544,6 +518,7 @@ namespace Wox
Activate();
Focus();
tbQuery.Focus();
+ ResetQueryHistoryIndex();
if (selectAll) tbQuery.SelectAll();
}
@@ -616,12 +591,26 @@ namespace Wox
break;
case Key.Down:
- SelectNextItem();
+ if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
+ {
+ DisplayNextQuery();
+ }
+ else
+ {
+ SelectNextItem();
+ }
e.Handled = true;
break;
case Key.Up:
- SelectPrevItem();
+ if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
+ {
+ DisplayPrevQuery();
+ }
+ else
+ {
+ SelectPrevItem();
+ }
e.Handled = true;
break;
@@ -703,6 +692,40 @@ namespace Wox
}
}
+ private void DisplayPrevQuery()
+ {
+ var prev = QueryHistoryStorage.Instance.Previous();
+ DisplayQueryHistory(prev);
+ }
+
+ private void DisplayNextQuery()
+ {
+ var nextQuery = QueryHistoryStorage.Instance.Next();
+ DisplayQueryHistory(nextQuery);
+ }
+
+ private void DisplayQueryHistory(HistoryItem history)
+ {
+ if (history != null)
+ {
+ ChangeQueryText(history.Query, true);
+ pnlResult.Dirty = true;
+ UpdateResultViewInternal(new List()
+ {
+ new Result(){
+ Title = "Execute " + history.Query+ " query",
+ SubTitle = "Last Execute Time: " + history.ExecutedDateTime,
+ IcoPath = "Images\\history.png",
+ PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
+ Action = _ =>{
+ ChangeQuery(history.Query,true);
+ return false;
+ }
+ }
+ });
+ }
+ }
+
private void SelectItem(int index)
{
int zeroBasedIndex = index - 1;
@@ -775,6 +798,7 @@ namespace Wox
HideWox();
}
UserSelectedRecordStorage.Instance.Add(result);
+ QueryHistoryStorage.Instance.Add(tbQuery.Text);
}
}
}
@@ -792,13 +816,18 @@ namespace Wox
o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o) * 5;
});
List l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList();
- Dispatcher.Invoke(new Action(() =>
- {
- pnlResult.AddResults(l);
- }));
+ UpdateResultViewInternal(l);
}
}
+ private void UpdateResultViewInternal(List list)
+ {
+ Dispatcher.Invoke(new Action(() =>
+ {
+ pnlResult.AddResults(list);
+ }));
+ }
+
private Result GetTopMostContextMenu(Result result)
{
if (TopMostRecordStorage.Instance.IsTopMost(result))
diff --git a/Wox/Properties/AssemblyInfo.cs b/Wox/Properties/AssemblyInfo.cs
index cfddac76a7..b4d5aea913 100644
--- a/Wox/Properties/AssemblyInfo.cs
+++ b/Wox/Properties/AssemblyInfo.cs
@@ -20,4 +20,4 @@ using System.Windows;
)]
[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0")]
-[assembly: Exceptionless.Configuration.Exceptionless("13462a93b5e843c7bae7da13a86bc00b", EnableLogging = true, LogPath = "E:\\exceptionless.log")]
\ No newline at end of file
+[assembly: Exceptionless.Configuration.Exceptionless("e0b256fbe9384498ba89aae2a6b7f8ab")]
\ No newline at end of file
diff --git a/Wox/ResultPanel.xaml b/Wox/ResultPanel.xaml
index f221205206..26b18f4f1a 100644
--- a/Wox/ResultPanel.xaml
+++ b/Wox/ResultPanel.xaml
@@ -24,7 +24,7 @@
-
+
diff --git a/Wox/ResultPanel.xaml.cs b/Wox/ResultPanel.xaml.cs
index c52367f69c..21251bb010 100644
--- a/Wox/ResultPanel.xaml.cs
+++ b/Wox/ResultPanel.xaml.cs
@@ -145,26 +145,25 @@ namespace Wox
private void UpdateItemNumber()
{
- VirtualizingStackPanel virtualizingStackPanel = GetInnerStackPanel(lbResults);
- int index = 0;
- for (int i = (int)virtualizingStackPanel.VerticalOffset; i <= virtualizingStackPanel.VerticalOffset + virtualizingStackPanel.ViewportHeight; i++)
- {
- index++;
- ListBoxItem item = lbResults.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;
- if (item != null)
- {
- ContentPresenter myContentPresenter = FindVisualChild(item);
- if (myContentPresenter != null)
- {
- DataTemplate dataTemplate = myContentPresenter.ContentTemplate;
- TextBlock tbItemNumber = (TextBlock)dataTemplate.FindName("tbItemNumber", myContentPresenter);
- tbItemNumber.Text = index.ToString();
- }
- }
- }
+ //VirtualizingStackPanel virtualizingStackPanel = GetInnerStackPanel(lbResults);
+ //int index = 0;
+ //for (int i = (int)virtualizingStackPanel.VerticalOffset; i <= virtualizingStackPanel.VerticalOffset + virtualizingStackPanel.ViewportHeight; i++)
+ //{
+ // index++;
+ // ListBoxItem item = lbResults.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;
+ // if (item != null)
+ // {
+ // ContentPresenter myContentPresenter = FindVisualChild(item);
+ // if (myContentPresenter != null)
+ // {
+ // DataTemplate dataTemplate = myContentPresenter.ContentTemplate;
+ // TextBlock tbItemNumber = (TextBlock)dataTemplate.FindName("tbItemNumber", myContentPresenter);
+ // tbItemNumber.Text = index.ToString();
+ // }
+ // }
+ //}
}
-
private childItem FindVisualChild(DependencyObject obj) where childItem : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
diff --git a/Wox/Storage/QueryHistoryStorage.cs b/Wox/Storage/QueryHistoryStorage.cs
new file mode 100644
index 0000000000..d39ebaad14
--- /dev/null
+++ b/Wox/Storage/QueryHistoryStorage.cs
@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using Newtonsoft.Json;
+using Wox.Infrastructure.Storage;
+
+namespace Wox.Storage
+{
+ 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.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); }
+ }
+
+ protected override string ConfigName
+ {
+ get { return "QueryHistory"; }
+ }
+
+ public HistoryItem Previous()
+ {
+ if (History.Count == 0 || cursor == 0) return null;
+ return History[--cursor];
+ }
+
+ public HistoryItem Next()
+ {
+ if (History.Count == 0 || cursor >= History.Count - 1) return null;
+ return History[++cursor];
+ }
+
+ public void Reset()
+ {
+ cursor = History.Count;
+ }
+
+ 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();
+ }
+
+ Reset();
+ }
+
+ public List GetHistory()
+ {
+ return History.OrderByDescending(o => o.ExecutedDateTime).ToList();
+ }
+ }
+
+ 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/Wox/Wox.csproj b/Wox/Wox.csproj
index 0a3a843e2e..5795de7ba8 100644
--- a/Wox/Wox.csproj
+++ b/Wox/Wox.csproj
@@ -123,6 +123,7 @@
+
@@ -194,6 +195,7 @@
PreserveNewest
+
Designer
MSBuild:Compile