Code used in this example
You can download this code using the ink above.
/***********************************
* LockChildrenToXPlaneOnDrag
********************************** */
//set up parent
DiagramNode parentNode = new DiagramNode("../Art/Me.gif", "ME", "Drag ME!", "ME1",
1, 55, 100, new List<string>(), new List<string>());
parentNode.LockChildrenToXPlaneOnDrag = true;
//set up children
DiagramNode childNode1 = new DiagramNode("../Art/You.gif", "You #1", "Drag yourself!", "YOU1",
2, 5, 5, new List<string>(), new List<string>());
DiagramNode childNode2 = new DiagramNode("../Art/You.gif", "You #2", "Drag yourself again!", "YOU2",
3, 105, 5, new List<string>(), new List<string>());
//add children to parent
parentNode.ParentOfIds.Add("YOU1");
parentNode.ParentOfIds.Add("YOU2");
diagramContainerXPlaneLock.AllNodes.Add(parentNode);
diagramContainerXPlaneLock.AllNodes.Add(childNode1);
diagramContainerXPlaneLock.AllNodes.Add(childNode2);
/***********************************
* LockChildrenToYPlaneOnDrag
********************************** */
//set up parent
DiagramNode parentNode2 = new DiagramNode("../Art/Me.gif", "ME", "Drag ME!", "ME2",
4, 55, 100, new List<string>(), new List<string>());
parentNode2.LockChildrenToYPlaneOnDrag = true;
//set up children
DiagramNode childNode3 = new DiagramNode("../Art/You.gif", "You #1", "Drag yourself!", "YOU3",
5, 5, 5, new List<string>(), new List<string>());
DiagramNode childNode4 = new DiagramNode("../Art/You.gif", "You #2", "Drag yourself again!", "YOU4",
6, 105, 5, new List<string>(), new List<string>());
//add children to parent
parentNode2.ParentOfIds.Add("YOU3");
parentNode2.ParentOfIds.Add("YOU4");
diagramContainerYPlaneLock.AllNodes.Add(parentNode2);
diagramContainerYPlaneLock.AllNodes.Add(childNode3);
diagramContainerYPlaneLock.AllNodes.Add(childNode4);
/***********************************
* AutoSnapChildrenBelow
********************************** */
//set up parent
DiagramNode parentNode3 = new DiagramNode("../Art/db/plainrow.gif", "Parent", "Drag ME!", "ME3",
7, 5, 5, new List<string>(), new List<string>());
//need to explicitly set height so the snapping works
parentNode3.Height = Unit.Pixel(35);
parentNode3.AutoSnapChildrenBelow = true;
parentNode3.TextPlacement = TextPosition.CenteredOnImage;
//ensure children fall in line to the snapping (these must be set
true if AutoSnapChildrenBelow is true)
parentNode3.LockChildrenToXPlaneOnDrag = true;
parentNode3.LockChildrenToYPlaneOnDrag = true;
//set up children -- note, it doesn't matter what x & y coordinates
are passed because
//the AutoSnapChildrenBelow will reposition them anyway
DiagramNode childNode5 = new DiagramNode("../Art/db/plainrow.gif", "Child #1", "Drag yourself!", "YOU5",
8, 0, 0, new List<string>(), new List<string>());
DiagramNode childNode6 = new DiagramNode("../Art/db/plainrow.gif", "Child #2", "Drag yourself again!", "YOU6",
9, 0, 0, new List<string>(), new List<string>());
//don't draw child lines of children because they are auto snapped
to parent
childNode5.DrawChildLines = false;
childNode6.DrawChildLines = false;
//must set height so snapping works
childNode5.Height = Unit.Pixel(35);
childNode6.Height = Unit.Pixel(35);
childNode5.TextPlacement = TextPosition.CenteredOnImage;
childNode6.TextPlacement = TextPosition.CenteredOnImage;
//don't draw parent lines of parent node because its children are
auto snapped below
parentNode3.DrawParentLines = false;
//add children to parent
parentNode3.ParentOfIds.Add("YOU5");
parentNode3.ParentOfIds.Add("YOU6");
diagramContainerAutoSnapChildrenBelow.AllNodes.Add(parentNode3);
diagramContainerAutoSnapChildrenBelow.AllNodes.Add(childNode5);
diagramContainerAutoSnapChildrenBelow.AllNodes.Add(childNode6);