private void context_AddFiles_Click(object sender, RoutedEventArgs e) { AnnoModificationManager4.Misc.OpenFileDialog openFileDialog = new AnnoModificationManager4.Misc.OpenFileDialog(); openFileDialog.Filter = "All files|*.*"; openFileDialog.Multiselect = true; bool?nullable = openFileDialog.ShowDialog(); if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) == 0) { return; } foreach (string file in openFileDialog.FileNames) { string generatedRDAFileName = RDAFile.FileNameToRDAFileName(file, Folder.FullPath); RDAFile rdafile = Folder.Files.Find(f => f.FileName == generatedRDAFileName); if (rdafile == null) { RDAFile rdaFile = RDAFile.Create(Folder.Version, file, Folder.FullPath); if (rdaFile != null) { Folder.Files.Add(rdaFile); } } else { RDAFileExtension.SetFile(rdafile, file, true); } } UpdateSubItems(); }
private void context_AddFolderAsRoot_Click(object sender, RoutedEventArgs e) { FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() != DialogResult.OK) { return; } List <RDAFile> files = new List <RDAFile>(); foreach (string str in Directory.GetFiles(folderBrowserDialog.SelectedPath, "*", SearchOption.AllDirectories)) { string folderpath = (Folder.FullPath + "\\" + Path.GetDirectoryName(str).Replace(folderBrowserDialog.SelectedPath, "")).Trim('\\'); string rdaDestFile = RDAFile.FileNameToRDAFileName(str, folderpath); RDAFile rdafile = Folder.GetAllFiles().Find((Predicate <RDAFile>)(f => f.FileName == rdaDestFile)); if (rdafile == null) { RDAFile rdaFile = RDAFile.Create(Folder.Version, str, folderpath); if (rdaFile != null) { files.Add(rdaFile); } } else { RDAFileExtension.SetFile(rdafile, str, true); } } Folder.AddFiles(files); UpdateSubItems(); }
private void context_AddFolderAsRoot_Click(object sender, RoutedEventArgs e) { FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } List <RDAFile> files = new List <RDAFile>(); foreach (string str in Directory.GetFiles(folderBrowserDialog.SelectedPath, "*", System.IO.SearchOption.AllDirectories)) { string folderpath = (CurrentReader.rdaFolder.FullPath + "\\" + Path.GetDirectoryName(str).Replace(folderBrowserDialog.SelectedPath, "")).Trim('\\'); string rdaDestFile = RDAFile.FileNameToRDAFileName(str, folderpath); RDAFile rdafile = CurrentReader.rdaFolder.GetAllFiles().Find(f => f.FileName == rdaDestFile); if (rdafile == null) { RDAFile rdaFile = RDAFile.Create(CurrentReader.rdaFolder.Version, str, folderpath); if (rdaFile != null) { files.Add(rdaFile); } } else { Misc.RDAFileExtension.SetFile(rdafile, str, true); } } CurrentReader.rdaFolder.AddFiles(files); RebuildTreeView(); }