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); }
public void Dispose() { _clipboard?.Dispose(); _clipboard = null; }
public ClipboardDataObject(IAvnClipboard clipboard) { _clipboard = new ClipboardImpl(clipboard); }