From 3fea8eb8206f903240a620d8e350170a4b984c15 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sun, 27 Jul 2014 17:15:12 +0800 Subject: [PATCH] Fix a crash in Win8 --- Wox/MainWindow.xaml | 2 +- Wox/MainWindow.xaml.cs | 23 +++++++++-------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Wox/MainWindow.xaml b/Wox/MainWindow.xaml index e1e9db800e..71ef2bfd54 100644 --- a/Wox/MainWindow.xaml +++ b/Wox/MainWindow.xaml @@ -22,7 +22,7 @@ - + \ No newline at end of file diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index d4633bacc7..0a0be77475 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -325,14 +325,12 @@ namespace Wox } }, TimeSpan.FromMilliseconds(ShouldNotDelayQuery ? 0 : 150)); } + private bool ShouldNotDelayQuery { get { - return (bool)Dispatcher.Invoke(new Func(() => - { - return IsCMDMode || IsWebSearchMode; - })); + return IsCMDMode || IsWebSearchMode; } } @@ -350,11 +348,10 @@ namespace Wox { Query q = new Query(tbQuery.Text); return !UserSettingStorage.Instance.EnableWebSearchSuggestion && - UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == q.ActionName && o.Enabled); + UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == q.ActionName && o.Enabled); } } - private void Border_OnMouseDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) DragMove(); @@ -521,7 +518,7 @@ namespace Wox toolTip.IsOpen = false; e.Handled = true; break; - + case Key.Back: if (BackKeyDownEvent != null) { @@ -533,7 +530,7 @@ namespace Wox } break; - case Key.Enter: + case Key.Enter: case Key.Tab: AcceptSelect(resultCtrl.GetActiveResult()); e.Handled = true; @@ -578,12 +575,10 @@ namespace Wox { waitShowResultList.AddRange(list); } - Dispatcher.DelayInvoke("ShowResult", k => resultCtrl.Dispatcher.Invoke(new Action(() => - { - List l = waitShowResultList.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList(); - waitShowResultList.Clear(); - resultCtrl.AddResults(l); - })), TimeSpan.FromMilliseconds(ShouldNotDelayQuery ? 0 : 50)); + List l = waitShowResultList.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList(); + waitShowResultList.Clear(); + + Dispatcher.Invoke(new Action(() => resultCtrl.AddResults(l))); } }