protected void OnDragOver(object sender, DragEventArgs e) { if (!_textArea.Focused) { _textArea.Focus(); } Point p = _textArea.PointToClient(new Point(e.X, e.Y)); if (_textArea.TextView.DrawingPosition.Contains(p.X, p.Y)) { TextLocation realmousepos = _textArea.TextView.GetLogicalPosition(p.X - _textArea.TextView.DrawingPosition.X, p.Y - _textArea.TextView.DrawingPosition.Y); int lineNr = Math.Min(_textArea.Document.TotalNumberOfLines - 1, Math.Max(0, realmousepos.Y)); _textArea.Caret.Position = new TextLocation(realmousepos.X, lineNr); _textArea.SetDesiredColumn(); if (e.Data.GetDataPresent(typeof(string)) && !_textArea.IsReadOnly(_textArea.Caret.Offset)) { e.Effect = GetDragDropEffect(e); } else { e.Effect = DragDropEffects.None; } } else { e.Effect = DragDropEffects.None; } }
void ShowHiddenCursorIfMovedOrLeft() { _textArea.ShowHiddenCursor(!_textArea.Focused || !_textArea.ClientRectangle.Contains(_textArea.PointToClient(Cursor.Position))); }