Skip to content

Commit

Permalink
input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
chaslain committed Aug 31, 2024
1 parent 0547d31 commit eab2814
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions RoR2VersionSelector/RoR2VersionSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,32 @@ private void RoR2VersionSelector_Load(object sender, EventArgs e)
UpdateInitialState();
}

private Boolean ValidateInput()
{
if (TextBoxUsername.Text.Length == 0)
{
MessageBox.Show("Please specify username.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}

if (!Enum.IsDefined(typeof(RoR2Versions), ComboBoxVersionSelector.Text))
{
MessageBox.Show("Please specify valid version.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}

return true;
}

private async void ButtonDownloadDepot_Click(object sender, EventArgs e)
{
if (!ValidateInput())
{
return;
}
ButtonDownloadDepot.Enabled = false;


var startInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Expand Down

0 comments on commit eab2814

Please sign in to comment.