Esempio n. 1
0
        private void InitializeComponent()
        {
            if (this.Parent != null)
            {
                Size = new Size(this.Parent.Width / 2, this.Parent.Height - 100);
            }

            this.Dock = DockStyle.Left;

            _treeView        = new TreeView();
            _treeView.Parent = this;
            _treeView.Dock   = DockStyle.Fill;

            _treeViewController = new TreeViewController(_treeView);

            _treeView.AfterExpand += (object sender, TreeViewEventArgs e) =>
            {
                TreeNode clickedNode = e.Node;

                TreeViewHandler2();

                if (TreeViewHandler != null)
                {
                    TreeViewHandler(new DirectoryInfo(clickedNode.Text));
                }

                foreach (TreeNode tn in clickedNode.Nodes)
                {
                    _treeViewController.AddNode(tn, new DirectoryInfo(tn.Text));
                }
            };

            _treeView.AfterCollapse += (object sender, TreeViewEventArgs e) =>
            {
                TreeNode clickedNode = e.Node;
                foreach (TreeNode tn in clickedNode.Nodes)
                {
                    _treeViewController.ClearAllNode(tn);
                }
            };

            _treeView.AfterSelect += (object sender, TreeViewEventArgs e) =>
            {
                TreeNode clickedNode = e.Node;
                TreeViewHandler2();
                TreeViewHandler(new DirectoryInfo(clickedNode.Text));
            };
        }