Drag&Drop a debug arrow like in visual studio

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by Jan - Germany
Avatar
SyntaxEditor .NET Control v3.1.0200, .NET 2.0, Windows XP

Hallo,

i have to implement a program location arrow drag & drop action like in visual studio.
But i can't find any solution to customize the Effect property of the Drag&Drop action.

In the documentation i read i have to use the PasteDragDrop Eventhandler in place of the general DragEnter event.
So my first try looks like this:

    Private Sub SyntaxEditor1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SyntaxEditor1.MouseDown
        If IsMouseHoveringDebugArrow(e.location) Then
            Me.DoDragDrop(Me.mArrowIndicator, DragDropEffects.Move)
        End If
    End Sub

    Private Function IsMouseHoveringDebugArrow(ByVal mouseLocation As Point) As Boolean
        If mouseLocation.X > SyntaxEditor1.IndicatorMarginWidth Then Return False

        Dim position As Position = SyntaxEditor1.SelectedView.PositionFromLocation(mouseLocation, LocationToOffsetAlgorithm.BestFit)
        Dim offset As Integer = SyntaxEditor1.Document.PositionToOffset(position)
        Dim nextOffset As Integer = SyntaxEditor1.Document.PositionToOffset(New Position(Math.Min(position.Line + 1, SyntaxEditor1.Document.Lines.Count - 1), 0))

        If mArrowIndicator.Offset >= offset AndAlso mArrowIndicator.Offset <= nextOffset Then Return True
       
        Return False
    End Function

    Private Sub SyntaxEditor1_PasteDragDrop(ByVal sender As System.Object, ByVal e As ActiproSoftware.SyntaxEditor.PasteDragDropEventArgs) Handles SyntaxEditor1.PasteDragDrop
        If e.Source = PasteDragDropSource.DragEnter Then
            If e.DragEventArgs.Data.GetDataPresent(mArrowIndicator.GetType()) Then
                e.DragEventArgs.Effect = DragDropEffects.Move
            End If
        End If
    End Sub
in the PasteDragDrop handler the codeline to change the dragDropEffect seems to have no affect.
does someone know what i'm doing wrong, or does example code for this standard feature exists?



[Modified at 03/27/2006 01:15 AM]

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jan,

Right now it appears our drag/drop code is designed for moving text only within the document.
So it's doing all the really difficult code of figuring out what "Effect" to apply when you are over a view.
This is rather advanced code when you have to account for drag/drop between views, etc.

Anyhow, it seems like you need a way to be able to turn off our default code.
Since the DragEventArgs and related event arg classes don't have a handled, your best
bet would probably be to override SyntaxEditor in your own class and if you are dragging
an indicator, don't call the base OnDragXXX events.

For our implemenation, we implemented OnDragDrop, OnDragEnter, OnDragLeave, and OnDragOver
so make sure you override all of those to cancel functionality.

We're also open to any suggestions you have for making this easier to turn off our code
in a future version.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.