public List <Pokemon> GetAllPokemonOfType(Pokemon.PokemonType type) { // create list to save pokemon of same type PokeDex pokemons = new PokeDex(); // check each pokemon for the matching type foreach (Pokemon pokemon in this) { if (pokemon.Type1 == type || pokemon.Type2 == type) { pokemons.Add(pokemon); } } // return a PokeDex containing only pokemon of matching type return(pokemons); }
private void TypeFilter_SelectionChanged(object sender, SelectionChangedEventArgs e) { // check if filter is selected if (TypeFilter.SelectedIndex != 0) { // Set the selectedType to the correct Enum and filter list by type Pokemon.PokemonType selectedType = (Pokemon.PokemonType)Enum.Parse(typeof(Pokemon.PokemonType), TypeFilter.SelectedItem.ToString(), true); PokedexListbox.ItemsSource = pokedexLoader.GetAllPokemonOfType(selectedType); PokedexListbox.Items.Refresh(); } else { PokedexListbox.ItemsSource = pokedexLoader; Update(); } }
private void bulbasaurBtn_Click(object sender, EventArgs e) { SelectedType = Pokemon.PokemonType.Bulbasaur; }
private void squirtleBtn_Click(object sender, EventArgs e) { SelectedType = Pokemon.PokemonType.Squirtle; }
private void slowpokeBtn_Click(object sender, EventArgs e) { SelectedType = Pokemon.PokemonType.Slowpoke; }
private void pikachuBtn_Click(object sender, EventArgs e) { SelectedType = Pokemon.PokemonType.Pikachu; }
private void MainForm_KeyDown(object sender, KeyEventArgs e) { if (e.Control) { switch(e.KeyCode) { case Keys.G: CurrentMode = Mode.Grow; break; case Keys.F: CurrentMode = Mode.Shrink; break; case Keys.E: CurrentMode = Mode.Erase; break; case Keys.W: CurrentMode = Mode.Selection; break; case Keys.D: CurrentMode = Mode.Duplicate; break; case Keys.X: CurrentMode = Mode.Move; break; case Keys.N: NewDrawing(); break; case Keys.Z: Drawing.Undo(); Drawing.RefreshDrawing(); break; case Keys.Q: Close(); break; case Keys.L: LoadDrawing(); break; case Keys.S: SaveDrawing(); break; } } switch (e.KeyCode) { case Keys.B: SelectedType = Pokemon.PokemonType.Bulbasaur; break; case Keys.S: SelectedType = Pokemon.PokemonType.Squirtle; break; case Keys.C: SelectedType = Pokemon.PokemonType.Charmander; break; case Keys.P: SelectedType = Pokemon.PokemonType.Pikachu; break; case Keys.L: SelectedType = Pokemon.PokemonType.Slowpoke; break; case Keys.D: SelectedType = Pokemon.PokemonType.Diglett; break; } }
private void diglettBtn_Click(object sender, EventArgs e) { SelectedType = Pokemon.PokemonType.Diglett; }
private void charmanderBtn_Click(object sender, EventArgs e) { SelectedType = Pokemon.PokemonType.Charmander; }