public override bool PerformDragOperation (NSDraggingInfo sender)
{
// Attempt to read filenames from pasteboard
var plist = (NSArray) sender.DraggingPasteboard.GetPropertyListForType (NSPasteboard.NSFilenamesType);
// Was a list of files returned from Finder?
if (plist != null) {
// Yes, process list
for (nuint n = 0; n < plist.Count; ++n) {
// Get the current file
var path = plist.GetItem<NSString> (n);
var url = NSUrl.FromString (path);
var contents = File.ReadAllText (path);
// Insert contents at cursor
NSRange range = SelectedRange;
TextStorage.BeginEditing ();
Replace (range, contents);
TextStorage.EndEditing ();
// Expand range to fully encompass new content and
// reformat
range = new NSRange (range.Location, contents.Length);
range = Formatter.FindLineBoundries (TextStorage.Value, range);
Formatter.HighlightSyntaxRegion (TextStorage.Value, range);
}
// Inform caller of success
return true;
} else {
// No, allow base class to handle
return base.PerformDragOperation (sender);
}
}