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 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 = ""; } }