|
3 | 3 |
|
4 | 4 | using Files.Shared.Helpers; |
5 | 5 | using Microsoft.UI.Xaml.Controls; |
| 6 | +using Microsoft.UI.Xaml.Media; |
6 | 7 | using Microsoft.UI.Xaml.Media.Imaging; |
7 | 8 | using Windows.Storage; |
8 | | -using Windows.Storage.Search; |
9 | 9 | using Windows.System; |
10 | | -using Microsoft.UI.Xaml.Media; |
11 | 10 |
|
12 | 11 | namespace Files.App.Helpers |
13 | 12 | { |
@@ -587,85 +586,7 @@ private static async Task<FilesystemResult> OpenFile(string path, IShellPage ass |
587 | 586 | } |
588 | 587 | else |
589 | 588 | { |
590 | | - //try using launcher first |
591 | | - bool launchSuccess = false; |
592 | | - |
593 | | - BaseStorageFileQueryResult? fileQueryResult = null; |
594 | | - |
595 | | - //Get folder to create a file query (to pass to apps like Photos, Movies & TV..., needed to scroll through the folder like what Windows Explorer does) |
596 | | - BaseStorageFolder currentFolder = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(path)); |
597 | | - |
598 | | - if (currentFolder is not null) |
599 | | - { |
600 | | - QueryOptions queryOptions = new(CommonFileQuery.DefaultQuery, null); |
601 | | - |
602 | | - //We can have many sort entries |
603 | | - SortEntry sortEntry = new() |
604 | | - { |
605 | | - AscendingOrder = associatedInstance.InstanceViewModel.FolderSettings.DirectorySortDirection == SortDirection.Ascending |
606 | | - }; |
607 | | - |
608 | | - //Basically we tell to the launched app to follow how we sorted the files in the directory. |
609 | | - var sortOption = associatedInstance.InstanceViewModel.FolderSettings.DirectorySortOption; |
610 | | - |
611 | | - switch (sortOption) |
612 | | - { |
613 | | - case SortOption.Name: |
614 | | - sortEntry.PropertyName = "System.ItemNameDisplay"; |
615 | | - queryOptions.SortOrder.Clear(); |
616 | | - queryOptions.SortOrder.Add(sortEntry); |
617 | | - break; |
618 | | - |
619 | | - case SortOption.DateModified: |
620 | | - sortEntry.PropertyName = "System.DateModified"; |
621 | | - queryOptions.SortOrder.Clear(); |
622 | | - queryOptions.SortOrder.Add(sortEntry); |
623 | | - break; |
624 | | - |
625 | | - case SortOption.DateCreated: |
626 | | - sortEntry.PropertyName = "System.DateCreated"; |
627 | | - queryOptions.SortOrder.Clear(); |
628 | | - queryOptions.SortOrder.Add(sortEntry); |
629 | | - break; |
630 | | - |
631 | | - //Unfortunately this is unsupported | Remarks: https://learn.microsoft.com/uwp/api/windows.storage.search.queryoptions.sortorder?view=winrt-19041 |
632 | | - //case Enums.SortOption.Size: |
633 | | - |
634 | | - //sortEntry.PropertyName = "System.TotalFileSize"; |
635 | | - //queryOptions.SortOrder.Clear(); |
636 | | - //queryOptions.SortOrder.Add(sortEntry); |
637 | | - //break; |
638 | | - |
639 | | - //Unfortunately this is unsupported | Remarks: https://learn.microsoft.com/uwp/api/windows.storage.search.queryoptions.sortorder?view=winrt-19041 |
640 | | - //case Enums.SortOption.FileType: |
641 | | - |
642 | | - //sortEntry.PropertyName = "System.FileExtension"; |
643 | | - //queryOptions.SortOrder.Clear(); |
644 | | - //queryOptions.SortOrder.Add(sortEntry); |
645 | | - //break; |
646 | | - |
647 | | - //Handle unsupported |
648 | | - default: |
649 | | - //keep the default one in SortOrder IList |
650 | | - break; |
651 | | - } |
652 | | - |
653 | | - var options = InitializeWithWindow(new LauncherOptions()); |
654 | | - if (currentFolder.AreQueryOptionsSupported(queryOptions)) |
655 | | - { |
656 | | - fileQueryResult = currentFolder.CreateFileQueryWithOptions(queryOptions); |
657 | | - options.NeighboringFilesQuery = fileQueryResult.ToStorageFileQueryResult(); |
658 | | - } |
659 | | - |
660 | | - // Now launch file with options. |
661 | | - var storageItem = (StorageFile)await FilesystemTasks.Wrap(() => childFile.Item.ToStorageFileAsync().AsTask()); |
662 | | - |
663 | | - if (storageItem is not null) |
664 | | - launchSuccess = await Launcher.LaunchFileAsync(storageItem, options); |
665 | | - } |
666 | | - |
667 | | - if (!launchSuccess) |
668 | | - await Win32Helper.InvokeWin32ComponentAsync(path, associatedInstance, args); |
| 589 | + await Win32Helper.InvokeWin32ComponentAsync(path, associatedInstance, args); |
669 | 590 | } |
670 | 591 | }); |
671 | 592 | } |
|
0 commit comments