Update MainForm.cs

Solves #10
This commit is contained in:
Logan Lowe 2022-02-20 17:54:17 -07:00
commit eba5a9d189

View file

@ -10,7 +10,7 @@ namespace LBPUnion.UnionPatcher.Gui {
private readonly FilePicker filePicker;
private readonly TextBox serverUrl;
private readonly FilePicker outputFileName;
private Uri uriResult;
public Dialog CreateOkDialog(string title, string errorMessage) {
DynamicLayout layout = new();
Button button;
@ -86,6 +86,18 @@ namespace LBPUnion.UnionPatcher.Gui {
return;
}
if (this.filePicker.FilePath == this.outputFileName.FilePath)
{
this.CreateOkDialog("Form Error", "Input and output filename are the same! Please save the patched file with a different name so you have a backup of your the original EBOOT.ELF.").ShowModal();
return;
}
if (!Uri.TryCreate(this.serverUrl.Text, UriKind.Absolute, out uriResult))
{
this.CreateOkDialog("Form Error", "Server URL is invalid! Please enter a valid URL.").ShowModal();
return;
}
try {
Patcher.PatchFile(this.filePicker.FilePath, this.serverUrl.Text, this.outputFileName.FilePath);
}