From 756d278bed7a89a6dc1bb6cc0a5a9f08d2e1e36a Mon Sep 17 00:00:00 2001 From: David Date: Tue, 22 Sep 2020 23:10:41 -0400 Subject: [PATCH] feat(dragdrop): Import the core drag and drop classes --- .../DragDrop/Core/CoreDragInfo.cs | 76 +++++++++++++++++++ .../DragDrop/Core/CoreDragUIOverride.cs | 16 ++++ ...reDropOperationTargetRequestedEventArgs.cs | 12 +++ .../DragDrop/Core/ICoreDropOperationTarget.cs | 14 ++++ .../CoreDragDropManager.cs | 2 +- .../CoreDragInfo.cs | 10 +-- .../CoreDragUIOverride.cs | 12 +-- ...reDropOperationTargetRequestedEventArgs.cs | 4 +- .../ICoreDropOperationTarget.cs | 10 +-- 9 files changed, 137 insertions(+), 19 deletions(-) create mode 100644 src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDragInfo.cs create mode 100644 src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDragUIOverride.cs create mode 100644 src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDropOperationTargetRequestedEventArgs.cs create mode 100644 src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/ICoreDropOperationTarget.cs diff --git a/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDragInfo.cs b/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDragInfo.cs new file mode 100644 index 000000000000..70e0836e3af6 --- /dev/null +++ b/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDragInfo.cs @@ -0,0 +1,76 @@ +#nullable enable + +using System; +using Windows.Foundation; +using Windows.System; +using Windows.UI.Core; +using Windows.UI.Input; + +namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core +{ + public partial class CoreDragInfo + { + private readonly CoreWindow _window; + private readonly Action _complete; + + internal CoreDragInfo( + CoreWindow window, + DataPackageView data, + DataPackageOperation allowedOperations, + Action complete) + { + _window = window; + _complete = complete; + Data = data; + AllowedOperations = allowedOperations; + } + + public DataPackageView Data { get; } + + public DataPackageOperation AllowedOperations { get; } + + public DragDropModifiers Modifiers + { + get + { + var mods = DragDropModifiers.None; + if (_window.LastPointerEvent is {} args) + { + var props = args.GetLocation(null).Properties; + if (props.IsLeftButtonPressed) + { + mods |= DragDropModifiers.LeftButton; + } + if (props.IsMiddleButtonPressed) + { + mods |= DragDropModifiers.MiddleButton; + } + if (props.IsRightButtonPressed) + { + mods |= DragDropModifiers.RightButton; + } + } + + if (_window.GetAsyncKeyState(VirtualKey.Shift) == CoreVirtualKeyStates.Down) + { + mods |= DragDropModifiers.Shift; + } + if (_window.GetAsyncKeyState(VirtualKey.Control) == CoreVirtualKeyStates.Down) + { + mods |= DragDropModifiers.Control; + } + if (_window.GetAsyncKeyState(VirtualKey.Menu) == CoreVirtualKeyStates.Down) + { + mods |= DragDropModifiers.Alt; + } + + return mods; + } + } + + public Point Position => _window.PointerPosition; + + internal void Complete(DataPackageOperation result) + => _complete(result); + } +} diff --git a/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDragUIOverride.cs b/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDragUIOverride.cs new file mode 100644 index 000000000000..a3ecd1107a67 --- /dev/null +++ b/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDragUIOverride.cs @@ -0,0 +1,16 @@ +#nullable enable + +namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core +{ + public partial class CoreDragUIOverride + { + public bool IsGlyphVisible { get; set; } + public bool IsContentVisible { get; set; } + public bool IsCaptionVisible { get; set; } + public string Caption { get; set; } = string.Empty; + + public void Clear() + { + } + } +} diff --git a/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDropOperationTargetRequestedEventArgs.cs b/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDropOperationTargetRequestedEventArgs.cs new file mode 100644 index 000000000000..5e7f4e20d0af --- /dev/null +++ b/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDropOperationTargetRequestedEventArgs.cs @@ -0,0 +1,12 @@ +#nullable enable + +namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core +{ + public partial class CoreDropOperationTargetRequestedEventArgs + { + internal ICoreDropOperationTarget? Target { get; private set; } + + public void SetTarget(ICoreDropOperationTarget target) + => Target = target; + } +} diff --git a/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/ICoreDropOperationTarget.cs b/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/ICoreDropOperationTarget.cs new file mode 100644 index 000000000000..94e9ed53333b --- /dev/null +++ b/src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/ICoreDropOperationTarget.cs @@ -0,0 +1,14 @@ +#nullable enable + +using Windows.Foundation; + +namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core +{ + public partial interface ICoreDropOperationTarget + { + IAsyncOperation EnterAsync(CoreDragInfo dragInfo, CoreDragUIOverride dragUIOverride); + IAsyncOperation OverAsync(CoreDragInfo dragInfo, CoreDragUIOverride dragUIOverride); + IAsyncAction LeaveAsync( CoreDragInfo dragInfo); + IAsyncOperation DropAsync(CoreDragInfo dragInfo); + } +} diff --git a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragDropManager.cs b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragDropManager.cs index 1f2622bf073c..a79a15aed2b1 100644 --- a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragDropManager.cs +++ b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragDropManager.cs @@ -7,7 +7,7 @@ namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core #endif public partial class CoreDragDropManager { - #if gfalse + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public bool AreConcurrentOperationsEnabled { diff --git a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragInfo.cs b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragInfo.cs index 9ac727c22fdf..33d6cde2ca26 100644 --- a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragInfo.cs +++ b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragInfo.cs @@ -2,12 +2,12 @@ #pragma warning disable 114 // new keyword hiding namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented] #endif public partial class CoreDragInfo { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public global::Windows.ApplicationModel.DataTransfer.DataPackageView Data { @@ -17,7 +17,7 @@ public partial class CoreDragInfo } } #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public global::Windows.ApplicationModel.DataTransfer.DragDrop.DragDropModifiers Modifiers { @@ -27,7 +27,7 @@ public partial class CoreDragInfo } } #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public global::Windows.Foundation.Point Position { @@ -37,7 +37,7 @@ public partial class CoreDragInfo } } #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public global::Windows.ApplicationModel.DataTransfer.DataPackageOperation AllowedOperations { diff --git a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragUIOverride.cs b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragUIOverride.cs index 37b079fb8519..a55f7675fe5c 100644 --- a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragUIOverride.cs +++ b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDragUIOverride.cs @@ -2,12 +2,12 @@ #pragma warning disable 114 // new keyword hiding namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented] #endif public partial class CoreDragUIOverride { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public bool IsGlyphVisible { @@ -21,7 +21,7 @@ public bool IsGlyphVisible } } #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public bool IsContentVisible { @@ -35,7 +35,7 @@ public bool IsContentVisible } } #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public bool IsCaptionVisible { @@ -49,7 +49,7 @@ public bool IsCaptionVisible } } #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public string Caption { @@ -85,7 +85,7 @@ public void SetContentFromSoftwareBitmap( global::Windows.Graphics.Imaging.Soft // Forced skipping of method Windows.ApplicationModel.DataTransfer.DragDrop.Core.CoreDragUIOverride.IsCaptionVisible.set // Forced skipping of method Windows.ApplicationModel.DataTransfer.DragDrop.Core.CoreDragUIOverride.IsGlyphVisible.get // Forced skipping of method Windows.ApplicationModel.DataTransfer.DragDrop.Core.CoreDragUIOverride.IsGlyphVisible.set - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public void Clear() { diff --git a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDropOperationTargetRequestedEventArgs.cs b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDropOperationTargetRequestedEventArgs.cs index c849c9501a9e..0b95a355958d 100644 --- a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDropOperationTargetRequestedEventArgs.cs +++ b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/CoreDropOperationTargetRequestedEventArgs.cs @@ -2,12 +2,12 @@ #pragma warning disable 114 // new keyword hiding namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented] #endif public partial class CoreDropOperationTargetRequestedEventArgs { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public void SetTarget( global::Windows.ApplicationModel.DataTransfer.DragDrop.Core.ICoreDropOperationTarget target) { diff --git a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/ICoreDropOperationTarget.cs b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/ICoreDropOperationTarget.cs index 48c516273057..5cd06de5ba8b 100644 --- a/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/ICoreDropOperationTarget.cs +++ b/src/Uno.UWP/Generated/3.0.0.0/Windows.ApplicationModel.DataTransfer.DragDrop.Core/ICoreDropOperationTarget.cs @@ -2,21 +2,21 @@ #pragma warning disable 114 // new keyword hiding namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented] #endif public partial interface ICoreDropOperationTarget { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false global::Windows.Foundation.IAsyncOperation EnterAsync( global::Windows.ApplicationModel.DataTransfer.DragDrop.Core.CoreDragInfo dragInfo, global::Windows.ApplicationModel.DataTransfer.DragDrop.Core.CoreDragUIOverride dragUIOverride); #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false global::Windows.Foundation.IAsyncOperation OverAsync( global::Windows.ApplicationModel.DataTransfer.DragDrop.Core.CoreDragInfo dragInfo, global::Windows.ApplicationModel.DataTransfer.DragDrop.Core.CoreDragUIOverride dragUIOverride); #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false global::Windows.Foundation.IAsyncAction LeaveAsync( global::Windows.ApplicationModel.DataTransfer.DragDrop.Core.CoreDragInfo dragInfo); #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false global::Windows.Foundation.IAsyncOperation DropAsync( global::Windows.ApplicationModel.DataTransfer.DragDrop.Core.CoreDragInfo dragInfo); #endif }