From 99b5e3565d0750be234459bf558a6ef8ca321026 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 23 Oct 2019 20:20:33 +1100 Subject: [PATCH] Add return to main query window from context menu after selection --- Wox/ViewModel/MainViewModel.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Wox/ViewModel/MainViewModel.cs b/Wox/ViewModel/MainViewModel.cs index 2a7781e1b2..4e2ee5818f 100644 --- a/Wox/ViewModel/MainViewModel.cs +++ b/Wox/ViewModel/MainViewModel.cs @@ -96,7 +96,7 @@ namespace Wox.ViewModel { EscCommand = new RelayCommand(_ => { - if (!ResultsSelected()) + if (!SelectedIsFromQueryResults()) { SelectedResults = Results; } @@ -153,17 +153,21 @@ namespace Wox.ViewModel MainWindowVisibility = Visibility.Collapsed; } - if (ResultsSelected()) + if (SelectedIsFromQueryResults()) { _userSelectedRecord.Add(result); _history.Add(result.OriginQuery.RawQuery); } + else + { + SelectedResults = Results; + } } }); LoadContextMenuCommand = new RelayCommand(_ => { - if (ResultsSelected()) + if (SelectedIsFromQueryResults()) { SelectedResults = ContextMenu; } @@ -175,7 +179,7 @@ namespace Wox.ViewModel LoadHistoryCommand = new RelayCommand(_ => { - if (ResultsSelected()) + if (SelectedIsFromQueryResults()) { SelectedResults = History; History.SelectedIndex = _history.Items.Count - 1; @@ -226,7 +230,7 @@ namespace Wox.ViewModel set { _selectedResults = value; - if (ResultsSelected()) + if (SelectedIsFromQueryResults()) { ContextMenu.Visbility = Visibility.Collapsed; History.Visbility = Visibility.Collapsed; @@ -273,7 +277,7 @@ namespace Wox.ViewModel public void Query() { - if (ResultsSelected()) + if (SelectedIsFromQueryResults()) { QueryResults(); } @@ -487,7 +491,7 @@ namespace Wox.ViewModel return menu; } - private bool ResultsSelected() + private bool SelectedIsFromQueryResults() { var selected = SelectedResults == Results; return selected;