Hi.
Thx for your code "(based on Stoyo's) prevents the creation of nested ContainerNode's"...
If you are dragging container "A" into container "B" this code is ok only if drop is permormed directly over container "B". If in "B" is any shape and drop is performed over it --> it doesnt work.
So I guess I should to use "GetNodesAt" function instead of "GetNodeAt" and iterate DiagramNodeCollection object which is returned by this function.
My two solutions:1) - handling NodeModifying event
Private Sub fcDiagram_NodeModifying(ByVal sender As Object, ByVal e As MindFusion.Diagramming.NodeValidationEventArgs) Handles fcDiagram.NodeModifying
'preventing nesting of containers
Select Case e.Node.GetType.Name
Case "ClsMMContainerNode"
Dim LoDiagramNodeCollection As DiagramNodeCollection = Me.fcDiagram.GetNodesAt(e.MousePosition)
For Each LoNode As DiagramNode In LoDiagramNodeCollection
If (LoNode.GetType.Name = "ClsMMContainerNode") And (Not LoNode.Equals(e.Node)) Then 'prevention of selfchecking
e.Cancel = True
Exit For
End If
Next
End Select
End sub
2) - deriving from ContainerNode
'overrided sub - when a diagram item is being dragged over this node
Public Overrides Function OnDragOver(ByVal item As MindFusion.Diagramming.DiagramItem) As Boolean
If item.GetType.Name = "ClsMMContainerNode" Then
Return False
Else
Return MyBase.OnDragOver(item)
End If
End Function
'overrided sub - when a diagram item is dropped over this node
Public Overrides Function OnDropOver(ByVal item As MindFusion.Diagramming.DiagramItem) As Boolean
If item.GetType.Name = "ClsMMContainerNode" Then
Return False
Else
Return MyBase.OnDropOver(item)
End If
End Function
In first case there is presented also "feature" - Setting e.Cancel = true should automatically move the node back to its original position and container.
In second case node is not returned back to original position.
It seems MyBase.OnDropOver performs any other operations because if I return true instead of MyBase.OnDropOver nothing is happen.Any comment guys? Any suggestion for improoving procedure "Cancel dropping nodes in containers"? Thx.
...MUDO...