internal TNode ActualFromNode() { if (DragFromNode == null) { return(null); } if (DragFromNode == DragToNode || DragToNode == null) // self-wiring or no to-route { return(DragFromNode); } if (DragFromNodeHitPath == null) // fromNode top level { return(DragFromNode); } if (DragToNodeHitPath == null) // counterpart top level { return(DragFromNodeHitPath[0].As <TNode>()); } var lca = HitPathsGetLowestCommonAncestor(); if (lca == null) { return(DragFromNodeHitPath[0].As <TNode>()); // counterpart in another container } int index = DragFromNodeHitPath.IndexOf(lca); return(DragFromNodeHitPath[index + 1].As <TNode>()); // return the child node of the lca }
// Gets the lowest common ancestor (LCA) for the 2 hit path private TNode HitPathsGetLowestCommonAncestor() { if (DragToNodeHitPath == null || DragFromNodeHitPath == null) { return(null); } for (int i = DragToNodeHitPath.Count - 1; i >= 0; --i) { if (DragFromNodeHitPath.Contains(DragToNodeHitPath[i])) { return(DragToNodeHitPath[i].As <TNode>()); } } return(null); }