Ejemplo n.º 1
0
        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)
                {
                    List <Connector> connectors = draggedNode.InConnectors as List <Connector>;
                    Connector        con;
                    bool             hasChild = false;
                    for (int i = 0; i < connectors.Count; i++)
                    {
                        con            = connectors[i];
                        con.SourceNode = droppedNode;
                        hasChild       = true;
                    }
                    if (hasChild)
                    {
                        Node PrevParentNode = GetParent((draggedNode.Content as DiagramEmployee).ReportingPerson);
                        if (PrevParentNode != null && PrevParentNode.OutConnectors.Count() == 0)
                        {
                            (PrevParentNode.Content as DiagramEmployee).HasChild = false;
                            DrawTemplate(PrevParentNode);
                        }
                        DiagramEmployee ParentEmployee = (droppedNode.Content as DiagramEmployee);
                        (draggedNode.Content as DiagramEmployee).ReportingPerson = ParentEmployee.Name;
                        ParentEmployee.HasChild = true;
                        DrawTemplate(droppedNode);

                        ExpandAll(draggedNode);
                    }
                    (draggedNode.Content as DiagramEmployee).ReportingPerson = (droppedNode.Content as DiagramEmployee).Name;
                    droppedNode.IsExpanded = true;
                    diagram.LayoutManager.Layout.UpdateLayout();
                    if (overview != null)
                    {
                        overview.ForceRefresh();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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();
                    }
                }
            }
        }