/// <summary> /// Handle drag and drop of text parts in the editor. /// </summary> /// <param name="s"></param> /// <param name="e"></param> private void HandleDragOver(object s, DragEventArgs e) { // convert cursor position to text position var point = PointToClient(new Point(e.X, e.Y)); int pos = CharPositionFromPoint(point.X, point.Y); // refresh text control Refresh(); // if the mouse is over a selected area, dropping will not be possible if (Selections.IndexOf(x => x.Start <= pos && pos < x.End) >= 0) { e.Effect = DragDropEffects.None; return; } // draw line at cursor position in text var g = CreateGraphics(); var pen = new Pen(Color.Black, 2); var height = TextRenderer.MeasureText("0", Font).Height; point.X = PointXFromPosition(pos); point.Y = PointYFromPosition(pos); g.DrawLine(pen, point.X, point.Y, point.X, point.Y + height); // show "MOVE" cursor e.Effect = DragDropEffects.Move; }