Skip to content

Instantly share code, notes, and snippets.

@cwensley
Created October 23, 2018 20:02
Show Gist options
  • Save cwensley/471a82882b05b6361176c614a3051abd to your computer and use it in GitHub Desktop.
Save cwensley/471a82882b05b6361176c614a3051abd to your computer and use it in GitHub Desktop.
Shows how to accept files with drag/drop in a Drawable
using System;
using Eto.Forms;
using Eto.Drawing;
using System.Linq;
using System.Diagnostics;
namespace TestDropFile
{
public partial class MainForm : Form
{
public MainForm()
{
Title = "My Eto Form";
ClientSize = new Size(400, 350);
var drawable = new Drawable { Size = new Size(300, 300) };
drawable.BackgroundColor = Colors.Blue;
drawable.AllowDrop = true;
drawable.DragEnter += Drawable_Drag;
drawable.DragDrop += Drawable_Drag;
Content = new StackLayout
{
Padding = 10,
Items =
{
drawable,
// add more controls here
}
};
}
private void Drawable_Drag(object sender, DragEventArgs e)
{
e.Effects = DragEffects.Link;
var files = e.Data.Uris.Select(r => r.AbsoluteUri).ToArray();
Debug.WriteLine(files);
foreach (var file in files)
Debug.WriteLine(file);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment