예제 #1
0
        void Entity_EntityUpdatedEvent(Entity ent, String field)
        {
            if (treeView1.IsDisposed)
            {
                return;
            }

            if (updateEnabled == false)
            {
                return;
            }

            EntidadNode node = FindEntityNode(ent);

            if (node != null)
            {
                treeView1.BeginUpdate();

                node.Text = ent.Name;

                EntidadNode root = null;

                if (ent.Transformation != null && ent.Transformation.Parent != null && ent.Transformation.Parent.Entity != null)
                {
                    root = FindEntityNode(ent.Transformation.Parent.Entity);
                }

                if (root != node.Parent)
                {
                    node.Remove();

                    if (root != null)
                    {
                        root.Nodes.Add(node);
                        root.ExpandAll();
                    }
                    else
                    {
                        treeView1.Nodes.Add(node);
                        treeView1.ExpandAll();
                    }
                }

                treeView1.EndUpdate();
            }
        }
예제 #2
0
        private EntidadNode FindEntityNode(Entity ent, TreeNodeCollection col)
        {
            foreach (EntidadNode node in col)
            {
                if (node.Entity == ent)
                {
                    return(node);
                }

                EntidadNode node2 = FindEntityNode(ent, node.Nodes);

                if (node2 != null)
                {
                    return(node2);
                }
            }

            return(null);
        }
예제 #3
0
        void Entity_EntityDeletedEvent(Entity ent)
        {
            if (treeView1.IsDisposed)
            {
                return;
            }

            if (updateEnabled == false)
            {
                return;
            }

            EntidadNode node = FindEntityNode(ent);

            if (node != null)
            {
                node.Remove();
            }
        }
예제 #4
0
        private void AgregarEntity(Entity ent, EntidadNode root)
        {
            EntidadNode nodo = new EntidadNode(ent);

            nodo.Expand();

            foreach (Entity ent2 in ent.Childs)
            {
                AgregarEntity(ent2, nodo);
            }

            if (root == null)
            {
                treeView1.Nodes.Add(nodo);
            }
            else
            {
                root.Nodes.Add(nodo);
            }
        }
예제 #5
0
        void Entity_EntityCreatedEvent(Entity ent)
        {
            if (treeView1.IsDisposed)
            {
                return;
            }

            if (updateEnabled == false)
            {
                return;
            }

            EntidadNode root = null;

            if (ent.Transformation.Parent != null && ent.Transformation.Parent.Entity != null)
            {
                root = FindEntityNode(ent.Transformation.Parent.Entity);
            }

            AgregarEntity(ent, root);
        }
예제 #6
0
        private void treeView1_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(EntidadNode)))
            {
                Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));

                EntidadNode destinationNode = (EntidadNode)((TreeView)sender).GetNodeAt(pt);
                Entity      destinationEntity;

                if (destinationNode != null)
                {
                    destinationEntity = destinationNode.Entity;
                }
                else
                {
                    destinationEntity = Entity.Root;
                }

                EntidadNode movingNode   = (EntidadNode)e.Data.GetData(typeof(EntidadNode));
                Entity      movingEntity = movingNode.Entity;

                if (movingEntity != destinationEntity)
                {
                    Entity temp = destinationEntity;
                    while (temp.Transformation.Parent != null)
                    {
                        if (temp.Transformation.Parent.Entity == movingEntity)
                        {
                            return;
                        }

                        temp = temp.Transformation.Parent.Entity;
                    }

                    movingEntity.Transformation.Parent = destinationEntity.Transformation;

                    Entity_EntityUpdatedEvent(movingEntity, "");

                    SelectedEntity = movingEntity;
                }
            }
            else if (e.Data.GetDataPresent(typeof(ListaRecursos.ListViewItemResource)))
            {
                Resource res = ((ListaRecursos.ListViewItemResource)e.Data.GetData(typeof(ListaRecursos.ListViewItemResource))).resource;

                Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));

                EntidadNode destinationNode = (EntidadNode)((TreeView)sender).GetNodeAt(pt);
                Entity      destinationEntity;

                if (destinationNode != null)
                {
                    destinationEntity = destinationNode.Entity;

                    if (res.CanAssignTo(destinationEntity))
                    {
                        res.AssignTo(destinationEntity);
                    }
                }
            }
        }