Exemple #1
0
        private void enumerateTreeNodes_objects()
        {
            EnumerateNodesDelegate enumerateAllNodesDelegate =
                new EnumerateNodesDelegate(enumerateAllNodes);;

            while (!TreeViewUtil.EnumerateNodes(treeViewObjects, enumerateAllNodesDelegate))
            {
                ;
            }
        }
Exemple #2
0
        private void tsmiDeleteLayer_Click(object sender, EventArgs e)
        {
            TreeNode node = CurrentLayerNode;

            if (node == null)
            {
                tsmiDeleteLayer.Enabled = false;
                return;
            }
            List <TreeNode> valueNodes = new List <TreeNode>();

            TreeViewUtil.EnumerateNodes(node, (_node) => {
                if (_node.Tag is Entity)
                {
                    valueNodes.Add(_node);
                }
                return(true);
            });
            if (valueNodes.Count > 0)
            {
                string infoMessage = string.Format("该Layer下有{0}个节点, 删除该Layer会将这些节点放在根节点下。是否继续?", valueNodes.Count);
                if (MessageBox.Show(infoMessage, "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                {
                    return;
                }
            }

            Map.EditorLayer layer = node.Tag as Map.EditorLayer;
            if (Map.Instance != null && layer == Map.Instance.RootEditorLayer)
            {
                tsmiDeleteLayer.Enabled = false;
                return;
            }

            if (layer.Remove())
            {
                node.Tag = null;
                if (node.Parent != null)
                {
                    treeViewEntities.SelectedNode = node.Parent;
                }
                node.Remove();

                UpdateData();

                MapWorld.Instance.Modified = true;
            }
        }