private void F_ButtonIVCalculate353_Click(object sender, EventArgs e) { if (!Messages.Instance.Pokemon.ContainsKey(f_ComboBoxPokemon353.Text) || f_ComboBoxPokemon353.Text == "") { CreateErrorDialog(Messages.Instance.ErrorMessage["InvalidPokemon"]); } else { decimal pokemonID = Messages.Instance.Pokemon[f_ComboBoxPokemon353.Text]; try { int lv = int.Parse(f_TextBoxLevel353.Text); if (lv > 100 || lv < 1) { CreateErrorDialog(Messages.Instance.ErrorMessage["LevelRange"]); return; } int HP = int.Parse(f_TextBoxIv0_353.Text); int Atk = int.Parse(f_TextBoxIv1_353.Text); int Def = int.Parse(f_TextBoxIv2_353.Text); int SpAtk = int.Parse(f_TextBoxIv3_353.Text); int SpDef = int.Parse(f_TextBoxIv4_353.Text); int Spd = int.Parse(f_TextBoxIv5_353.Text); int nature = Messages.Instance.Nature[f_ComboBoxNature_353.Text]; int characteristic = Messages.Instance.Characteristic[f_ComboBoxCharacteristic_353.Text]; var IVs = IVCalculator.getIVs(pokemonID, lv, nature, characteristic, new List <int>() { HP, Atk, Def, SpAtk, SpDef, Spd }, null); f_TextBoxIv0_353.Text = IVs[0].First().ToString(); f_TextBoxIv1_353.Text = IVs[1].First().ToString(); f_TextBoxIv2_353.Text = IVs[2].First().ToString(); f_TextBoxIv3_353.Text = IVs[3].First().ToString(); f_TextBoxIv4_353.Text = IVs[4].First().ToString(); f_TextBoxIv5_353.Text = IVs[5].First().ToString(); } catch (FormatException except) { CreateErrorDialog(Messages.Instance.ErrorMessage["VFormat"]); } catch (ArgumentOutOfRangeException except) { CreateErrorDialog(Messages.Instance.ErrorMessage["CouldNotCalculateIVs"]); } catch (IVCalculator.StatException s) { CreateErrorDialog(Messages.Instance.ErrorMessage["StatError"] + Messages.Instance.Status[s.Stat]); } } }
private async Task AddPokemonAsync() { Pokemon newPokemon = new Pokemon(); IVCalculator calculator = new IVCalculator(newPokemon); IVCalculatorPopupEventArgs args = await navigationService.OpenPopup <IVCalculatorViewModel>(new IVCalculatorWrapper(calculator, true)) as IVCalculatorPopupEventArgs; if (args != null) { this.Session.MyPokemon.Add(args.NewPokemon); Messenger.Default.Send(new PokemonMessage(args.NewPokemon)); } }