private void addEmptyEntityToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var form = new GetNameForm("Entity name");

            if (form.ShowDialog() == DialogResult.OK)
            {
                var ent = new Entity(form.Name, activeScene);
                EntityView.BeginUpdate();
                int t = EntityView.Nodes.Add(new EntityTreeNode(ent));
                EntityView.EndUpdate();
            }
        }
        private void SceneComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lastScene != null)
            {
                ///
                /// Remove all handlers
                ///
                //lastScene.Materials.CollectionChanged -= MaterialsChanged;
                lastScene.sceneRenderer.OnDrawStart -= DrawGrid;
            }
            EntityView.Nodes.Clear();

            MaterialBox.Items.Clear();
            MaterialShaderBox.Items.Clear();

            activeScene = (SceneComboBox.SelectedItem) as Scene;

            if (activeScene == null)
            {
                return;
            }

            //activeScene.Materials.CollectionChanged += MaterialsChanged;
            activeScene.EnititiesChanged += EntityChanged;
            EntityView.BeginUpdate();
            foreach (var ent in activeScene.Entities)
            {
                AddEntitiesToTreeViewRec(ent, EntityView.Nodes);
                //int x = 5;
            }


            /*foreach (var mr in activeScene.Materials.References())
             * {
             *  MaterialBox.Items.Add(mr);
             * }*/

            EntityView.EndUpdate();
            GameApp.RenderSystem.ActiveScene = activeScene;
            lastScene = activeScene;

            activeScene.sceneRenderer.OnDrawStart += DrawGrid;
        }
        private void EntityView_DragDrop(object sender, DragEventArgs e)
        {
            EntityTreeNode NewNode;

            if (e.Data.GetDataPresent(typeof(EntityTreeNode).FullName, false))
            {
                System.Drawing.Point pt = ((TreeView)sender).PointToClient(new System.Drawing.Point(e.X, e.Y));
                EntityTreeNode       DestinationNode = (EntityTreeNode)((TreeView)sender).GetNodeAt(pt);
                NewNode = (EntityTreeNode)e.Data.GetData(typeof(EntityTreeNode).FullName);


                if (DestinationNode == null)
                {
                    if (NewNode.Entity.Parent != null)
                    {
                        NewNode.Entity.Parent.RemoveEntity(NewNode.Entity, true);
                        NewNode.Remove();
                        EntityView.Nodes.Add(NewNode);
                    }
                }
                else
                if (DestinationNode.TreeView == EntityView)
                {
                    Entity ent = DestinationNode.Entity;
                    do
                    {
                        if (NewNode.Entity == ent)
                        {
                            return;
                        }
                        ent = ent.Parent;
                    } while (ent != null);

                    EntityView.BeginUpdate();
                    NewNode.Remove();
                    DestinationNode.Entity.AddEntity(NewNode.Entity);
                    DestinationNode.Nodes.Add(NewNode);
                    DestinationNode.Expand();
                    EntityView.EndUpdate();
                }
            }
        }