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;
            }
        }
Exemplo n.º 2
0
 public void JumpTo(int line, int column)
 {
     textArea.Focus();
     textArea.SelectionManager.ClearSelection();
     textArea.Caret.Position = new TextLocation(column, line);
     textArea.SetDesiredColumn();
     ScrollToCaret();
 }
        void TextAreaClick(object sender, EventArgs e)
        {
            Point mousepos;

            mousepos = textArea.mousepos;

            if (dodragdrop)
            {
                return;
            }

            if (clickedOnSelectedText && textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y))
            {
                textArea.SelectionManager.ClearSelection();

                TextLocation clickPosition = textArea.TextView.GetLogicalPosition(
                    mousepos.X - textArea.TextView.DrawingPosition.X,
                    mousepos.Y - textArea.TextView.DrawingPosition.Y);
                textArea.Caret.Position = clickPosition;
                textArea.SetDesiredColumn();
            }
        }