Copy error dialog code from DiscoHawk's top box to its bottom box
This commit is contained in:
parent
6309e3b7fc
commit
3f2f9cc170
|
@ -116,23 +116,38 @@ namespace BizHawk.Client.DiscoHawk
|
||||||
|
|
||||||
private void LblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e)
|
private void LblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
var files = ValidateDrop(e.Data);
|
lblMp3ExtractMagicArea.AllowDrop = false;
|
||||||
if (files.Count == 0) return;
|
Cursor = Cursors.WaitCursor;
|
||||||
foreach (var file in files)
|
try
|
||||||
{
|
{
|
||||||
using var disc = Disc.LoadAutomagic(file);
|
var files = ValidateDrop(e.Data);
|
||||||
var (path, filename, _) = file.SplitPathToDirFileAndExt();
|
if (files.Count == 0) return;
|
||||||
static bool? PromptForOverwrite(string mp3Path)
|
foreach (var file in files)
|
||||||
=> MessageBox.Show(
|
{
|
||||||
$"Do you want to overwrite existing files? Choosing \"No\" will simply skip those. You could also \"Cancel\" the extraction entirely.\n\ncaused by file: {mp3Path}",
|
using var disc = Disc.LoadAutomagic(file);
|
||||||
"File to extract already exists",
|
var (path, filename, _) = file.SplitPathToDirFileAndExt();
|
||||||
MessageBoxButtons.YesNoCancel) switch
|
static bool? PromptForOverwrite(string mp3Path)
|
||||||
{
|
=> MessageBox.Show(
|
||||||
DialogResult.Yes => true,
|
$"Do you want to overwrite existing files? Choosing \"No\" will simply skip those. You could also \"Cancel\" the extraction entirely.\n\ncaused by file: {mp3Path}",
|
||||||
DialogResult.No => false,
|
"File to extract already exists",
|
||||||
_ => null
|
MessageBoxButtons.YesNoCancel) switch
|
||||||
};
|
{
|
||||||
AudioExtractor.Extract(disc, path, filename, PromptForOverwrite);
|
DialogResult.Yes => true,
|
||||||
|
DialogResult.No => false,
|
||||||
|
_ => null
|
||||||
|
};
|
||||||
|
AudioExtractor.Extract(disc, path, filename, PromptForOverwrite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.ToString(), "Error loading disc");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
lblMp3ExtractMagicArea.AllowDrop = true;
|
||||||
|
Cursor = Cursors.Default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue