Hi Stoyan,
I am using my own node class which inherits CompositeNode and i'm wondering if it's possible to use the DiagramView's CopyToClipboard functionality on it?
What i'm trying to do is allow the user to select a single node and copy it and all of it's children (nodes & links) and then be able to paste it onto another node in the diagram as a subordinate - basically, to save them having to do everything twice!
I currently have the following code which I was hoping would allow me to copy the nodes but it's crashing on the scView.CopyToClipboard(true) line if the selectedNode has any children...
'Handles mnuCopy.Click
Private Sub mnuCopy_Click(sender As System.Object, e As System.EventArgs) Handles mnuCopy.Click
If Not IsNothing(selectedNode) Then
copyWithChildren(selectedNode)
End If
End Sub
'Handles mnuPaste.Click
Private Sub mnuPaste_Click(sender As System.Object, e As System.EventArgs) Handles mnuPaste.Click
If Not IsNothing(selectedNode) Then
scView.PasteFromClipboard(10, 10)
End If
End Sub
Private Sub copyWithChildren(ByVal node As SmartScore_NodeDesign)
selectWithChildren(node)
scView.CopyToClipboard(True)
doc.Selection.Change(node)
End Sub
Private Sub selectWithChildren(ByVal node As SmartScore_NodeDesign)
node.Selected = True
For Each link As DiagramLink In node.OutgoingLinks
link.Selected = True
selectWithChildren(link.Destination)
Next
End Sub
Even if I just select a single node, it doesn't paste (although it doesn't crash - it doesn't seem to do anything)... Plus, how would I go about taking the first node of the copied group and making it a child of the node used to paste onto - would i use AttachTo? How would i select the first node of the copied group?
Any help would be really appreciated.
Thanks!
Rich