private void FileDrop(object sender, DragEventArgs e) { String[] FileTypes = new String[] { ".gb", ".gbc", ".bin" }; String[] Files = (String[])e.Data.GetData(DataFormats.FileDrop); List <ROM> ROMsToAdd = new List <ROM>(); foreach (String FileToProcess in Files) { if (File.Exists(FileToProcess) && FileTypes.Contains(Path.GetExtension(FileToProcess))) { Byte[] temp = new Byte[15], temp1 = new Byte[0x10]; using (FileStream Reader = new FileStream(FileToProcess, FileMode.Open, FileAccess.Read)) { Reader.Position = 0x134; //ROM ASCII title Reader.Read(temp, 0, 15); //Info entry header for Menu Reader.Position = 0x1C000; Reader.Read(temp1, 0, 0x10); if (Encoding.ASCII.GetString(temp) == "NP M-MENU MENU" && temp1.SequenceEqual(new Byte[] { 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x44, 0x4D, 0x47, 0x20, 0x2D, 0x4D, 0x45, 0x4E, 0x55 })) { ROMsToAdd.AddRange(Processing.ParseGBMBinary(FileToProcess)); } else if (Path.GetExtension(FileToProcess) != ".bin") { using (MemoryStream Mem = new MemoryStream()) { Reader.Position = 0; Reader.CopyTo(Mem);; ROMsToAdd.Add(Processing.ParseROM(Mem, FileToProcess)); } } } } } foreach (ROM R in ROMsToAdd) { TitleEntry ROMTitle = new TitleEntry(R.ASCIITitle); if (ROMTitle.ShowDialog() == DialogResult.OK) { R.Title = ROMTitle.Title; } else { return; } AddROMToInterface(R); } }
private void ImportButtonClick(object sender, EventArgs e) { using (OpenFileDialog ImportMenu = new OpenFileDialog()) { ImportMenu.Filter = "1024kB GBM binary|*.gb;*.gbc;*.bin"; ImportMenu.Multiselect = true; if (ImportMenu.ShowDialog() == DialogResult.OK) { List <ROM> ROMsToAdd = new List <ROM>(); foreach (String BinaryFile in ImportMenu.FileNames) { if (!File.Exists(BinaryFile)) { continue; } if (new FileInfo(BinaryFile).Length / 1024 != 1024) { MessageBox.Show(String.Format("GBM binary {1}{0}{1} has to be 1024kByte in size!", Path.GetFileName(BinaryFile), '"'), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } ROMsToAdd.AddRange(Processing.ParseGBMBinary(BinaryFile)); } foreach (ROM R in ROMsToAdd) { TitleEntry ROMTitle = new TitleEntry(R.ASCIITitle); if (ROMTitle.ShowDialog() == DialogResult.OK) { R.Title = ROMTitle.Title; } else { return; } AddROMToInterface(R); } } } }