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)) { return; } if (e.Data.GetDataPresent(typeof(DefaultSelection))) { ISelection sel = (ISelection)e.Data.GetData(typeof(DefaultSelection)); if (sel.ContainsPosition(textArea.Caret.Position)) { return; } if (GetDragDropEffect(e) == DragDropEffects.Move) { if (SelectionManager.SelectionIsReadOnly(textArea.Document, sel)) { return; } int len = sel.Length; textArea.Document.Remove(sel.Offset, len); if (sel.Offset < 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(); } } }
void ShowHiddenCursorIfMovedOrLeft() { textArea.ShowHiddenCursor(!textArea.Focused || !textArea.ClientRectangle.Contains(textArea.PointToClient(Cursor.Position))); }