private void SetExtra2(int checkedId) { var extra2 = new BallValidator(ThisBall); switch (checkedId) { case Resource.Id.bye: ThisBall.LegByes = 0; var byesvalid = extra2.Validate("byes"); if (byesvalid.Any()) { FindViewById <RadioButton>(Resource.Id.bye).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, byesvalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.Byes = 1; } break; case Resource.Id.legbye: ThisBall.Byes = 0; var legbyesvalid = extra2.Validate("legbyes"); if (legbyesvalid.Any()) { FindViewById <RadioButton>(Resource.Id.legbye).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, legbyesvalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.LegByes = 1; } break; } if (ThisBall.Byes == 1 || ThisBall.LegByes == 1) { mExtra2Runs.SetSelection(1); mExtra2Runs.Enabled = true; } else { mExtra2Runs.SetSelection(0); mExtra2Runs.Enabled = false; } }
private void SetExtra1(int checkedId) { var extra1 = new BallValidator(ThisBall); switch (checkedId) { case Resource.Id.wide: ThisBall.NoBall = 0; var widevalid = extra1.Validate("wide"); if (widevalid.Any()) { FindViewById <RadioButton>(Resource.Id.wide).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, widevalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.Wide = 1; } break; case Resource.Id.noball: ThisBall.Wide = 0; var noballvalid = extra1.Validate("noball"); if (noballvalid.Any()) { FindViewById <RadioButton>(Resource.Id.noball).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, noballvalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.NoBall = 1; } break; } if (ThisBall.Wide == 1 || ThisBall.NoBall == 1) { mExtra1Runs.SetSelection(1); mExtra1Runs.Enabled = true; } else { mExtra1Runs.SetSelection(0); mExtra1Runs.Enabled = false; } }
private void SetScoreWicket(int checkedId) { var scorewicket = new BallValidator(ThisBall); var scorevalid = scorewicket.Validate("runs"); var wicket1valid = scorewicket.Validate("out"); var wicket2valid = scorewicket.Validate("xout"); switch (checkedId) { case Resource.Id.dot: ThisBall.HowOut = "not out"; ThisBall.RunsScored = 0; break; case Resource.Id.one: ThisBall.HowOut = "not out"; if (scorevalid.Any()) { FindViewById <RadioButton>(Resource.Id.one).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, scorevalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.RunsScored = 1; } break; case Resource.Id.two: ThisBall.HowOut = "not out"; if (scorevalid.Any()) { FindViewById <RadioButton>(Resource.Id.two).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, scorevalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.RunsScored = 2; } break; case Resource.Id.three: ThisBall.HowOut = "not out"; if (scorevalid.Any()) { FindViewById <RadioButton>(Resource.Id.three).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, scorevalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.RunsScored = 3; } break; case Resource.Id.four: ThisBall.HowOut = "not out"; if (scorevalid.Any()) { FindViewById <RadioButton>(Resource.Id.four).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, scorevalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.RunsScored = 4; } break; case Resource.Id.five: ThisBall.HowOut = "not out"; if (scorevalid.Any()) { FindViewById <RadioButton>(Resource.Id.five).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, scorevalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.RunsScored = 5; } break; case Resource.Id.six: ThisBall.HowOut = "not out"; if (scorevalid.Any()) { FindViewById <RadioButton>(Resource.Id.six).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, scorevalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.RunsScored = 6; } break; case Resource.Id.seven: ThisBall.HowOut = "not out"; if (scorevalid.Any()) { FindViewById <RadioButton>(Resource.Id.seven).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, scorevalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.RunsScored = 7; } break; case Resource.Id.eight: ThisBall.HowOut = "not out"; if (scorevalid.Any()) { FindViewById <RadioButton>(Resource.Id.eight).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, scorevalid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.RunsScored = 8; } break; case Resource.Id.bowled: ThisBall.RunsScored = 0; if (wicket1valid.Any()) { FindViewById <RadioButton>(Resource.Id.bowled).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, wicket1valid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.HowOut = $"b {ThisBall.ActiveBowler}"; } break; case Resource.Id.caught: ThisBall.RunsScored = 0; if (wicket1valid.Any()) { FindViewById <RadioButton>(Resource.Id.caught).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, wicket1valid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.HowOut = $"c {ThisBall.Fielder} b {ThisBall.ActiveBowler}"; mFielder_Keeper.Enabled = true; } break; case Resource.Id.lbw: ThisBall.RunsScored = 0; if (wicket1valid.Any()) { FindViewById <RadioButton>(Resource.Id.lbw).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, wicket1valid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.HowOut = $"lbw {ThisBall.ActiveBowler}"; } break; case Resource.Id.runout: mFielder_Keeper.Enabled = true; ThisBall.RunsScored = 0; ThisBall.HowOut = $"runout({ThisBall.Fielder})"; ShowRunoutDialog(); break; case Resource.Id.stumped: ThisBall.RunsScored = 0; if (wicket2valid.Any()) { FindViewById <RadioButton>(Resource.Id.stumped).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, wicket2valid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.HowOut = $"st †{ThisBall.Fielder} b {ThisBall.ActiveBowler}"; mFielder_Keeper.Enabled = true; } break; case Resource.Id.hitout: ThisBall.RunsScored = 0; if (wicket2valid.Any()) { FindViewById <RadioButton>(Resource.Id.hitout).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, wicket2valid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.HowOut = $"hit wicket {ThisBall.ActiveBowler}"; } break; case Resource.Id.retried: ThisBall.RunsScored = 0; if (wicket1valid.Any()) { FindViewById <RadioButton>(Resource.Id.hitout).Checked = false; Toast.MakeText(this, string.Join(System.Environment.NewLine, wicket1valid.ToArray()), ToastLength.Long).Show(); } else { ThisBall.HowOut = "retired"; } break; } }