Exemplo n.º 1
0
        void Add(MyNode parent, SceneNodHierachyModel obj)
        {
            MyNode child = new MyNode(obj.ID);
            child.Obj = obj;
            parent.Nodes.Add(child);
            //parent.Obj = obj;
            if(obj.Children.Count>0)
            {

                foreach(SceneNodHierachyModel childModel in obj.Children)
                    Add(child, childModel);
            }
        }
Exemplo n.º 2
0
 void select(MyNode node, List<string> nodeNms)
 {
     if (node.Name == nodeNms[0])
         node.TreeView.SelectedNode=node;
 }
Exemplo n.º 3
0
        //void _treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        //{
        //    Type t= sender.GetType();
        //    try
        //    {
        //        MyNode node = (MyNode)e.Node;
        //        if (node.Obj == null)
        //            return;
        //        string id = node.Text;
        //        //SelectFunction.Select(id);
        //        SelectFunction.Select(node.Obj);
        //    }
        //    catch (Exception ef)
        //    {
        //        MyConsole.WriteLine("Cannot select such data");
        //    }
        //}
        void Initialize()
        {
            _treeView = new TreeView();
            _lockPipeBtn = new Button();
            _lockBuildingBtn = new Button();

            this.SuspendLayout();

            // Initialize treeView1.
            _treeView.Location = new System.Drawing.Point(0, 25);
            _treeView.Size = new Size(292, 248);
            _treeView.Anchor = AnchorStyles.Top | AnchorStyles.Left |
                AnchorStyles.Bottom | AnchorStyles.Right;
            _treeView.CheckBoxes = true;
            //_treeView.NodeMouseClick+=_treeView_NodeMouseClick;
            _treeView.AfterSelect += new TreeViewEventHandler(afterSelectHandler);

            _treeView.AfterCheck += new TreeViewEventHandler(afterCheck);
            _pipeRoot = new MyNode("供水管道");
            _valveRoot = new MyNode("阀门");
            _chamberRoot = new MyNode("热力小室");
            _wellRoot =new MyNode("井");//new System.Windows.Forms.TreeNode("井");
            _holeRoot = new MyNode("空洞");
            _buildingRoot = new MyNode("地面");
            _treeView.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
                        _pipeRoot,_valveRoot,
                        _chamberRoot,_wellRoot,
                        _holeRoot, _buildingRoot});
            /*
            // Add nodes to treeView1.
            TreeNode node;
            for (int x = 0; x < 3; ++x)
            {
                // Add a root node.
                node = _treeView.Nodes.Add(String.Format("Node{0}", x * 4));
                for (int y = 1; y < 4; ++y)
                {
                    // Add a node as a child of the previously added node.
                    node = node.Nodes.Add(String.Format("Node{0}", x * 4 + y));
                }
            }

            // Set the checked state of one of the nodes to
            // demonstrate the showCheckedNodesButton button behavior.
            _treeView.Nodes[1].Nodes[0].Nodes[0].Checked = true;
            */
            // Initialize showCheckedNodesButton.
            _lockPipeBtn.Size = new Size(144, 24);
            _lockPipeBtn.Text = "锁定管道";
            _lockPipeBtn.Click +=
                new EventHandler(showCheckedNodesButton_Click);

            _lockBuildingBtn.Size = new Size(144, 24);
            _lockBuildingBtn.Text = "锁定建筑";
            _lockBuildingBtn.Click +=
                new EventHandler(showCheckedNodesButton_Click);

            // Initialize the form.
            this.ClientSize = new Size(292, 273);
            this.Controls.AddRange(new Control[] { _lockPipeBtn,_lockBuildingBtn, _treeView });

            this.ResumeLayout(false);
        }