Пример #1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = this.objectsTreeView.SelectedNode;

            if (node == null)
            {
                return;
            }
            SceneObject obj = node.Tag as SceneObject;

            if (obj == null)
            {
                return;
            }

            if (obj.Parent == null)
            {
                throw new Exception("This should not happen.");
            }

            obj.Parent.Children.Remove(obj);
            if (node.Parent == null)
            {
                this.objectsTreeView.Nodes.Remove(node);
            }
            else
            {
                node.Parent.Nodes.Remove(node);
            }

            obj.Dispose();

            this.scientificCanvas.Invalidate();
        }