Drag / Drop Iconic Node Issue

I have the following code

   Dim node = CType(gvTask.Document.PickObject(e.ViewPoint, True), GoIconicNode)

It is on the ExternalObjectsDropped, I then execute code based on the dropped node’s properties. The problem I am having is that the point returned by both DocPoint and ViewPoint obviously do not relate to the node dropped as the node is nothing.

Is there a way around this? Could I use rectangle and force the users to drop near the top of the screen (not ideal)

Surely if the object dropped is a node how would it not relate to the node?

In addition this sometimes works and sometimes does not.

Any ideas would be most welcome.

Look at
ExternalObjectsDropped in the Processor sample. The GoView.Selection is the collection of objects just dropped. You don’t have to PickObject to find that object.

Hi Jake, I looked at that example, it does not have a list of selected objects.

If I could get access to the last dropped object not from a point that would be ideal.

Dim sel As GoObject = Me.goPalette1.Selection.Primary
Dim rn As RemoteConnectorNode = Nothing
If (TypeOf sel Is RemoteConnectorNode) Then _
rn = CType(sel, RemoteConnectorNode)
If (Not rn Is Nothing) Then
’ the newly copied node has already been added to the document–remove it
’ now look at the object at the event’s point, which should be a FlowLink
Dim link As FlowLink = Nothing
If (TypeOf goView1.Document.PickObject(e.DocPoint, True).ParentNode Is FlowLink) Then _
link = CType(goView1.Document.PickObject(e.DocPoint, True).ParentNode, FlowLink)
If (Not link Is Nothing AndAlso link.CanInsertRemoteConnectors()) Then
End If
End If
End Sub

Ah sorry, I see it, let me try that

I tried that and it removes the icon from the palette

 Dim obj As Object = Me.GoPalette1.Selection.Primary

    'If (TypeOf gvTask.Document.PickObject(e.DocPoint, True) Is GoIconicNode) Then
    If (TypeOf obj Is GoIconicNode) Then

        Dim bSaveStep As Boolean = True
        Dim [step] As New [Step]

        'Dim node = CType(gvTask.Document.PickObject(e.ViewPoint, True), GoIconicNode)
        Dim node = CType(obj, GoIconicNode)

        If Not node Is Nothing Then

Just looked into this a bit more, I need to keep my original code, I need to get the node dropped not the selected on in the palette

it has to be something to do with to coordinates, it works 95% of time on dev machine, and about 1% on client

this gets more bizarre by the second, on the client machine it works fine for the first item in the palette but no the rest. This is exactly the same code as the development machine which works 95% of the item for all items in the palette

from Processor:

private void goView1_ExternalObjectsDropped(object sender, Northwoods.Go.GoInputEventArgs e) {
  RemoteConnectorNode rn = goView1.Selection.Primary as RemoteConnectorNode;

goView1.Selection is the collection of dropped objects… which is typically one item.

goView1.Selection.Primary is the first element of that collection.

thus, “rn” is the node that was dropped onto the view from the palette.

That’s what I tried Jake but it then removes it from the palette. Is there a way of simply grabbing the last added node just not from a point

That’s because the sample does rn.Remove();. Don’t do that, or any of the rest of that method’s code in the sample.

I will have a look tomorrow, I am pretty sure I don’t

Hi Jake, that seems to have sorted it. Thanks for all your help