From 411e3c8860b1756ce8b01943a1091d5481493b02 Mon Sep 17 00:00:00 2001 From: boombuler Date: Wed, 7 Mar 2018 07:46:28 +0100 Subject: [PATCH] started dragging API --- src/Avalonia.Controls/DragDrop/DataObject.cs | 43 ++++++++++++++++++++ src/Avalonia.Controls/DragDrop/DragDrop.cs | 10 +++++ 2 files changed, 53 insertions(+) create mode 100644 src/Avalonia.Controls/DragDrop/DataObject.cs diff --git a/src/Avalonia.Controls/DragDrop/DataObject.cs b/src/Avalonia.Controls/DragDrop/DataObject.cs new file mode 100644 index 0000000000..e0e7b6d069 --- /dev/null +++ b/src/Avalonia.Controls/DragDrop/DataObject.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Avalonia.Controls.DragDrop +{ + public class DataObject : IDataObject + { + private readonly Dictionary _items = new Dictionary(); + + public bool Contains(string dataFormat) + { + return _items.ContainsKey(dataFormat); + } + + public object Get(string dataFormat) + { + if (_items.ContainsKey(dataFormat)) + return _items[dataFormat]; + return null; + } + + public IEnumerable GetDataFormats() + { + return _items.Keys; + } + + public IEnumerable GetFileNames() + { + return Get(DataFormats.FileNames) as IEnumerable; + } + + public string GetText() + { + return Get(DataFormats.Text) as string; + } + + public void Set(string dataFormat, object value) + { + _items[dataFormat] = value; + } + } +} diff --git a/src/Avalonia.Controls/DragDrop/DragDrop.cs b/src/Avalonia.Controls/DragDrop/DragDrop.cs index 317a903d3c..af003516b1 100644 --- a/src/Avalonia.Controls/DragDrop/DragDrop.cs +++ b/src/Avalonia.Controls/DragDrop/DragDrop.cs @@ -20,5 +20,15 @@ namespace Avalonia.Controls.DragDrop { interactive.SetValue(AcceptDragProperty, value); } + + /// + /// Starts a dragging operation with the given and returns the applied drop effect from the target. + /// + /// + public static DragDropEffects DoDragDrop(this Interactive source, IDataObject data, DragDropEffects allowedEffects) + { + + return DragDropEffects.None; + } } } \ No newline at end of file