protected void OnDragDrop(object sender, DragEventArgs e)
{
Point p = _textArea.PointToClient(new Point(e.X, e.Y));
if (e.Data.GetDataPresent(typeof(string)))
{
_textArea.BeginUpdate();
_textArea.Document.UndoStack.StartUndoGroup();
try
{
int offset = _textArea.Caret.Offset;
if (_textArea.IsReadOnly(offset))
{
// prevent dragging text into readonly section
return;
}
//TODO2 drag/drop - all this:
//if (e.Data.GetDataPresent(typeof(Selection)))
//{
// Selection sel = (Selection)e.Data.GetData(typeof(Selection));
// if (sel.ContainsPosition(textArea.Caret.Position))
// {
// return;
// }
// if (GetDragDropEffect(e) == DragDropEffects.Move)
// {
// if (SelectionManager.SelectionIsReadOnly(textArea.Document, sel))
// {
// // prevent dragging text out of readonly section
// return;
// }
// int len = sel.Length;
// textArea.Document.Remove(sel.StartOffset, len);
// if (sel.StartOffset < offset)
// {
// offset -= len;
// }
// }
//}
_textArea.SelectionManager.ClearSelection();
InsertString(offset, (string)e.Data.GetData(typeof(string)));
_textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
}
finally
{
_textArea.Document.UndoStack.EndUndoGroup();
_textArea.EndUpdate();
}
}
}