예제 #1
0
        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);
        }
예제 #2
0
        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";
                }
            }
        }
예제 #3
0
 //Other
 private void UpdateTreeView(MFSDirectory dir)
 {
     ListViewItem[] items;
     listView.Items.Clear();
     if (Program.GetAllFilesFromDirectory(dir, out items))
     {
         listView.Items.AddRange(items);
     }
 }
예제 #4
0
 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);
 }
예제 #5
0
        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);
        }
예제 #6
0
        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));
        }
예제 #7
0
 private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     current_dir = (MFSDirectory)e.Node.Tag;
     UpdateTreeView(current_dir);
 }