private TreeNode AddFileToTree(ScanType scanType, FileInfo fileInfo, string fullname) { TreeNode newNode; switch (scanType) { case ScanType.Disk: newNode = parent.AddDiskToTree(fileInfo, fullname); break; case ScanType.Tape: newNode = parent.AddTapeToTree(fileInfo, fullname); break; case ScanType.ROM: newNode = parent.AddRomToTree(fileInfo, fullname); break; default: newNode = parent.AddOtherFileToTree(fileInfo, fullname); break; } return(newNode); }
// Drag and Drop options // 1. Tape to Tape // 2. Tape to Disk // 3. Disk to Disk // 4. Disk to Tape private void CopyTapeFilesToTape(TreeNode sourceTreeNode, TreeNode destinationTreeNode) { // Retrieve details of the destination Tape TapeInfo destinationTapeInfo = (TapeInfo)destinationTreeNode.Tag; OricTape destinationTape = new OricTape(); destinationTape.TapeName = destinationTapeInfo.FullName;// Path.Combine(destinationTapeInfo.Folder, destinationTapeInfo.Name); // Copy a file from a Tape if (sourceTreeNode.Tag.GetType() == typeof(OricFileInfo)) { // Retrieve program information from the source node OricFileInfo programInfo = (OricFileInfo)sourceTreeNode.Tag; // Load the program contents from the source tape OricTape sourceTape = new OricTape(); OricProgram oricProgram = sourceTape.Load(Path.Combine(programInfo.Folder, programInfo.ParentName), programInfo.ProgramName, programInfo.ProgramIndex); // Copy file to the end of the destination tape destinationTape.SaveFile(oricProgram); } // Copy a whole Tape else if (sourceTreeNode.Tag.GetType() == typeof(TapeInfo)) { // Retrieve information about the source Tape TapeInfo sourceTapeInfo = (TapeInfo)sourceTreeNode.Tag; OricTape sourceTape = new OricTape(); sourceTape.TapeName = sourceTapeInfo.FullName;// Path.Combine(sourceTapeInfo.Folder, sourceTapeInfo.Name); FileInfo fiTapeFile = new FileInfo(sourceTape.TapeName); // Retrieve a catalog of all the programs on the source Tape OricFileInfo[] tapeCatalog = sourceTape.Catalog(fiTapeFile); foreach (OricFileInfo programInfo in tapeCatalog) { // Load the program contents from the source tape OricProgram oricProgram = new OricProgram(); oricProgram = sourceTape.Load(Path.Combine(programInfo.Folder, programInfo.ParentName), programInfo.ProgramName, programInfo.ProgramIndex); // Copy file to the end of the destination tape destinationTape.SaveFile(oricProgram); } } // Get full pathname of the updated destination Tape FileInfo fiTape = new FileInfo(Path.Combine(Path.GetDirectoryName(destinationTapeInfo.FullName), destinationTreeNode.Text)); // Remove destination Tape from Tree list destinationTreeNode.Remove(); // Add the updated Tape to the Tree list and display the files in the Tape TreeNode newTreeNode = mMainForm.AddTapeToTree(fiTape); newTreeNode.Expand(); }
public void GetListOfTapes() { filesScanned = 0; foreach (string directory in Configuration.Persistent.TapeFolders) { DirectoryInfo tapeDirectoryInfo = new DirectoryInfo(directory); // Get list of Tape files if (tapeDirectoryInfo.Exists) { FileInfo[] tapeFileInfo = tapeDirectoryInfo.GetFiles("*.ta*", SearchOption.AllDirectories); if (tapeFileInfo != null) { foreach (FileInfo fileInfo in tapeFileInfo) { lblInfo.Text = "Scanning folders for Tape files..."; lblFile.Text = fileInfo.FullName; // Add the tape to the tree if (parent.AddTapeToTree(fileInfo) != null) { tapesFound++; } else { filesSkipped++; tapesSkipped++; } filesScanned++; float percentage = (100 / (float)tapeFileInfo.Length) * filesScanned; pbProgress.PercentageValue = (int)percentage; pbProgress.Text = string.Format("Processing {0:N0} of {1:N0}", filesScanned, tapeFileInfo.Length); Application.DoEvents(); } } } } }