/*private async void NavigateSettingsPage(object sender, EventArgs e) * { * await Navigation.PushAsync(new NewPage()); * } */ public async void TeamOptions(object sender, EventArgs e) { string loadOption = await DisplayActionSheet("Do you want to load a team or match details?", "Cancel", null, "Match Details", "Teams"); switch (loadOption) { case "Match Details": if (File.Exists(ScorerIO.GetDownloadFilename("MatchDefinition.txt"))) { ScorerIO.ReadMatchDetails("MatchDefinition.txt"); } else { await DisplayActionSheet("A Match Definition file could not be found", null, "Ok"); // possibility for entering and creating a match definition file on the app if one wasnt found } break; case "Teams": TeamLoadOption(); break; } }
async void TeamLoadOption() { // TODO Have a guard or try/catch in here in case file does not exist (or cannot be read) to avoid exceptions Innings.ScheduledOvers = Match.ScheduledOvers; string team = await DisplayActionSheet("Which team do you wish to input (1 or 2)?", "Cancel", null, "1", "2"); int.TryParse(team, out int teamNumber); var loadOption = await DisplayActionSheet("Do you want to load the teams from a file or input now?", "Cancel", null, "File", "Input Now"); switch (loadOption) { case "File": try { if (File.Exists(ScorerIO.GetDownloadFilename(ScorerIO.GetTeamFileName(teamNumber)))) { ScorerIO.PopulateTeamFromFile(ScorerIO.GetTeamFileName(teamNumber), teamNumber); } else { await DisplayActionSheet("That team file could not be found", null, "Ok"); } } catch (Exception ex) { await DisplayAlert("Unhandled exception", ex.Message, "cancel"); } break; case "Input Now": ScorerIO.PopulateTeamFromConsole(teamNumber); break; } }