protected void OnDragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(string))) { e.Effect = TextAreaDragDropHandler.GetDragDropEffect(e); } }
protected void OnDragOver(object sender, DragEventArgs e) { if (!this.textArea.Focused) { this.textArea.Focus(); } Point point = this.textArea.PointToClient(new Point(e.X, e.Y)); if (this.textArea.TextView.DrawingPosition.Contains(point.X, point.Y)) { Point logicalPosition = this.textArea.TextView.GetLogicalPosition(point.X - this.textArea.TextView.DrawingPosition.X, point.Y - this.textArea.TextView.DrawingPosition.Y); int y = Math.Min(this.textArea.Document.TotalNumberOfLines - 1, Math.Max(0, logicalPosition.Y)); this.textArea.Caret.Position = new Point(logicalPosition.X, y); this.textArea.SetDesiredColumn(); if (!this.textArea.EnableCutOrPaste) { e.Effect = DragDropEffects.None; return; } if (e.Data.GetDataPresent(typeof(string))) { e.Effect = TextAreaDragDropHandler.GetDragDropEffect(e); } } }
protected void OnDragDrop(object sender, DragEventArgs e) { this.textArea.PointToClient(new Point(e.X, e.Y)); if (!this.textArea.EnableCutOrPaste) { return; } if (e.Data.GetDataPresent(typeof(string))) { bool flag = false; this.textArea.BeginUpdate(); try { int num = this.textArea.Caret.Offset; if (e.Data.GetDataPresent(typeof(DefaultSelection))) { ISelection selection = (ISelection)e.Data.GetData(typeof(DefaultSelection)); if (selection.ContainsPosition(this.textArea.Caret.Position)) { return; } if (TextAreaDragDropHandler.GetDragDropEffect(e) == DragDropEffects.Move) { int length = selection.Length; this.textArea.Document.Remove(selection.Offset, length); if (selection.Offset < num) { num -= length; } } flag = true; } this.textArea.SelectionManager.ClearSelection(); this.InsertString(num, (string)e.Data.GetData(typeof(string))); if (flag) { this.textArea.Document.UndoStack.UndoLast(2); } this.textArea.Document.UpdateQueue.Clear(); this.textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea)); } finally { this.textArea.EndUpdate(); } } }