Esempio n. 1
0
        private void Initialize()
        {
            this.TargetProjectChanged += this.ExplorerTreeWindow_TargetProjectChanged;
            this.SelectedNodeChanged  += this.LibraryExplorerTree_SelectedNodeChanged;

            this.m_LibraryRootNode = new ApplicationFolderTreeNode("Librarys");
            this.m_FileRootNode    = new ApplicationFolderTreeNode("Files");

            this.treeView1.Nodes.Add(this.m_LibraryRootNode);
            this.treeView1.Nodes.Add(this.m_FileRootNode);
        }
Esempio n. 2
0
        private void treeView1_AfterExpand(object sender, TreeViewEventArgs e)
        {
            ExplorerTreeNode node = (ExplorerTreeNode)e.Node;
            int imageIndex        = IMG_UNKNOWN_DOCUMENT;

            switch (node.NodeType)
            {
            case ExplorerTreeNodeType.LibraryFolder:
            case ExplorerTreeNodeType.ApplicationFolder:
                imageIndex = IMG_CLOSE_FODLER;
                break;
            }
            node.ImageIndex = node.SelectedImageIndex = imageIndex;
        }
Esempio n. 3
0
 private ExplorerTreeNode FindNode(ExplorerTreeNode node, Predicate <ExplorerTreeNode> predicate)
 {
     if (predicate(node))
     {
         return(node);
     }
     foreach (ExplorerTreeNode child in node.Nodes)
     {
         ExplorerTreeNode child1 = this.FindNode(child, predicate);
         if (child1 != null)
         {
             return(child1);
         }
     }
     return(null);
 }
Esempio n. 4
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ExplorerTreeNode node = (ExplorerTreeNode)e.Node;

            switch (node.NodeType)
            {
            case ExplorerTreeNodeType.LibraryFolder:
                this.SelectedNode = node;
                break;

            case ExplorerTreeNodeType.OfficeFile:
                this.SelectedNode = node;
                break;

            default:
                this.SelectedNode = null;
                break;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// フォルダを巡回して、ノードを作成する。
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="library"></param>
        /// <param name="folder"></param>
        private void EnumerateFolder(ExplorerTreeNode parent, Library library, LibraryFolder folder)
        {
            //NOTE:parentはLibraryRootNodeも含めるため、ExplorerTreeNodeで宣言する
            string name = Path.GetFileName(folder.Path);
            //指定されたフォルダに対応するノードの存在有無を確認し、無ければ追加する。
            LibraryFolderTreeNode node = parent.Nodes.Cast <LibraryFolderTreeNode>().FirstOrDefault(x => x.LibraryFolder?.Path == folder.Path);

            if (node == null)
            {
                node = new LibraryFolderTreeNode(folder);
                parent.Nodes.Add(node);
            }


            //子ノードに不要なノードがないかの確認
            //NOTE:RootNodeにはこのチェックは不要のため、子ノードからスタートしている
            List <LibraryFolderTreeNode> cloneList = node.Nodes.Cast <LibraryFolderTreeNode>().ToList();

            cloneList.Where(child => library.Find(X => X.Path == child.LibraryFolder?.Path) == null).ToList()
            .ForEach(child => node.Nodes.Remove(child));

            //for (int i = node.Nodes.Count - 1; i >= 0; i--) {
            //    LibraryFolderTreeNode child = (LibraryFolderTreeNode)node.Nodes[i];
            //    LibraryFolder childFolder = library.Find(x => x.Path == child.LibraryFolder?.Path);
            //    if (childFolder == null) {
            //        node.Nodes.Remove(child);
            //    }
            //}


            //サブフォルダに対して再帰処理
            foreach (string subDirectory in Directory.GetDirectories(folder.Path))
            {
                LibraryFolder subFolder = library.Find(x => x.Path == subDirectory);
                this.EnumerateFolder(node, library, subFolder);
            }
        }