Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed issues with drag & drop from Files to other apps #10949

Merged
merged 7 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.ComTypes;
using System.Threading;
using System.Threading.Tasks;
using Vanara.PInvoke;
using Windows.ApplicationModel.DataTransfer;
using Windows.ApplicationModel.DataTransfer.DragDrop;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.System;
using static Files.App.Helpers.PathNormalization;
using VA = Vanara.Windows.Shell;
using DispatcherQueueTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;

namespace Files.App
Expand Down Expand Up @@ -751,11 +755,23 @@ protected virtual void Page_CharacterReceived(UIElement sender, CharacterReceive
protected void FileList_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
{
SelectedItems!.AddRange(e.Items.OfType<ListedItem>());

try
{
// Only support IStorageItem capable paths
var itemList = e.Items.OfType<ListedItem>().Where(x => !(x.IsHiddenItem && x.IsLinkItem && x.IsRecycleBinItem && x.IsShortcut)).Select(x => VirtualStorageItem.FromListedItem(x));
e.Data.SetStorageItems(itemList, false);
var itemList = e.Items.OfType<ListedItem>().Select(x => new VA.ShellItem(x.ItemPath)).ToArray();
var iddo = itemList[0].Parent.GetChildrenUIObjects<IDataObject>(HWND.NULL, itemList);
itemList.ForEach(x => x.Dispose());
var wfdo = new System.Windows.Forms.DataObject(iddo);
var formats = wfdo.GetFormats(false);
foreach (var format in formats)
{
var clipFrmtId = (uint)System.Windows.Forms.DataFormats.GetFormat(format).Id;
if (iddo.TryGetData<byte[]>(clipFrmtId, out var data))
{
var mem = new MemoryStream(data).AsRandomAccessStream();
e.Data.SetData(format, mem);
}
}
}
catch (Exception)
{
Expand Down
140 changes: 0 additions & 140 deletions src/Files.App/Filesystem/StorageItems/VirtualStorageItem.cs

This file was deleted.