Skip to content

Commit

Permalink
test(dragdrop): Update test
Browse files Browse the repository at this point in the history
- make uri higher priority than text
- avoid not supported API of StorageFile
- accept only one operation at a time at it should reflect the result operation (and drives the UI)
  • Loading branch information
dr1rrb committed Oct 16, 2020
1 parent 6f18a77 commit 84f3d13
Showing 1 changed file with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.ObjectModel;
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.UI;
Expand Down Expand Up @@ -225,20 +226,13 @@ private async void ShowDropDetails(global::Windows.UI.Xaml.DragEventArgs args)
{
details += "Name: " + file.Name + Environment.NewLine;
details += "DisplayName: " + file.DisplayName + Environment.NewLine;
details += "DisplayType: " + file.DisplayType + Environment.NewLine;
//details += "DisplayType: " + file.DisplayType + Environment.NewLine;
details += "ContentType: " + file.ContentType + Environment.NewLine;
details += "Path: " + file.Path;
}
}
}
}
else if (args.DataView.Contains(StandardDataFormats.Text))
{
title += " (Text)";

var text = await args.DataView.GetTextAsync();
details = text;
}
else if (args.DataView.Contains(StandardDataFormats.UserActivityJsonArray))
{
title += " (UserActivityJsonArray)";
Expand All @@ -259,6 +253,13 @@ private async void ShowDropDetails(global::Windows.UI.Xaml.DragEventArgs args)
var webLink = await args.DataView.GetWebLinkAsync();
details = webLink.ToString();
}
else if (args.DataView.Contains(StandardDataFormats.Text))
{
title += " (Text)";

var text = await args.DataView.GetTextAsync();
details = text;
}

// Determine the drop position
var pos = args.GetPosition(this.DropBorder);
Expand All @@ -276,15 +277,8 @@ private async void ShowDropDetails(global::Windows.UI.Xaml.DragEventArgs args)
/// </summary>
private void DropBorder_DragEnter(object sender, global::Windows.UI.Xaml.DragEventArgs e)
{
// Accept everything possible
if (e.DataView.RequestedOperation != DataPackageOperation.None)
{
e.AcceptedOperation = e.DataView.RequestedOperation;
}
else
{
e.AcceptedOperation = DataPackageOperation.Copy | DataPackageOperation.Link | DataPackageOperation.Move;
}
// We accept only one operation
e.AcceptedOperation = DataPackageOperation.Copy;

this.ShowDragDropDetails(nameof(global::Windows.UI.Xaml.UIElement.DragEnter), e);
return;
Expand Down

0 comments on commit 84f3d13

Please sign in to comment.