Browse Source

started dragging API

pull/1417/head
boombuler 9 years ago
parent
commit
411e3c8860
  1. 43
      src/Avalonia.Controls/DragDrop/DataObject.cs
  2. 10
      src/Avalonia.Controls/DragDrop/DragDrop.cs

43
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<string, object> _items = new Dictionary<string, object>();
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<string> GetDataFormats()
{
return _items.Keys;
}
public IEnumerable<string> GetFileNames()
{
return Get(DataFormats.FileNames) as IEnumerable<string>;
}
public string GetText()
{
return Get(DataFormats.Text) as string;
}
public void Set(string dataFormat, object value)
{
_items[dataFormat] = value;
}
}
}

10
src/Avalonia.Controls/DragDrop/DragDrop.cs

@ -20,5 +20,15 @@ namespace Avalonia.Controls.DragDrop
{
interactive.SetValue(AcceptDragProperty, value);
}
/// <summary>
/// Starts a dragging operation with the given <see cref="IDataObject"/> and returns the applied drop effect from the target.
/// <seealso cref="DataObject"/>
/// </summary>
public static DragDropEffects DoDragDrop(this Interactive source, IDataObject data, DragDropEffects allowedEffects)
{
return DragDropEffects.None;
}
}
}
Loading…
Cancel
Save