diff --git a/src/Files.App/Constants.cs b/src/Files.App/Constants.cs index d5ecefa28323..cd124ecbfc98 100644 --- a/src/Files.App/Constants.cs +++ b/src/Files.App/Constants.cs @@ -56,6 +56,7 @@ public static class ImageRes public const int Libraries = 1023; public const int Folder = 3; public const int ShieldIcon = 78; + public const int SearchIcon = 177; } public static class Shell32 diff --git a/src/Files.App/Helpers/UI/UIHelpers.cs b/src/Files.App/Helpers/UI/UIHelpers.cs index cfc1bd5327d5..5307297fc968 100644 --- a/src/Files.App/Helpers/UI/UIHelpers.cs +++ b/src/Files.App/Helpers/UI/UIHelpers.cs @@ -106,6 +106,8 @@ public static void CloseAllDialogs() private static IconFileInfo ShieldIconResource = LoadShieldIconResource(); + private static IconFileInfo SearchIconResource = LoadSearchIconResource(); + public static IconFileInfo GetSidebarIconResourceInfo(int index) { var icons = UIHelpers.SidebarIconResources; @@ -128,6 +130,13 @@ public static IconFileInfo GetSidebarIconResourceInfo(int index) : null; } + public static async Task GetSearchIconResource() + { + return SearchIconResource is not null + ? await SearchIconResource.IconData.ToBitmapAsync() + : null; + } + private static IEnumerable LoadSidebarIconResources() { string imageres = Path.Combine(Constants.UserEnvironmentPaths.SystemRootPath, "System32", "imageres.dll"); @@ -153,5 +162,15 @@ private static IconFileInfo LoadShieldIconResource() return imageResList.FirstOrDefault(); } + + private static IconFileInfo LoadSearchIconResource() + { + string imageres = Path.Combine(Constants.UserEnvironmentPaths.SystemRootPath, "System32", "imageres.dll"); + var imageResList = Win32Helper.ExtractSelectedIconsFromDLL(imageres, new List() { + Constants.ImageRes.SearchIcon + }, 48); + + return imageResList.FirstOrDefault(); + } } } diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index d3bf746a0d3e..dc6dc947fbbf 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -1010,6 +1010,9 @@ Search results in {1} for {0} + + Search results for `{0}` + Details diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index c96b09ddabd9..bab020065ce7 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -121,6 +121,14 @@ public ImageSource? FolderThumbnailImageSource private set => SetProperty(ref _FolderThumbnailImageSource, value); } + private BitmapImage? _SearchIconBitmapImage; + public BitmapImage? SearchIconBitmapImage + { + get => _SearchIconBitmapImage; + private set => SetProperty(ref _SearchIconBitmapImage, value); + } + + public bool ShowFilterHeader => UserSettingsService.GeneralSettingsService.ShowFilterHeader && WorkingDirectory != "Home" && @@ -739,7 +747,26 @@ public void CancelExtendedPropertiesLoadingForItem(ListedItem item) itemLoadQueue.TryUpdate(item.ItemPath, true, false); } - private bool IsSearchResults { get; set; } + private bool _isSearchResults; + public bool IsSearchResults + { + get => _isSearchResults; + set + { + if (SetProperty(ref _isSearchResults, value)) + { + if (!value) + SearchHeaderTitle = string.Empty; + } + } + } + + private string? _searchHeaderTitle; + public string? SearchHeaderTitle + { + get => _searchHeaderTitle; + set => SetProperty(ref _searchHeaderTitle, value); + } public void UpdateEmptyTextType() { @@ -2692,6 +2719,13 @@ public async Task SearchAsync(FolderSearch search) await ApplyFilesAndFoldersChangesAsync(); EmptyTextType = EmptyTextType.None; + SearchHeaderTitle = !string.IsNullOrEmpty(search.Query) + ? string.Format(Strings.SearchResultsFor.GetLocalizedResource(), search.Query) + : string.Empty; + + if (SearchIconBitmapImage is null) + SearchIconBitmapImage ??= await UIHelpers.GetSearchIconResource(); + ItemLoadStatusChanged?.Invoke(this, new ItemLoadStatusChangedEventArgs() { Status = ItemLoadStatusChangedEventArgs.ItemLoadStatus.InProgress }); var results = new List(); diff --git a/src/Files.App/Views/Shells/ModernShellPage.xaml b/src/Files.App/Views/Shells/ModernShellPage.xaml index 186f94c75e5d..cfd2f0c1564c 100644 --- a/src/Files.App/Views/Shells/ModernShellPage.xaml +++ b/src/Files.App/Views/Shells/ModernShellPage.xaml @@ -43,6 +43,7 @@ + @@ -58,7 +59,7 @@ + + + + + + + +