Пример #1
0
        private void buttonAddLayer_Click(object sender, EventArgs e)
        {
            if (treeViewLayers.SelectedNode != null)
            {
                if (treeViewLayers.SelectedNode.Parent != null)
                {
                    int index = treeViewLayers.SelectedNode.Parent.Nodes.IndexOf(treeViewLayers.SelectedNode);

                    TreeNode newNode =  treeViewLayers.SelectedNode.Parent.Nodes.Insert(index + 1, "untitled");

                    Layer newLayer = new Layer((Layer)treeViewLayers.SelectedNode.Parent.Tag);
                    newLayer.AttachToTreeNode(newNode);
                    Layer parentLayer = (Layer)treeViewLayers.SelectedNode.Parent.Tag;

                    _scene.Layers.Add(newLayer, parentLayer);

                }
                else
                {
                    int index = treeViewLayers.Nodes.IndexOf(treeViewLayers.SelectedNode);
                    TreeNode newNode = treeViewLayers.Nodes.Insert(index + 1, "untitled");

                    Layer newLayer = new Layer(null);
                    newLayer.AttachToTreeNode(newNode);
                    _scene.Layers.Add(newLayer);
                }

            }
        }