GetDragDropEffect() static private method

static private GetDragDropEffect ( DragEventArgs e ) : DragDropEffects
e System.Windows.Forms.DragEventArgs
return DragDropEffects
コード例 #1
0
        protected void OnDragOver(object sender, DragEventArgs e)
        {
            if (!this.textArea.Focused)
            {
                this.textArea.Focus();
            }
            Point client = this.textArea.PointToClient(new Point(e.X, e.Y));

            if (!this.textArea.TextView.DrawingPosition.Contains(client.X, client.Y))
            {
                e.Effect = DragDropEffects.None;
                return;
            }
            TextView     textView        = this.textArea.TextView;
            int          x               = client.X - this.textArea.TextView.DrawingPosition.X;
            int          y               = client.Y;
            Rectangle    drawingPosition = this.textArea.TextView.DrawingPosition;
            TextLocation logicalPosition = textView.GetLogicalPosition(x, y - drawingPosition.Y);
            int          num             = Math.Min(this.textArea.Document.TotalNumberOfLines - 1, Math.Max(0, logicalPosition.Y));

            this.textArea.Caret.Position = new TextLocation(logicalPosition.X, num);
            this.textArea.SetDesiredColumn();
            if (!e.Data.GetDataPresent(typeof(string)) || this.textArea.IsReadOnly(this.textArea.Caret.Offset))
            {
                e.Effect = DragDropEffects.None;
                return;
            }
            e.Effect = TextAreaDragDropHandler.GetDragDropEffect(e);
        }
コード例 #2
0
 protected void OnDragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(typeof(string)))
     {
         e.Effect = TextAreaDragDropHandler.GetDragDropEffect(e);
     }
 }
コード例 #3
0
 protected void OnDragDrop(object sender, DragEventArgs e)
 {
     this.textArea.PointToClient(new Point(e.X, e.Y));
     if (e.Data.GetDataPresent(typeof(string)))
     {
         this.textArea.BeginUpdate();
         this.textArea.Document.UndoStack.StartUndoGroup();
         try
         {
             int offset = this.textArea.Caret.Offset;
             if (!this.textArea.IsReadOnly(offset))
             {
                 if (e.Data.GetDataPresent(typeof(DefaultSelection)))
                 {
                     ISelection data = (ISelection)e.Data.GetData(typeof(DefaultSelection));
                     if (data.ContainsPosition(this.textArea.Caret.Position))
                     {
                         return;
                     }
                     else if (TextAreaDragDropHandler.GetDragDropEffect(e) == DragDropEffects.Move)
                     {
                         if (!SelectionManager.SelectionIsReadOnly(this.textArea.Document, data))
                         {
                             int length = data.Length;
                             this.textArea.Document.Remove(data.Offset, length);
                             if (data.Offset < offset)
                             {
                                 offset -= length;
                             }
                         }
                         else
                         {
                             return;
                         }
                     }
                 }
                 this.textArea.SelectionManager.ClearSelection();
                 this.InsertString(offset, (string)e.Data.GetData(typeof(string)));
                 this.textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
             }
         }
         finally
         {
             this.textArea.Document.UndoStack.EndUndoGroup();
             this.textArea.EndUpdate();
         }
     }
 }