mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 18:29:24 +08:00
Updated program execution to call action on background thread. (#2370)
This commit is contained in:
parent
368640b59b
commit
a6e8cbc50d
@ -114,8 +114,8 @@ namespace Wox.ViewModel
|
||||
SelectPrevItemCommand = new RelayCommand(_ =>
|
||||
{
|
||||
SelectedResults.SelectPrevResult();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
SelectNextTabItemCommand = new RelayCommand(_ =>
|
||||
{
|
||||
SelectedResults.SelectNextTabItem();
|
||||
@ -152,37 +152,37 @@ namespace Wox.ViewModel
|
||||
results.SelectedIndex = int.Parse(index.ToString());
|
||||
}
|
||||
|
||||
if(results.SelectedItem != null)
|
||||
{
|
||||
//If there is a context button selected fire the action for that button before the main command.
|
||||
bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton();
|
||||
|
||||
if (!didExecuteContextButton)
|
||||
{
|
||||
var result = results.SelectedItem.Result;
|
||||
if (result != null) // SelectedItem returns null if selection is empty.
|
||||
{
|
||||
bool hideWindow = result.Action != null && result.Action(new ActionContext
|
||||
{
|
||||
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
|
||||
});
|
||||
|
||||
if (hideWindow)
|
||||
{
|
||||
MainWindowVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
if (SelectedIsFromQueryResults())
|
||||
{
|
||||
_userSelectedRecord.Add(result);
|
||||
_history.Add(result.OriginQuery.RawQuery);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedResults = Results;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(results.SelectedItem != null)
|
||||
{
|
||||
//If there is a context button selected fire the action for that button before the main command.
|
||||
bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton();
|
||||
|
||||
if (!didExecuteContextButton)
|
||||
{
|
||||
var result = results.SelectedItem.Result;
|
||||
if (result != null && result.Action != null) // SelectedItem returns null if selection is empty.
|
||||
{
|
||||
MainWindowVisibility = Visibility.Collapsed;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
result.Action(new ActionContext
|
||||
{
|
||||
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
|
||||
});
|
||||
});
|
||||
|
||||
if (SelectedIsFromQueryResults())
|
||||
{
|
||||
_userSelectedRecord.Add(result);
|
||||
_history.Add(result.OriginQuery.RawQuery);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedResults = Results;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -289,8 +289,8 @@ namespace Wox.ViewModel
|
||||
|
||||
public ICommand EscCommand { get; set; }
|
||||
public ICommand SelectNextItemCommand { get; set; }
|
||||
public ICommand SelectPrevItemCommand { get; set; }
|
||||
|
||||
public ICommand SelectPrevItemCommand { get; set; }
|
||||
|
||||
public ICommand SelectNextTabItemCommand { get; set; }
|
||||
public ICommand SelectPrevTabItemCommand { get; set; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user