Beispiel #1
0
        public DirectoryTree getFile(string relativePath, bool create)
        {
            if (relativePath == "")
            {
                return(this);
            }
            var    pathSplit = relativePath.Split(new char[] { '\\' }, 2);
            string pathNext = pathSplit[0], pathRest = pathSplit.Length == 2 ? pathSplit[1] : "";

            DirectoryTree t;

            if (children.TryGetValue(pathNext, out t))
            {
                return(t.getFile(pathRest, create));
            }

            if (!create)
            {
                return(null);
            }

            t = new DirectoryTree(this, pathNext);
            if (pathRest != "")
            {
                t.children = new SortedList <string, DirectoryTree>(new ChildComparer());  //< This is a folder node!
            }
            children.Add(pathNext, t);

            return(t.getFile(pathRest, create));
        }
        void update()
        {
            files.Search(new SearchSpec(FileSearch.Text));
            if (ShowRightOnly.IsChecked == true)
            {
                files.SearchRightPresent();
            }
            DirTree.Data.ClearAll();
            DirTree.Data.AddRootItem(files);
            if (IsVisible)
            {
                if (lastSelectedFile != null && lastSelectedFile.Parent != null &&
                    !lastSelectedFile.LeftPresent && !lastSelectedFile.RightPresent)
                {
                    // File has been deleted or renamed.  Check for renaming
                    UInt32 instance = NameRegistry.Files.toHash(lastSelectedFile.BaseName);
                    UInt32 group    = NameRegistry.Groups.toHash(lastSelectedFile.Parent.Path);
                    UInt32 ext      = NameRegistry.Types.toHash(lastSelectedFile.FileType);
                    string newpath  = NameRegistry.Groups.toName(group) + "\\" + NameRegistry.Files.toName(instance) + "." + NameRegistry.Types.toName(ext);
                    lastSelectedFile = files.getFile(newpath, false);
                }
                DirTree.SelectedItem = lastSelectedFile;
                if (DirTree.SelectedItem != null)
                {
                    DirTree.ScrollIntoView(DirTree.SelectedItem);
                }

                /*if (editing != null && DirTree.SelectedItem != null &&
                 *  editing == RightPath + "\\" + (DirTree.SelectedItem as DirectoryTree).Path)
                 * {
                 *  if (System.IO.File.GetLastWriteTimeUtc(editing) >
                 * }*/
                updateEditorSearch();
            }
        }
        private void updateFile(string relativePath, int isNewFile)
        {
            if (relativePath.EndsWith(".search_index"))
            {
                return;
            }
            var n = target.getFile(relativePath, isNewFile > 0);

            if (n == null)
            {
                return;
            }

            if (n.IsFolder)
            {
                if (isNewFile < 0)
                {
                    n.decPresent(side);
                }
            }
            else
            {
                if (isNewFile > 0)
                {
                    n.incPresent(side);
                }
                if (isNewFile < 0)
                {
                    n.decPresent(side);
                }
                if (isNewFile >= 0 && !n.IsFolder && fullTextExtensions.Contains(n.FileType))
                {
                    n.LoadFullText(side, path + "\\" + relativePath);
                }
            }
        }