private void TextChanged(object sender, TextChangedEventArgs args) { if (!tb.IsEnabled) { return; } var query = tb.Text; var context = new WindowFilterContext <AppWindowViewModel> { Windows = _unfilteredWindowList, ForegroundWindowProcessTitle = new AppWindow(_foregroundWindow.HWnd).ProcessTitle }; var filterResults = new WindowFilterer().Filter(context, query).ToList(); foreach (var filterResult in filterResults) { filterResult.AppWindow.FormattedTitle = GetFormattedTitleFromBestResult(filterResult.WindowTitleMatchResults); filterResult.AppWindow.FormattedProcessTitle = GetFormattedTitleFromBestResult(filterResult.ProcessTitleMatchResults); } _filteredWindowList = new ObservableCollection <AppWindowViewModel>(filterResults.Select(r => r.AppWindow)); AddPrefixNumbersToFormattedTitle(_filteredWindowList); lb.DataContext = _filteredWindowList; if (lb.Items.Count > 0) { lb.SelectedItem = lb.Items[0]; } }
public List <Result> Query(Query query) { var queryString = query.Search; var windowContext = new WindowFilterContext <AppWindowViewModel> { Windows = new WindowFinder().GetWindows().Select(w => new AppWindowViewModel(w)), ForegroundWindowProcessTitle = new AppWindow(SystemWindow.ForegroundWindow.HWnd).ProcessTitle }; var filterResults = new WindowFilterer().Filter(windowContext, queryString).Select(o => o.AppWindow.AppWindow) .Where(window => window.ProcessTitle != "Wox") .ToList(); return(filterResults.Select(o => { return new Result { Title = _settings.SwapTitleAndSubtitle? o.ProcessTitle : GetNormalTitleOrAppFirst(o.Title), SubTitle = _settings.SwapTitleAndSubtitle ? GetNormalTitleOrAppFirst(o.Title) : o.ProcessTitle, IcoPath = o.ExecutablePath, ContextData = o, Action = con => { o.SwitchTo(); Context.API.HideApp(); return true; } }; }).ToList()); }
private void TextChanged(object sender, TextChangedEventArgs args) { var text = tb.Text; var filterResults = new WindowFilterer().Filter(_unfilteredWindowList, text).ToList(); foreach (var filterResult in filterResults) { filterResult.AppWindow.FormattedTitle = GetFormattedTitleFromBestResult(filterResult.WindowTitleMatchResults); filterResult.AppWindow.FormattedProcessTitle = GetFormattedTitleFromBestResult(filterResult.ProcessTitleMatchResults); } _filteredWindowList = new ObservableCollection <AppWindowViewModel>(filterResults.Select(r => r.AppWindow)); lb.DataContext = _filteredWindowList; if (lb.Items.Count > 0) { lb.SelectedItem = lb.Items[0]; } }