internal void RemoveAllLocalChilds()
        {
            for (int i = 0; i < m_files.Count;)
            {
                FSNodeFile fsnf = m_files.Values[i];
                if (!(fsnf is FSNodeVirtualFile))
                {
                    fsnf.RemoveSelf();
                }
                else
                {
                    i++;
                    if (m_tree != null)
                    {
                        m_tree.InvokeNodeFileIsVirtualChanged((FSNodeVirtualFile)fsnf);
                    }
                }
            }

            for (int i = 0; i < m_subdirs.Count;)
            {
                FSNodeDir fsnd = m_subdirs.Values[i];
                if (!fsnd.m_hasVirtual)
                {
                    fsnd.RemoveSelf();
                }
                else
                {
                    fsnd.RemoveAllLocalChilds();
                    i++;
                }
            }
            LocalCountZero();
        }
Exemple #2
0
 internal void InvokeNodeRemoved(FSNodeDir sender, FileTreeDirChangedEventArgs e)
 {
     if (NodeRemoved != null)
     {
         NodeRemoved(sender, e);
     }
 }
Exemple #3
0
 /// <summary>
 /// Shuts down the FileTree, freeing all resources.
 /// </summary>
 public void ShutDown()
 {
     m_watcher.EnableRaisingEvents = false;
     m_watcher.Dispose();
     m_shutDown.Set();
     m_rootNode = null;
 }
        void NodeAdded(FSNodeDir sender, FileTreeDirChangedEventArgs e)
        {
            TreeNode parent = m_trvFileTreeView.GetFileTreeNodeByPath(m_fileTrees[sender.Tree] + '\\' + e.Parent.GetPathInTree(), false);
            TreeNode tn;

            if (e.Child is FSNodeDir)
            {
                tn = ((FSNodeDir)e.Child).ConvertToTreeNode(m_noVirtual, m_noLocal, true, m_colorLocalFiles, m_colorLocalDirectories);
            }
            else
            {
                tn = ((FSNodeFile)e.Child).ConvertToTreeNode(true, m_colorLocalFiles);
            }
            if (tn == null || parent == null) // possible for virtual trees
            {
                return;
            }
            if (m_trvFileTreeView.InvokeRequired)
            {
                m_trvFileTreeView.Invoke(new TreeNodeAddInvoke(parent.Nodes.InsertNodeSorted), tn);
            }
            else
            {
                parent.Nodes.InsertNodeSorted(tn);
            }
        }
        public FSNode GetSubNodeByPath(string path)
        {
            FSNodeDir current = this;

            string[] nextDir = path.Split(s_splitter, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < nextDir.Length; i++)
            {
                if (current.m_subdirs.ContainsKey(nextDir[i]))
                {
                    if (i == nextDir.Length - 1)
                    {
                        return(current.m_subdirs[nextDir[i]]);
                    }
                    current = current.m_subdirs[nextDir[i]];
                }
                else if (i == nextDir.Length - 1)
                {
                    if (current.m_files.ContainsKey(nextDir[i]))
                    {
                        return(current.m_files[nextDir[i]]);
                    }
                }
                else
                {
                    break;
                }
            }
            return(null);
        }
        public FSNodeDir AddDirFromRelativePath(string[] parts, int startIndex = 0)
        {
            FSNodeDir current = this;

            for (int i = startIndex; i < parts.Length; i++)
            {
                current = new FSNodeDir(parts[i], m_tree, current);
            }
            return(current);
        }
Exemple #7
0
        public FileTree(string path)
        {
            if (!path.EndsWith('\\'))
            {
                path += '\\';
            }
            m_basePath = path;
            m_rootNode = new FSNodeDir(path, this);

            SetupWatcher(path);
            SetupConsumerThread();
        }
Exemple #8
0
        /// <summary>
        /// Constructs a new FileTree from the given path and SGAs.
        /// Set an EntryPoint name to only add files from SGAs which belong to an EntryPoint with the specified name.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sgas"></param>
        /// <param name="epName"></param>
        public FileTree(string path, IEnumerable <SGAFile> sgas, string epName = null)
        {
            if (!path.EndsWith('\\'))
            {
                path += '\\';
            }
            m_basePath = path;
            m_rootNode = new FSNodeDir(path, this);

            foreach (SGAFile sga in sgas)
            {
                foreach (SGAEntryPoint ep in sga)
                {
                    if (epName != null && string.Compare(ep.Name, epName, true) != 0)
                    {
                        continue;
                    }

                    foreach (SGAStoredDirectory sgasd in ep.StoredDirectories.Values)
                    {
                        string    dirpath = sgasd.GetPath();
                        FSNodeDir dirnode = m_rootNode.TryAddDirFromRelativePath(dirpath);
                        if (sgasd.StoredFiles.Values.Count > 0)
                        {
                            dirnode.HasVirtual = true;
                        }
                        foreach (SGAStoredFile sgasf in sgasd.StoredFiles.Values)
                        {
                            FSNodeFile file = dirnode.GetFile(sgasf.Name);
                            if (file == null)
                            {
                                new FSNodeVirtualFile(sgasf.Name, sgasf, this)
                                {
                                    Parent = dirnode
                                };
                            }
                            else if (!(file is FSNodeVirtualFile))
                            {
                                dirnode.RemoveChild(file);
                                new FSNodeVirtualFile(sgasf.Name, sgasf, this)
                                {
                                    Parent = dirnode
                                };
                            }
                        }
                    }
                }
            }

            SetupWatcher(path);
            SetupConsumerThread();
        }
Exemple #9
0
 protected FSNode(string name, FileTree tree, FSNodeDir parent = null)
 {
     m_name = name;
     m_tree = tree;
     if (parent != null)
     {
         Parent = parent;
     }
     else
     {
         m_parent = null;
     }
 }
        public void MergeWith(FSNodeDir node)
        {
            for (int i = 0; i < node.FilesList.Count; i++)
            {
                FSNodeFile fsnf = node.FilesList.Values[i];
                if (!ContainsFile(fsnf.Name))
                {
                    if (!HasLocalFile(fsnf.Name))
                    {
                        continue;
                    }
                    if (fsnf is FSNodeVirtualFile)
                    {
                        new FSNodeFile(fsnf.Name, m_tree, this);
                        if (m_tree != null)
                        {
                            m_tree.InvokeNodeFileIsVirtualChanged((FSNodeVirtualFile)node.m_files[fsnf.Name]);
                        }
                        node.LocalCountAdd(-1);
                    }
                    else
                    {
                        fsnf.Parent = this;
                        node.LocalCountAdd(-1);
                        i--;
                    }
                }
                else if (m_files[fsnf.Name] is FSNodeVirtualFile && m_files[fsnf.Name].HasLocal)
                {
                    if (m_tree != null)
                    {
                        m_tree.InvokeNodeFileIsVirtualChanged((FSNodeVirtualFile)m_files[fsnf.Name]);
                    }
                    LocalCountAdd(1);
                }
            }

            for (int i = 0; i < node.SubDirsList.Count; i++)
            {
                FSNodeDir fsnd = node.SubDirsList.Values[i];
                if (!ContainsDirectory(fsnd.Name))
                {
                    fsnd.Parent = this;
                    i--;
                }
                else
                {
                    m_subdirs[fsnd.m_name].MergeWith(fsnd);
                }
            }
        }
Exemple #11
0
        public FSNodeDir(string path, FSNodeDir parent)
            : base(path.SubstringAfterLast('\\'), parent.m_tree, parent)
        {
            IEnumerable<string> files = Directory.EnumerateFiles(path);
            IEnumerable<string> dirs = Directory.EnumerateDirectories(path);

            foreach (string file in files)
            {
                new FSNodeFile(file.SubstringAfterLast('\\'), m_tree, this);
            }

            foreach (string dir in dirs)
            {
                new FSNodeDir(dir, this);
            }
        }
        public override FSNode GClone()
        {
            var copy = new FSNodeDir(m_name, m_tree);

            foreach (FSNodeDir fsnd in m_subdirs.Values)
            {
                fsnd.GClone().Parent = copy;
            }

            foreach (FSNodeFile fsnf in m_files.Values)
            {
                fsnf.GClone().Parent = copy;
            }

            return(copy);
        }
        public FSNodeDir(string path, FSNodeDir parent)
            : base(path.SubstringAfterLast('\\'), parent.m_tree, parent)
        {
            IEnumerable <string> files = Directory.EnumerateFiles(path);
            IEnumerable <string> dirs  = Directory.EnumerateDirectories(path);

            foreach (string file in files)
            {
                new FSNodeFile(file.SubstringAfterLast('\\'), m_tree, this);
            }

            foreach (string dir in dirs)
            {
                new FSNodeDir(dir, this);
            }
        }
Exemple #14
0
        protected void TransferIntoTnc(Control owner, FSNodeDir parent, TreeNodeCollection collection, bool noVirtual, bool noLocal, bool usePictures,
                                       bool colorLocalFiles, bool colorLocalDirs)
        {
            foreach (FSNodeDir fsnd in parent.SubDirsList.Values)
            {
                if (noVirtual && !fsnd.HasLocal)
                {
                    continue;
                }
                if (noLocal && !fsnd.HasVirtual)
                {
                    continue;
                }
                TreeNode dir = fsnd.ConvertToTreeNode(noVirtual, noLocal, usePictures, colorLocalFiles, colorLocalDirs);
                if (owner.InvokeRequired)
                {
                    MethodInvoker k = () => collection.Add(dir);
                    owner.Invoke(k);
                }
                else
                {
                    collection.Add(dir);
                }
            }

            foreach (FSNodeFile fsnf in parent.FilesList.Values)
            {
                if (noVirtual && !fsnf.HasLocal)
                {
                    continue;
                }
                if (noLocal && !(fsnf is FSNodeVirtualFile))
                {
                    continue;
                }
                TreeNode file = fsnf.ConvertToTreeNode(usePictures, colorLocalFiles);
                if (owner.InvokeRequired)
                {
                    MethodInvoker k = () => collection.Add(file);
                    owner.Invoke(k);
                }
                else
                {
                    collection.Add(file);
                }
            }
        }
Exemple #15
0
 public void RemoveSelf(bool forceLocal = false)
 {
     if (forceLocal)
     {
         if (m_parent != null)
         {
             m_parent.RemoveChildIntern(this, true);
             m_parent = null;
             m_tree   = null;
         }
     }
     else
     {
         Parent = null;
     }
     ResetPath();
 }
        public FSNodeDir TryAddDirFromRelativePath(string[] parts)
        {
            FSNodeDir current = this;
            int       pos     = 0;

            while (true)
            {
                if (current.m_subdirs.ContainsKey(parts[pos]))
                {
                    current = current.m_subdirs[parts[pos]];
                    if (parts.Length - pos == 1)
                    {
                        return(current);
                    }
                    pos++;
                    continue;
                }
                return(current.AddDirFromRelativePath(parts, pos));
            }
        }
        public FSNodeDir GetSubDirByPath(string path)
        {
            string[]  nextDir = path.Split(s_splitter, StringSplitOptions.RemoveEmptyEntries);
            FSNodeDir current = this;

            for (int i = 0; i < nextDir.Length; i++)
            {
                if (current.m_subdirs.ContainsKey(nextDir[i]))
                {
                    if (i == nextDir.Length - 1)
                    {
                        return(current.m_subdirs[nextDir[i]]);
                    }
                    current = current.m_subdirs[nextDir[i]];
                    continue;
                }
                return(null);
            }
            return(null);
        }
        public FSNodeFile TryAddFileFromRelativePath(string path)
        {
            if (!File.Exists(m_tree.BasePath + path))
            {
                //throw new CopeException("The file you're trying to add does not exist! Base path: {0} ; relative path: {1}", _tree.BasePath, path);
                return(null);
            }
            string dirPath = path.SubstringBeforeLast('\\', true);

            FSNodeFile newFile;

            if (dirPath.Contains('\\'))
            {
                FSNodeDir direc    = TryAddDirFromRelativePath(dirPath);
                string    filename = path.SubstringAfterLast('\\');
                newFile = !direc.ContainsFile(filename) ? new FSNodeFile(path.SubstringAfterLast('\\'), m_tree, direc) : direc.m_files[filename];
                return(newFile);
            }
            newFile = new FSNodeFile(path.SubstringAfterLast('\\'), m_tree, this);
            return(newFile);
        }
        void NodeRemoved(FSNodeDir sender, FileTreeDirChangedEventArgs e)
        {
            TreeNode tn;

            if (e.Child is FSNodeDir)
            {
                tn = m_trvFileTreeView.GetFileTreeNodeByPath(m_fileTrees[sender.Tree] + '\\' + e.Child.GetPathInTree(), false);
                if (tn == null)
                {
                    return;
                }
                if (m_trvFileTreeView.InvokeRequired)
                {
                    m_trvFileTreeView.Invoke(new MethodInvoker(tn.Remove));
                }
                else
                {
                    tn.Remove();
                }
            }
            else
            {
                tn = m_trvFileTreeView.GetFileTreeNodeByPath(m_fileTrees[sender.Tree] + '\\' + e.Child.GetPathInTree());
                if (tn == null)
                {
                    return;
                }
                if (m_trvFileTreeView.InvokeRequired)
                {
                    m_trvFileTreeView.Invoke(new MethodInvoker(tn.Remove));
                }
                else
                {
                    tn.Remove();
                }
            }
        }
 public FSNodeFile(string name, FileTree tree, FSNodeDir parent = null)
     : base(name, tree, parent)
 {
 }
        private static void PasteNode(FSNode node, FSNodeDir into, string newName)
        {
            if (node == null || into == null)
                return;
            try
            {
                string dirPath = into.Path + '\\';

                if (File.Exists(dirPath + newName))
                {
                    string name = newName.SubstringBeforeLast('.');
                    string ext = newName.SubstringAfterLast('.', true);
                    int numOfThatKind = into.Directories.Count(d => d.Name.StartsWith(name + "_copy"));
                    numOfThatKind += into.Files.Count(d => d.Name.StartsWith(name + "_copy"));
                    if (numOfThatKind > 0)
                        PasteNode(node, into, name + "_copy_" + (numOfThatKind + 1) + ext);
                    else
                        PasteNode(node, into, name + "_copy" + ext);
                    return;
                }

                if (node is FSNodeVirtualFile)
                {
                    var virtualFile = node as FSNodeVirtualFile;
                    if (virtualFile.HasLocal)
                    {
                        if (!Directory.Exists(dirPath))
                            Directory.CreateDirectory(dirPath);
                        File.Copy(virtualFile.Path, dirPath + newName);
                    }
                    else
                        virtualFile.Extract(dirPath + newName);
                }
                else if (node is FSNodeFile)
                {
                    var file = node as FSNodeFile;
                    if (!Directory.Exists(dirPath))
                        Directory.CreateDirectory(dirPath);
                    File.Copy(file.Path, dirPath + newName);
                }
                else if (node is FSNodeDir)
                {
                    var dir = node as FSNodeDir;
                    if (!Directory.Exists(dirPath + newName))
                        Directory.CreateDirectory(dirPath + newName);

                    into = into.GetDirectory(newName);
                    foreach (var d in dir.Directories)
                        PasteNode(d, into, d.Name);
                    foreach (var f in dir.Files)
                        PasteNode(f, into, f.Name);
                }
            }
            catch (Exception ex)
            {
                 UIHelper.ShowError("Failed to paste: " + ex.Message);
            }
        }
Exemple #22
0
        /// <summary>
        /// Constructs a new FileTree from the given path and SGAs.
        /// Set an EntryPoint name to only add files from SGAs which belong to an EntryPoint with the specified name.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sgas"></param>
        /// <param name="epName"></param>
        public FileTree(string path, IEnumerable<SGAFile> sgas, string epName = null)
        {
            if (!path.EndsWith('\\'))
                path += '\\';
            m_basePath = path;
            m_rootNode = new FSNodeDir(path, this);

            foreach (SGAFile sga in sgas)
            {
                foreach (SGAEntryPoint ep in sga)
                {
                    if (epName != null && string.Compare(ep.Name, epName, true) != 0)
                        continue;

                    foreach (SGAStoredDirectory sgasd in ep.StoredDirectories.Values)
                    {
                        string dirpath = sgasd.GetPath();
                        FSNodeDir dirnode = m_rootNode.TryAddDirFromRelativePath(dirpath);
                        if (sgasd.StoredFiles.Values.Count > 0)
                            dirnode.HasVirtual = true;
                        foreach (SGAStoredFile sgasf in sgasd.StoredFiles.Values)
                        {
                            FSNodeFile file = dirnode.GetFile(sgasf.Name);
                            if (file == null)
                            {
                                new FSNodeVirtualFile(sgasf.Name, sgasf, this) {Parent = dirnode};
                            }
                            else if (!(file is FSNodeVirtualFile))
                            {
                                dirnode.RemoveChild(file);
                                new FSNodeVirtualFile(sgasf.Name, sgasf, this) {Parent = dirnode};
                            }
                        }
                    }
                }
            }

            SetupWatcher(path);
            SetupConsumerThread();
        }
Exemple #23
0
        private void ProcessEvent(FileSystemEventArgs e)
        {
            string relativePath;

            if (e.FullPath.StartsWith(m_basePath))
            {
                relativePath = e.FullPath.SubstringAfterFirst(m_basePath);
            }
            else
            {
                return;
            }
            try
            {
                switch (e.ChangeType)
                {
                case WatcherChangeTypes.Created:
                    if (Directory.Exists(e.FullPath))
                    {
                        FSNodeDir tmp = m_rootNode.GetSubDirByPath(relativePath);
                        if (tmp == null)
                        {
                            m_rootNode.TryAddDirFromRelativePath(relativePath);
                        }
                    }
                    else
                    {
                        FSNodeFile file = m_rootNode.TryAddFileFromRelativePath(relativePath);
                        if (file != null && file is FSNodeVirtualFile)
                        {
                            if (file.Parent != null)
                            {
                                file.Parent.LocalCountAdd(1);
                            }
                            InvokeNodeFileIsVirtualChanged((FSNodeVirtualFile)file);
                        }
                    }
                    break;

                case WatcherChangeTypes.Deleted:
                    FSNode tmp2 = m_rootNode.GetSubNodeByPath(relativePath);
                    if (tmp2 == null)
                    {
                        return;
                    }
                    if (tmp2 is FSNodeDir)
                    {
                        if (!((FSNodeDir)tmp2).HasVirtual)
                        {
                            tmp2.RemoveSelf(true);
                        }
                        else
                        {
                            ((FSNodeDir)tmp2).RemoveAllLocalChilds();
                        }
                        return;
                    }
                    if (tmp2 is FSNodeVirtualFile)
                    {
                        if (tmp2.Parent != null)
                        {
                            tmp2.Parent.LocalCountAdd(-1);
                        }
                        InvokeNodeFileIsVirtualChanged((FSNodeVirtualFile)tmp2);
                        return;
                    }
                    tmp2.RemoveSelf(true);
                    break;

                case WatcherChangeTypes.Renamed:
                    relativePath = ((RenamedEventArgs)e).OldFullPath.SubstringAfterFirst(m_basePath);
                    FSNode file2 = m_rootNode.GetSubNodeByPath(relativePath);
                    file2.Name = e.Name.SubstringAfterLast('\\');
                    break;
                }
            }
            catch (ObjectDisposedException)
            {
            }
        }
Exemple #24
0
 internal void InvokeNodeRemoved(FSNodeDir sender, FileTreeDirChangedEventArgs e)
 {
     if (NodeRemoved != null)
         NodeRemoved(sender, e);
 }
Exemple #25
0
 /// <summary>
 /// Shuts down the FileTree, freeing all resources.
 /// </summary>
 public void ShutDown()
 {
     m_watcher.EnableRaisingEvents = false;
     m_watcher.Dispose();
     m_shutDown.Set();
     m_rootNode = null;
 }
Exemple #26
0
        public override FSNode GClone()
        {
            var copy = new FSNodeDir(m_name, m_tree);

            foreach (FSNodeDir fsnd in m_subdirs.Values)
            {
                fsnd.GClone().Parent = copy;
            }

            foreach (FSNodeFile fsnf in m_files.Values)
            {
                fsnf.GClone().Parent = copy;
            }

            return copy;
        }
 public FSNodeDir(string name, FileTree tree, FSNodeDir parent = null)
     : base(name)
 {
     m_tree = tree;
     Parent = parent;
 }
 /// <summary>
 /// Creates a new RBFCrawler that call the specified delegate for every RBF and starts at a given directory.
 /// </summary>
 /// <param name="foreachRBF">This delegate is called for every RBF.</param>
 /// <param name="startNode">The crawler will begin searching for RBF files from this node.</param>
 public RBFCrawler(CrawlerCallback foreachRBF, FSNodeDir startNode)
     : this(foreachRBF, startNode, null)
 {
 }
        /// <summary>
        /// Creates a new RBFCrawler that call the specified delegate for every RBF and starts at a given directory.
        /// </summary>
        /// <param name="foreachRBF">This delegate is called for every RBF.</param>
        /// <param name="startNode">The crawler will begin searching for RBF files from this node.</param>
        /// <param name="advanceProgressCallback">Called everytime a file has been processed.</param>
        /// <exception cref="ArgumentNullException"><paramref name="foreachRBF" /> is <c>null</c>.</exception>
        public RBFCrawler(CrawlerCallback foreachRBF, FSNodeDir startNode, Action advanceProgressCallback)
        {
            if (foreachRBF == null) throw new ArgumentNullException("foreachRBF");
            if (startNode == null) throw new ArgumentNullException("startNode");

            m_foreachRBF = foreachRBF;
            m_startNode = startNode;
            m_advanceProgressCallback = advanceProgressCallback;
            UseDedicatedThread = true;
        }
        private void Visit(FSNodeDir startDir)
        {
            if (m_stopSearch.WaitOne(0))
                return;

            foreach (FSNodeFile file in startDir.Files)
            {
                if (m_stopSearch.WaitOne(0))
                    return;
                if (file.Name.EndsWith(".rbf"))
                {
                    UniFile uni = file.GetUniFile();
                    RelicBinaryFile rbf;
                    try
                    {
                        rbf = new RelicBinaryFile(uni)
                        {
                            KeyProvider = ModManager.RBFKeyProvider,
                            UseKeyProvider = RBFSettings.UseKeyProviderForLoading
                        };
                        rbf.ReadData();
                    }
                    catch (Exception ex)
                    {
                        if (OnFileOpenFailed != null)
                            OnFileOpenFailed(ex);
                        if (m_advanceProgressCallback != null)
                            m_advanceProgressCallback.Invoke();
                        continue;
                    }

                    m_foreachRBF.Invoke(rbf.AttributeStructure, file.PathInTree);
                }
                if (m_advanceProgressCallback != null)
                    m_advanceProgressCallback.Invoke();
            }

            foreach (FSNodeDir dir in startDir.Directories)
            {
                if (m_stopSearch.WaitOne(0))
                    return;
                Visit(dir);
            }
        }
Exemple #31
0
        public void MergeWith(FSNodeDir node)
        {
            for (int i = 0; i < node.FilesList.Count; i++)
            {
                FSNodeFile fsnf = node.FilesList.Values[i];
                if (!ContainsFile(fsnf.Name))
                {
                    if (!HasLocalFile(fsnf.Name))
                        continue;
                    if (fsnf is FSNodeVirtualFile)
                    {
                        new FSNodeFile(fsnf.Name, m_tree, this);
                        if (m_tree != null)
                            m_tree.InvokeNodeFileIsVirtualChanged((FSNodeVirtualFile) node.m_files[fsnf.Name]);
                        node.LocalCountAdd(-1);
                    }
                    else
                    {
                        fsnf.Parent = this;
                        node.LocalCountAdd(-1);
                        i--;
                    }
                }
                else if (m_files[fsnf.Name] is FSNodeVirtualFile && m_files[fsnf.Name].HasLocal)
                {
                    if (m_tree != null)
                        m_tree.InvokeNodeFileIsVirtualChanged((FSNodeVirtualFile) m_files[fsnf.Name]);
                    LocalCountAdd(1);
                }
            }

            for (int i = 0; i < node.SubDirsList.Count; i++)
            {
                FSNodeDir fsnd = node.SubDirsList.Values[i];
                if (!ContainsDirectory(fsnd.Name))
                {
                    fsnd.Parent = this;
                    i--;
                }
                else
                    m_subdirs[fsnd.m_name].MergeWith(fsnd);
            }
        }
Exemple #32
0
 public FileTreeDirChangedEventArgs(FSNodeDir parent, FSNode child, FileTreeActions action)
 {
     Parent = parent;
     Child  = child;
     Action = action;
 }
 void NodeAdded(FSNodeDir sender, FileTreeDirChangedEventArgs e)
 {
     TreeNode parent = m_trvFileTreeView.GetFileTreeNodeByPath(m_fileTrees[sender.Tree] + '\\' + e.Parent.GetPathInTree(), false);
     TreeNode tn;
     if (e.Child is FSNodeDir)
     {
         tn = ((FSNodeDir)e.Child).ConvertToTreeNode(m_noVirtual, m_noLocal, true, m_colorLocalFiles, m_colorLocalDirectories);
     }
     else
     {
         tn = ((FSNodeFile)e.Child).ConvertToTreeNode(true, m_colorLocalFiles);
     }
     if (tn == null || parent == null) // possible for virtual trees
         return;
     if (m_trvFileTreeView.InvokeRequired)
         m_trvFileTreeView.Invoke(new TreeNodeAddInvoke(parent.Nodes.InsertNodeSorted), tn);
     else
         parent.Nodes.InsertNodeSorted(tn);
 }
Exemple #34
0
 public bool ContainsDirectory(FSNodeDir dir)
 {
     return m_subdirs.ContainsValue(dir);
 }
 void NodeRemoved(FSNodeDir sender, FileTreeDirChangedEventArgs e)
 {
     TreeNode tn;
     if (e.Child is FSNodeDir)
     {
         tn = m_trvFileTreeView.GetFileTreeNodeByPath(m_fileTrees[sender.Tree] + '\\' + e.Child.GetPathInTree(), false);
         if (tn == null)
             return;
         if (m_trvFileTreeView.InvokeRequired)
             m_trvFileTreeView.Invoke(new MethodInvoker(tn.Remove));
         else
             tn.Remove();
     }
     else
     {
         tn = m_trvFileTreeView.GetFileTreeNodeByPath(m_fileTrees[sender.Tree] + '\\' + e.Child.GetPathInTree());
         if (tn == null)
             return;
         if (m_trvFileTreeView.InvokeRequired)
             m_trvFileTreeView.Invoke(new MethodInvoker(tn.Remove));
         else
             tn.Remove();
     }
 }
Exemple #36
0
        public FSNodeDir AddDirFromRelativePath(string[] parts, int startIndex = 0)
        {
            FSNodeDir current = this;

            for (int i = startIndex; i < parts.Length; i++)
            {
                current = new FSNodeDir(parts[i], m_tree, current);
            }
            return current;
        }
Exemple #37
0
        public FileTree(string path)
        {
            if (!path.EndsWith('\\'))
                path += '\\';
            m_basePath = path;
            m_rootNode = new FSNodeDir(path, this);

            SetupWatcher(path);
            SetupConsumerThread();
        }
 public FSNodeFile(string name, FileTree tree, FSNodeDir parent = null)
     : base(name, tree, parent)
 {
 }
Exemple #39
0
        protected void TransferIntoTnc(Control owner, FSNodeDir parent, TreeNodeCollection collection, bool noVirtual, bool noLocal, bool usePictures,
                                       bool colorLocalFiles, bool colorLocalDirs)
        {
            foreach (FSNodeDir fsnd in parent.SubDirsList.Values)
            {
                if (noVirtual && !fsnd.HasLocal)
                    continue;
                if (noLocal && !fsnd.HasVirtual)
                    continue;
                TreeNode dir = fsnd.ConvertToTreeNode(noVirtual, noLocal, usePictures, colorLocalFiles, colorLocalDirs);
                if (owner.InvokeRequired)
                {
                    MethodInvoker k = () => collection.Add(dir);
                    owner.Invoke(k);
                }
                else
                    collection.Add(dir);
            }

            foreach (FSNodeFile fsnf in parent.FilesList.Values)
            {
                if (noVirtual && !fsnf.HasLocal)
                    continue;
                if (noLocal && !(fsnf is FSNodeVirtualFile))
                    continue;
                TreeNode file = fsnf.ConvertToTreeNode(usePictures, colorLocalFiles);
                if (owner.InvokeRequired)
                {
                    MethodInvoker k = () => collection.Add(file);
                    owner.Invoke(k);
                }
                else
                    collection.Add(file);
            }
        }
 public bool ContainsDirectory(FSNodeDir dir)
 {
     return(m_subdirs.ContainsValue(dir));
 }
Exemple #41
0
 public FileTreeDirChangedEventArgs(FSNodeDir parent, FSNode child, FileTreeActions action)
 {
     Parent = parent;
     Child = child;
     Action = action;
 }
 public FSNodeVirtualFile(string name, SGAStoredFile sgasf, FileTree tree, FSNodeDir parent = null)
     : base(name, tree, parent)
 {
     m_virtual = sgasf;
 }
 public FSNodeVirtualFile(string name, SGAStoredFile sgasf, FileTree tree, FSNodeDir parent = null)
     : base(name, tree, parent)
 {
     m_virtual = sgasf;
 }
Exemple #44
0
 public FSNodeDir(string name, FileTree tree, FSNodeDir parent = null)
     : base(name)
 {
     m_tree = tree;
     Parent = parent;
 }