예제 #1
0
        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();
            }
        }
예제 #2
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));
        }
 public DirectoryTreeWatcher(DirectoryTree target, int side, string path, System.Windows.Threading.Dispatcher disp, ChangeHandler Change,
                             HashSet <string> fullTextExtensions,
                             PleaseWait initProgress)
 {
     this.target             = target;
     this.side               = side;
     this.path               = path;
     this.Change            += Change;
     this.disp               = disp;
     this.fullTextExtensions = fullTextExtensions;
     init(initProgress);
 }
예제 #4
0
        private void Tree_SelectedItemChanged(object sender, SelectionChangedEventArgs e)
        {
            var s = (sender as VTreeView.VTreeView).SelectedItem as DirectoryTree;

            SelectedFilePanel.IsEnabled = (s != null);
            if (s != null)
            {
                lastSelectedFile             = s;
                SelectedFileLabel.Text       = s.Path;
                SelectedFile_Open.IsEnabled  = s.LeftPresent;
                SelectedFile_Erase.IsEnabled = s.RightPresent;
                var f = s.IsFolder ? s : s.Parent;
                SelectedFile_ExploreLeft.IsEnabled  = f.LeftPresent;
                SelectedFile_ExploreRight.IsEnabled = f.RightPresent;
                SelectedFile_Save.IsEnabled         = false;
                if (!s.LeftPresent && !s.RightPresent)
                {
                    editDocument(null, true);
                }
                else if (s.RightPresent)
                {
                    editDocument(this.RightPath + "\\" + s.Path + (s.IsFolder?"\\":""), false);
                }
                else
                {
                    editDocument(this.LeftPath + "\\" + s.Path + (s.IsFolder ? "\\" : ""), true);
                    if (!s.IsFolder)
                    {
                        SelectedFile_Save.IsEnabled = true;
                    }
                }
                DirTree.ScrollIntoView(s);
            }
            else
            {
                if (!lastSelectedFile.IsSelected)
                {
                    lastSelectedFile = null;
                }
                //SelectedFileLabel.Text = "";
            }
        }
예제 #5
0
 private DirectoryTree(DirectoryTree parent, string fullname)
 {
     this.parent        = parent;
     this.fullname      = fullname;
     this.fullnamelower = fullname.ToLowerInvariant();
 }
예제 #6
0
        void renameTree(DirectoryTree node)
        {
            foreach (var c in node.Children)
            {
                renameTree(c as DirectoryTree);
            }

            if (node.FullName.EndsWith(".prop.xml"))
            {
                if (node.LeftPresent)
                {
                    foreach (var oldName in oldNames)
                    {
                        if (node.LeftContains(oldName))
                        {
                            if ((new RebuildPropertyFile(leftPath + node.Path)).Failed)
                            {
                                errors.Add(leftPath + node.Path);
                            }
                            break;
                        }
                    }
                }
                if (node.RightPresent)
                {
                    foreach (var oldName in oldNames)
                    {
                        if (node.RightContains(oldName))
                        {
                            if ((new RebuildPropertyFile(rightPath + node.Path)).Failed)
                            {
                                errors.Add(rightPath + node.Path);
                            }
                            break;
                        }
                    }
                }
            }

            try
            {
                var hash = NameRegistry.Files.toHash(node.BaseName);
                if (hashes.Contains(hash))
                {
                    string newPath = node.Parent.Path + "\\" +
                                     NameRegistry.Files.toName(hash);
                    string ext = node.FileType;
                    if (ext != "")
                    {
                        newPath += "." + ext;
                    }
                    if (newPath != node.Path)
                    {
                        if (node.LeftPresent)
                        {
                            System.IO.Directory.Move(leftPath + node.Path, leftPath + newPath);
                        }
                        if (node.RightPresent)
                        {
                            System.IO.Directory.Move(rightPath + node.Path, rightPath + newPath);
                        }
                    }
                }
            }
            catch (Exception)
            {
                if (node.LeftPresent)
                {
                    errors.Add(leftPath + node.Path);
                }
                if (node.RightPresent)
                {
                    errors.Add(rightPath + node.Path);
                }
            }
        }