public static bool GetAllFilesFromDirectory(MFSDirectory dir, out ListViewItem[] items) { List <ListViewItem> list = new List <ListViewItem>(); if (disk == null || disk.Format == MFS.DiskFormat.Invalid) { items = null; return(false); } foreach (MFSFile file in MFSRAMUtil.GetAllFilesFromDirID(disk, dir.DirectoryID)) { ListViewItem item = new ListViewItem(file.Name + (file.Ext != "" ? "." + file.Ext : "")); item.Tag = file; item.ImageIndex = mainform.imageListLarge.Images.IndexOfKey(file.Ext); if (item.ImageIndex == -1) { item.ImageIndex = 0; } list.Add(item); } items = list.ToArray(); return(true); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofs = new OpenFileDialog(); ofs.Filter = "All Supported Files (*.ndd, *.ndr, *.ram)|*.ndd;*.ndr;*.ram|64DD RAM Area Image (*.ram)|*.ram|64DD Disk Image (*.ndd, *.ndr)|*.ndd;*.ndr|All files|*.*"; ofs.Title = "Open Disk Image..."; ofs.Multiselect = false; if (ofs.ShowDialog() == DialogResult.OK) { treeView.Nodes.Clear(); listView.Items.Clear(); if (Program.LoadDisk(ofs.FileName)) { TreeNode node; if (Program.GetDirectoryNode(out node)) { treeView.Nodes.Add(node); treeView.Nodes[0].Expand(); treeView.SelectedNode = treeView.Nodes[0]; } current_dir = null; clipboardfiles = null; this.Text = "64DD MFS Manager - [" + Program.GetDiskFilename() + "]"; } else { MessageBox.Show("Could not load " + ofs.SafeFileName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); current_dir = null; clipboardfiles = null; this.Text = "64DD MFS Manager"; } } }
//Other private void UpdateTreeView(MFSDirectory dir) { ListViewItem[] items; listView.Items.Clear(); if (Program.GetAllFilesFromDirectory(dir, out items)) { listView.Items.AddRange(items); } }
public static bool AddFilesToDirectory(MFSDirectory dir, string[] filepaths) { foreach (string file in filepaths) { if (Program.AddFileToDirectory(dir, file) == false) { MessageBox.Show("Could not import " + Path.GetFileName(file) + "\nCancelling file import.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } return(true); }
static TreeNode GetDirectoryTreeNode(MFSDirectory pdir) { TreeNode node = new TreeNode(pdir.Name); node.Tag = pdir; node.ImageIndex = GetContainerColor(pdir.Name); node.SelectedImageIndex = node.ImageIndex; foreach (MFSDirectory dir in MFSRAMUtil.GetAllDirectoriesFromDirID(disk, pdir.DirectoryID)) { node.Nodes.Add(GetDirectoryTreeNode(dir)); } return(node); }
public static bool AddFileToDirectory(MFSDirectory dir, string filepath) { if (disk == null || disk.Format == MFS.DiskFormat.Invalid) { return(false); } FileStream file = new FileStream(filepath, FileMode.Open); byte[] filedata = new byte[file.Length]; file.Read(filedata, 0, (int)file.Length); file.Close(); return(MFSRAMUtil.WriteFile(disk, filedata, Path.GetFileName(filepath), dir.DirectoryID)); }
private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { current_dir = (MFSDirectory)e.Node.Tag; UpdateTreeView(current_dir); }