private void MenuItem_Click(object sender, RoutedEventArgs e) { var dialog = new System.Windows.Forms.FolderBrowserDialog(); System.Windows.Forms.DialogResult result = dialog.ShowDialog(); // Get the selected file name and display in a TextBox if (result == System.Windows.Forms.DialogResult.OK) { String dirPath = dialog.SelectedPath; string[] files = Directory.GetFiles(dirPath); var rootItem = new TreeViewItem(); rootItem.Header = Path.GetFileName(dirPath); int numFiles = 0; foreach (string f in files) { if (Path.GetExtension(f).Equals(".RRM")) { FileEntry file = new RRMImage(f); numFiles++; rootItem.Items.Add(file); } } if (numFiles > 0) { fileTreeView.Items.Add(rootItem); } } }
private void FileTreeViewSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { var tree = sender as TreeView; if (tree.SelectedItem is TreeViewItem) { var item = tree.SelectedItem as TreeViewItem; //MessageBox.Show("sdadas:" + tree.SelectedItem); } else if (tree.SelectedItem is string) { //MessageBox.Show(tree.SelectedItem.ToString()); } else if (tree.SelectedItem is FileEntry) { fileNameTextBlock.Text = (tree.SelectedItem as FileEntry).FileName.ToString(); offsetTextBlock.Text = (tree.SelectedItem as FileEntry).FileOffset.ToString(); FileEntry f = (FileEntry)tree.SelectedItem; var ext = Path.GetExtension(f.FileName); if (ext.Equals(".LBV")) { LBVImage image = new LBVImage(resource.GetFile(f.ResourceIdx), f.FileName, resource.FileName); showImage(image); } else if (ext.Equals(".RRM")) { RRMImage image = (RRMImage)tree.SelectedItem; showImage(image); } else if (ext.Equals(".BG")) { Console.Out.WriteLine("Trying to display BD image from The Last Express..."); var image = new BGImage(resource.GetFile(f.ResourceIdx), f.FileName, resource.FileName); showImage(image); } } }