|
26 | 26 | using System.Collections.Generic;
|
27 | 27 | using System.ComponentModel;
|
28 | 28 | using System.Diagnostics;
|
| 29 | +using System.IO; |
29 | 30 | using System.Linq;
|
30 | 31 | using System.Runtime.CompilerServices;
|
| 32 | +using System.Runtime.InteropServices.ComTypes; |
31 | 33 | using System.Threading;
|
32 | 34 | using System.Threading.Tasks;
|
| 35 | +using Vanara.PInvoke; |
33 | 36 | using Windows.ApplicationModel.DataTransfer;
|
34 | 37 | using Windows.ApplicationModel.DataTransfer.DragDrop;
|
35 | 38 | using Windows.Foundation;
|
36 | 39 | using Windows.Foundation.Collections;
|
37 | 40 | using Windows.Storage;
|
38 | 41 | using Windows.System;
|
39 | 42 | using static Files.App.Helpers.PathNormalization;
|
| 43 | +using VA = Vanara.Windows.Shell; |
40 | 44 | using DispatcherQueueTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;
|
41 | 45 | using SortDirection = Files.Shared.Enums.SortDirection;
|
42 | 46 |
|
@@ -875,11 +879,27 @@ protected virtual void Page_CharacterReceived(UIElement sender, CharacterReceive
|
875 | 879 | protected void FileList_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
|
876 | 880 | {
|
877 | 881 | SelectedItems!.AddRange(e.Items.OfType<ListedItem>());
|
| 882 | + |
878 | 883 | try
|
879 | 884 | {
|
880 |
| - // Only support IStorageItem capable paths |
881 |
| - var itemList = e.Items.OfType<ListedItem>().Where(x => !(x.IsHiddenItem && x.IsLinkItem && x.IsRecycleBinItem && x.IsShortcut)).Select(x => VirtualStorageItem.FromListedItem(x)); |
882 |
| - e.Data.SetStorageItems(itemList, false); |
| 885 | + var shellItemList = e.Items.OfType<ListedItem>().Select(x => new VA.ShellItem(x.ItemPath)).ToArray(); |
| 886 | + if (shellItemList[0].FileSystemPath is not null) |
| 887 | + { |
| 888 | + var iddo = shellItemList[0].Parent.GetChildrenUIObjects<IDataObject>(HWND.NULL, shellItemList); |
| 889 | + shellItemList.ForEach(x => x.Dispose()); |
| 890 | + var format = System.Windows.Forms.DataFormats.GetFormat("Shell IDList Array"); |
| 891 | + if (iddo.TryGetData<byte[]>((uint)format.Id, out var data)) |
| 892 | + { |
| 893 | + var mem = new MemoryStream(data).AsRandomAccessStream(); |
| 894 | + e.Data.SetData(format.Name, mem); |
| 895 | + } |
| 896 | + } |
| 897 | + else |
| 898 | + { |
| 899 | + // Only support IStorageItem capable paths |
| 900 | + var storageItemList = e.Items.OfType<ListedItem>().Where(x => !(x.IsHiddenItem && x.IsLinkItem && x.IsRecycleBinItem && x.IsShortcut)).Select(x => VirtualStorageItem.FromListedItem(x)); |
| 901 | + e.Data.SetStorageItems(storageItemList, false); |
| 902 | + } |
883 | 903 | }
|
884 | 904 | catch (Exception)
|
885 | 905 | {
|
|
0 commit comments