private void btnSubmit_Click(object sender, RoutedEventArgs e) { if (lstbxPokes.SelectedItem is Pokemon) { SelectedPokemon = (Pokemon) lstbxPokes.SelectedItem; Close(); } else { if (lstbxPokes.SelectedIndex >= 0) MessageBox.Show("The specified item is not of type 'Pokemon'.", "Error"); } Close(); }
public PokeTab(Pokemon p) { MouseDown += PokeTab_MouseDown; ContextMenu = new ContextMenu(); MenuItem cmClose = new MenuItem(); cmClose.Header = "_Close"; cmClose.Click += (sender, args) => RemoveFromTabControl(); ContextMenu.Items.Add(cmClose); Header = p.ToString(); Grid g = new Grid(); g.Margin = new Thickness(0, 0, 0, 0); g.Children.Add(new PokeDataControl(p)); AddChild(g); }
public PokeDataControl(Pokemon p) { Poke = p; InitializeComponent(); }
public static Pokemon FromRawIndex(int index, bool writeNoPoke = false) { if (Program.RawPokeData == null) { Log.AsyncLine("Raw Pokemon Data not set."); return null; } Pokemon ret = new Pokemon(); int st = Array.IndexOf(Program.RawPokeData, $"[{index}]"); if (st == -1) { if (writeNoPoke) Log.AsyncLine("No Pokemon at index: " + index); return null; } int en = Array.IndexOf(Program.RawPokeData, $"[{index + 1}]", st + 1); if (en == -1) en = Program.RawPokeData.Length; //Log.AsyncLine((st + " - " + en); var t = Program.RawPokeData.SubArray(st, en - st); ret.Id = Convert.ToInt32(t[0].Replace("[", "").Replace("]", "")); ret.Name = t.PullKeyValue<string>("Name"); ret.InternalName = t.PullKeyValue<string>("InternalName"); ret.Type1 = t.PullKeyValue<PokeType>("Type1"); ret.Type2 = t.PullKeyValue<PokeType>("Type2"); ret.BaseStats = new PokeStat(t.PullKeyValue<string>("BaseStats").Split(',').CastArrayInt()); ret.GenderRate = t.PullKeyValue<string>("GenderRate"); ret.GrowthRate = t.PullKeyValue<string>("GrowthRate"); ret.BaseExp = t.PullKeyValue<string>("BaseEXP").AsInt(); ret.EffortPoints = new PokeStat(t.PullKeyValue<string>("EffortPoints").Split(',').CastArrayInt()); ret.Rareness = t.PullKeyValue<string>("Rareness").AsInt(); ret.Happiness = t.PullKeyValue<string>("Happiness").AsInt(); ret.Abilities = t.PullKeyValue<string>("Abilities").Split(','); ret.HiddenAbility = t.PullKeyValue<string>("HiddenAbility"); ret.Moves = t.PullKeyValue<LearnedMove[]>("Moves"); ret.EggMoves = t.PullKeyValue<PokeMove[]>("EggMoves"); ret.Compatability = t.PullKeyValue<string>("Compatibility").Split(',').CastArrayInt(); ret.StepsToHatch = t.PullKeyValue<string>("StepsToHatch").AsInt(); ret.Height = t.PullKeyValue<string>("Height").AsFloat(); ret.Weight = t.PullKeyValue<string>("Weight").AsFloat(); ret.Colour = t.PullKeyValue<string>("Color"); ret.Habitat = t.PullKeyValue<string>("Habitat"); ret.RegionalNumbers = t.PullKeyValue<string>("RegionalNumbers").Split(',').CastArrayInt(); ret.Kind = t.PullKeyValue<string>("Kind"); ret.Pokedex = t.PullKeyValue<string>("Pokedex"); ret.Evolutions = t.PullKeyValue<PokeEvo[]>("Evolutions"); foreach (PokeEvo pe in ret.Evolutions) { pe.CalcNextEvo(); } //Log.AsyncLine((JsonConvert.SerializeObject(ret, Formatting.None) + "\n"); return ret; }