protected void NDrawingView1_AsyncClick(object sender, EventArgs e) { NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs; NNodeList nodes = NDrawingView1.HitTest(args); NNodeList shapes = nodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D); NExpandCollapseCheck check = null; int length = shapes.Count; for (int i = 0; i < length; i++) { if (shapes[i] is NExpandCollapseCheck) { check = shapes[i] as NExpandCollapseCheck; break; } } if (check == null) { return; } NExpandableShape shape = check.ParentNode.ParentNode as NExpandableShape; shape.Expand(!shape.Expanded); }
/// <summary> /// /// </summary> /// <param name="expandShape"></param> public void Expand(bool expandShape) { // expand or collapse in a single transation StartTransaction(expandShape ? "Expand Tree" : "Collapse Tree"); // mark shape as expanded Expanded = expandShape; // show/hide the plus or minus NExpandCollapseCheck check = GetExpandCollapseCheck(); NPathPrimitive pathPrimitive; pathPrimitive = check.Primitives.GetChildAt(1) as NPathPrimitive; pathPrimitive.Visible = !expandShape; pathPrimitive = check.Primitives.GetChildAt(2) as NPathPrimitive; pathPrimitive.Visible = expandShape; // show/hide all outgoing shapes NNodeList nodes = GetOutgoingShapes(); for (int i = 0; i < nodes.Count; i++) { NShape shape = (nodes[i] as NShape); shape.Visible = expandShape; } // show/hide all destination shapes nodes = GetDestinationShapes(); for (int i = 0; i < nodes.Count; i++) { NShape shape = (nodes[i] as NShape); shape.Visible = expandShape; } // expand/collapse the destination shapes for (int i = 0; i < nodes.Count; i++) { NExpandableShape expandableShape = (nodes[i] as NExpandableShape); if (expandableShape != null) { expandableShape.Expand(expandShape); } } // commit the transaction Commit(); }