public Task <DragDropEffects> DoDragDrop(PointerEventArgs triggerEvent, IDataObject data, DragDropEffects allowedEffects)
        {
            // Sanity check
            var tl   = FindRoot(triggerEvent.Source);
            var view = tl?.PlatformImpl as WindowBaseImpl;

            if (view == null)
            {
                throw new ArgumentException();
            }

            triggerEvent.Pointer.Capture(null);

            var tcs = new TaskCompletionSource <DragDropEffects>();

            var clipboardImpl = _factory.CreateDndClipboard();

            using (var clipboard = new ClipboardImpl(clipboardImpl))
                using (var cb = new DndCallback(tcs))
                {
                    if (data.Contains(DataFormats.Text))
                    {
                        // API is synchronous, so it's OK
                        clipboard.SetTextAsync(data.GetText()).Wait();
                    }

                    view.BeginDraggingSession((AvnDragDropEffects)allowedEffects,
                                              triggerEvent.GetPosition(tl).ToAvnPoint(), clipboardImpl, cb,
                                              GCHandle.ToIntPtr(GCHandle.Alloc(data)));
                }

            return(tcs.Task);
        }
Esempio n. 2
0
 public void Dispose()
 {
     _clipboard?.Dispose();
     _clipboard = null;
 }
Esempio n. 3
0
 public ClipboardDataObject(IAvnClipboard clipboard)
 {
     _clipboard = new ClipboardImpl(clipboard);
 }