예제 #1
0
파일: Main.cs 프로젝트: jongha/winuglifier
        private void GetTreeNode(ref WinUglifier.TreeView.TreeNode root, string[] items)
        {
            foreach (string item in items)
            {
                if (Directory.Exists(item)) // is directory ?
                {
                    WinUglifier.TreeView.TreeNode node = new WinUglifier.TreeView.TreeNode(null, Path.GetFileName(item));

                    SetNodeImage(item, ref node);

                    string[] files = Directory.GetFiles(item);
                    if (files.Length > 0) // has files?
                    {
                        GetTreeNode(ref node, files);
                    }

                    foreach (string dir in Directory.GetDirectories(item))
                    {
                        GetTreeNode(ref node, new string[] { dir });
                    }

                    if (node.Value != null || (node.Value == null && node.Nodes.Count > 0))
                    {
                        root.Nodes.Add(node);
                    }
                }
                else
                {
                    string name = Path.GetFileName(item);
                    if (IsAddableType(name))
                    {
                        WinUglifier.TreeView.TreeNode node = new WinUglifier.TreeView.TreeNode(item, name);

                        SetNodeImage(item, ref node);

                        root.Nodes.Add(node);
                    }
                }
            }
        }
예제 #2
0
파일: Main.cs 프로젝트: jongha/winuglifier
        private void treeItems_DragDrop(object sender, DragEventArgs e)
        {
            string[] items = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            WinUglifier.TreeView.TreeNode root = new WinUglifier.TreeView.TreeNode();

            GetTreeNode(ref root, items);

            List<WinUglifier.TreeView.TreeNode> nodes = new List<WinUglifier.TreeView.TreeNode>();
            foreach (WinUglifier.TreeView.TreeNode node in root.Nodes)
            {
                nodes.Add(node);
            }

            treeItems.Nodes.AddRange(nodes.ToArray());
            treeItems.ExpandAll();
        }