private void ConvertButton_Click(Button button, RomConverter.RomFormat format) { using (RomConverter romConverter = new RomConverter(romFileName)) { using (SaveFileDialog fileDialog = new SaveFileDialog()) { fileDialog.Filter = $"N64 rom(*.{format.ToString().ToLower()})|*.{format.ToString().ToLower()}"; fileDialog.FileName = Path.GetFileName(Regex.Replace(romFileName, romConverter.GetFormat().ToString(), format.ToString().ToLower(), RegexOptions.IgnoreCase)); if (fileDialog.ShowDialog() == DialogResult.OK) { romConverter.Convert(fileDialog.FileName, format); MessageBox.Show("Converted successfully!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
private void ConvertButton_Click(Button button, RomConverter.RomFormat format) { using (RomConverter romConverter = new RomConverter(FileName)) { // show error if we're trying to convert to the same format if (format.ToString().ToLower() == romConverter.GetFormat().ToString().ToLower()) { ShowDialog("Cannot convert to the same format!", MessageType.Error); return; } FileChooserDialog fc = new FileChooserDialog("Select ROM", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); FileFilter fileFilter = new FileFilter(); fileFilter.Name = format.ToString(); fileFilter.AddPattern("*." + format.ToString().ToUpper()); fileFilter.AddPattern("*." + format.ToString().ToLower()); fc.AddFilter(fileFilter); fc.CurrentName = System.IO.Path.GetFileName( Regex.Replace(FileName, romConverter.GetFormat().ToString(), format.ToString().ToLower(), RegexOptions.IgnoreCase)); if (fc.Run() != (int)ResponseType.Accept) { fc.Destroy(); return; } string targetFileName = fc.Filename; fc.Destroy(); romConverter.Convert(targetFileName, format); ShowDialog("Converted successfully!", MessageType.Info); } }