UI: Improved error handling for drag and drop

This commit is contained in:
Souryo 2017-09-08 19:09:15 -04:00
parent d0713b2775
commit 4704c92317

View file

@ -929,17 +929,29 @@ namespace Mesen.GUI.Forms
private void frmMain_DragDrop(object sender, DragEventArgs e)
{
try {
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if(File.Exists(files[0])) {
LoadFile(files[0]);
this.Activate();
} else {
InteropEmu.DisplayMessage("Error", "File not found: " + files[0]);
}
} catch(Exception ex) {
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
}
}
private void frmMain_DragEnter(object sender, DragEventArgs e)
{
try {
if(e.Data.GetDataPresent(DataFormats.FileDrop)) {
e.Effect = DragDropEffects.Copy;
} else {
InteropEmu.DisplayMessage("Error", "Unsupported operation.");
}
} catch(Exception ex) {
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
}
}