[PT Run] WindowWalker: Refactor code, fix some bugs, hide UWP non-windows, prepare code for new features (#15441)

* Import files from old PR #15329

* Improvements

* hide uwp non-windows (#13637)

* update debug tool tip

* fix spelling and comments

* disable tool tip

* fix doc links

* remove obsolete using

* Update docs

* fix spelling

* rename elevation property and test method

* Add property <DoesExist> to WindowProcess class

* Close process handles correctly if not used anymore

* cleanup coed

* fix bug with sticky notes process

* add window class to tool tip

* small change

* make nativeMethods static class

* fix broken uwpApp property of WindowProcess class

* rename method

* Revert making NativeMethods class static. It contains instance members.

* improve loggign

* fix merge mistakes

* fixes

* remove obsolete delegate

* Improve SearchController to speed up search (#15561)

* add <IsShellProcess> property to <WindowProcess> class

* reorder code

* disable debug tool tip

* Update devdocs

* remove obsolete event handler

* update var name
This commit is contained in:
Heiko
2022-01-25 10:33:40 +01:00
committed by GitHub
parent 5eaf60e8a2
commit edc43e39ca
8 changed files with 429 additions and 156 deletions

View File

@@ -7,7 +7,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.Plugin.WindowWalker.Components
{
@@ -24,7 +23,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
/// <summary>
/// Open window search results
/// </summary
/// </summary>
private List<SearchResult> searchMatches;
/// <summary>
@@ -32,16 +31,6 @@ namespace Microsoft.Plugin.WindowWalker.Components
/// </summary>
private static SearchController instance;
/// <summary>
/// Delegate handler for open windows updates
/// </summary>
public delegate void SearchResultUpdateEventHandler(object sender, SearchResultUpdateEventArgs e);
/// <summary>
/// Event raised when there is an update to the list of open windows
/// </summary>
public event SearchResultUpdateEventHandler OnSearchResultUpdateEventHandler;
/// <summary>
/// Gets or sets the current search text
/// </summary>
@@ -95,16 +84,16 @@ namespace Microsoft.Plugin.WindowWalker.Components
/// <summary>
/// Event handler for when the search text has been updated
/// </summary>
public async Task UpdateSearchText(string searchText)
public void UpdateSearchText(string searchText)
{
SearchText = searchText;
await SyncOpenWindowsWithModelAsync().ConfigureAwait(false);
SyncOpenWindowsWithModel();
}
/// <summary>
/// Syncs the open windows with the OpenWindows Model
/// </summary>
public async Task SyncOpenWindowsWithModelAsync()
public void SyncOpenWindowsWithModel()
{
System.Diagnostics.Debug.Print("Syncing WindowSearch result with OpenWindows Model");
@@ -116,22 +105,8 @@ namespace Microsoft.Plugin.WindowWalker.Components
}
else
{
searchMatches = await FuzzySearchOpenWindowsAsync(snapshotOfOpenWindows).ConfigureAwait(false);
searchMatches = FuzzySearchOpenWindows(snapshotOfOpenWindows);
}
OnSearchResultUpdateEventHandler?.Invoke(this, new SearchResultUpdateEventArgs());
}
/// <summary>
/// Redirecting method for Fuzzy searching
/// </summary>
/// <param name="openWindows">what windows are open</param>
/// <returns>Returns search results</returns>
private Task<List<SearchResult>> FuzzySearchOpenWindowsAsync(List<Window> openWindows)
{
return Task.Run(
() =>
FuzzySearchOpenWindows(openWindows));
}
/// <summary>
@@ -151,7 +126,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
foreach (var window in openWindows)
{
var titleMatch = FuzzyMatching.FindBestFuzzyMatch(window.Title, searchString.SearchText);
var processMatch = FuzzyMatching.FindBestFuzzyMatch(window.ProcessName, searchString.SearchText);
var processMatch = FuzzyMatching.FindBestFuzzyMatch(window.ProcessInfo.Name, searchString.SearchText);
if ((titleMatch.Count != 0 || processMatch.Count != 0) &&
window.Title.Length != 0)