private void Diagram_Loaded(object sender) { diagram.BringToView(diagram.Nodes[0]); if (isTablet) { overview = new CustomOverview(diagram.Context); diagram.OverviewPanel = overview; overview.PreventRefresh = true; overview.Layout(0, 0, 400, 400); diagram.AddView(overview); overview.ForceRefresh(); } }
private void Diagram_OnLayoutNodeDropped(object sender, LayoutNodeDroppedEventArgs args) { Node draggedNode = args.DraggedItem as Node; Node droppedNode = args.DroppedItem as Node; bool contain = true; if (draggedNode != null && draggedNode != droppedNode) { Node ParentNode = GetParent((droppedNode.Content as DiagramEmployee).ReportingPerson); do { if (ParentNode != draggedNode) { contain = false; } else { contain = true; break; } ParentNode = GetParent((ParentNode.Content as DiagramEmployee).ReportingPerson); } while (ParentNode != null); if (!contain) { Connector con; bool hasChild = false; foreach (Connector connector in draggedNode.InConnectors) { con = connector; con.SourceNode = droppedNode; hasChild = true; } if (hasChild) { Node PrevParentNode = GetParent((draggedNode.Content as DiagramEmployee).ReportingPerson); bool noChild = true; foreach (Connector c in PrevParentNode.OutConnectors) { noChild = false; } if (PrevParentNode != null && noChild) { (PrevParentNode.Content as DiagramEmployee).HasChild = false; DrawTemplate(PrevParentNode); } DiagramEmployee ParentEmployee = (droppedNode.Content as DiagramEmployee); (draggedNode.Content as DiagramEmployee).ReportingPerson = ParentEmployee.Name; ParentEmployee.HasChild = true; ExpandAll(draggedNode); UpdateTemplate(draggedNode); UpdateTemplate(droppedNode); } droppedNode.IsExpanded = true; diagram.LayoutManager.Layout.UpdateLayout(); if (overviewPanel != null) { overviewPanel.ForceRefresh(); } } } }