Add return to main query window from context menu after selection

This commit is contained in:
Jeremy Wu 2019-10-23 20:20:33 +11:00
parent 0db8898577
commit 99b5e3565d

View File

@ -96,7 +96,7 @@ namespace Wox.ViewModel
{ {
EscCommand = new RelayCommand(_ => EscCommand = new RelayCommand(_ =>
{ {
if (!ResultsSelected()) if (!SelectedIsFromQueryResults())
{ {
SelectedResults = Results; SelectedResults = Results;
} }
@ -153,17 +153,21 @@ namespace Wox.ViewModel
MainWindowVisibility = Visibility.Collapsed; MainWindowVisibility = Visibility.Collapsed;
} }
if (ResultsSelected()) if (SelectedIsFromQueryResults())
{ {
_userSelectedRecord.Add(result); _userSelectedRecord.Add(result);
_history.Add(result.OriginQuery.RawQuery); _history.Add(result.OriginQuery.RawQuery);
} }
else
{
SelectedResults = Results;
}
} }
}); });
LoadContextMenuCommand = new RelayCommand(_ => LoadContextMenuCommand = new RelayCommand(_ =>
{ {
if (ResultsSelected()) if (SelectedIsFromQueryResults())
{ {
SelectedResults = ContextMenu; SelectedResults = ContextMenu;
} }
@ -175,7 +179,7 @@ namespace Wox.ViewModel
LoadHistoryCommand = new RelayCommand(_ => LoadHistoryCommand = new RelayCommand(_ =>
{ {
if (ResultsSelected()) if (SelectedIsFromQueryResults())
{ {
SelectedResults = History; SelectedResults = History;
History.SelectedIndex = _history.Items.Count - 1; History.SelectedIndex = _history.Items.Count - 1;
@ -226,7 +230,7 @@ namespace Wox.ViewModel
set set
{ {
_selectedResults = value; _selectedResults = value;
if (ResultsSelected()) if (SelectedIsFromQueryResults())
{ {
ContextMenu.Visbility = Visibility.Collapsed; ContextMenu.Visbility = Visibility.Collapsed;
History.Visbility = Visibility.Collapsed; History.Visbility = Visibility.Collapsed;
@ -273,7 +277,7 @@ namespace Wox.ViewModel
public void Query() public void Query()
{ {
if (ResultsSelected()) if (SelectedIsFromQueryResults())
{ {
QueryResults(); QueryResults();
} }
@ -487,7 +491,7 @@ namespace Wox.ViewModel
return menu; return menu;
} }
private bool ResultsSelected() private bool SelectedIsFromQueryResults()
{ {
var selected = SelectedResults == Results; var selected = SelectedResults == Results;
return selected; return selected;