private void btnAdd_Click(object sender, RoutedEventArgs e) { PokemonPartyCRUD CRUDwindow = new PokemonPartyCRUD(); //als er op Add word gedrukt, word het Crud scherm met enkel Add functionaliteit geopened if (Pokemonparty.Max(x => x.Position) < 6) { CRUDwindow.btnAdd.IsEnabled = true; CRUDwindow.cmbPosition.SelectedIndex = Pokemonparty.Max(x => x.Position); CRUDwindow.cmbPosition.IsEnabled = false; CRUDwindow.currentTrainer = trainerParty; CRUDwindow.cmbPokemon.SelectedIndex = 0; CRUDwindow.txtName.Text = "Bulbasaur"; CRUDwindow.txtLvl.Text = "5"; Topmost = false; CRUDwindow.ShowDialog(); Topmost = true; Pokemonparty = DatabaseOperations.SelectParty(trainerParty.Id); LoadPokemon(); } else { MessageBox.Show("You already have 6 pokemon, remove one before adding more"); } }
private void Border_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { Border thisBorder = sender as Border; PokemonGroup currentPokemon = new PokemonGroup(); switch (thisBorder.Name) { case "Card1": currentPokemon = Pokemonparty[0]; break; case "Card2": currentPokemon = Pokemonparty[1]; break; case "Card3": currentPokemon = Pokemonparty[2]; break; case "Card4": currentPokemon = Pokemonparty[3]; break; case "Card5": currentPokemon = Pokemonparty[4]; break; case "Card6": currentPokemon = Pokemonparty[5]; break; default: MessageBox.Show("???"); break; } //In geval je een rechterklik voor een pokemon doet, word deze pokemon naar de CRUD geladen voor delete en update operaties PokemonPartyCRUD CRUDwindow = new PokemonPartyCRUD(); CRUDwindow.btnChange.IsEnabled = true; CRUDwindow.btnDelete.IsEnabled = true; CRUDwindow.cmbPokemon.IsEnabled = false; CRUDwindow.cmbPosition.Items.Clear(); for (int i = 0; i < Pokemonparty.Count(); i++) { //Zorg dat alle momentele posities ingeladen worden, zodat je enkel kan wisselen met een bestaande pokemon CRUDwindow.cmbPosition.Items.Add(i + 1); } //Instellen van gegevens CRUDwindow.CurrentPkmParty = currentPokemon; CRUDwindow.CurrentPkm = currentPokemon.Pokemon; CRUDwindow.cmbPosition.SelectedIndex = currentPokemon.Position - 1; CRUDwindow.cmbPokemon.SelectedIndex = (int)currentPokemon.Pokemon.PokedexID - 1; CRUDwindow.cmbAbility.SelectedIndex = (int)currentPokemon.Pokemon.AbilityID - 1; CRUDwindow.txtLvl.Text = currentPokemon.Pokemon.PokemonLevel.ToString(); CRUDwindow.txtName.Text = currentPokemon.Pokemon.Nickname; CRUDwindow.cmbGender.SelectedIndex = Convert.ToInt32(currentPokemon.Pokemon.Gender); CRUDwindow.currentTrainer = trainerParty; Topmost = false; CRUDwindow.ShowDialog(); Topmost = true; //Hernieuw de lijst zodat de veranderingen gereflecteerd zijn in deze pagina Pokemonparty.Clear(); foreach (Border card in Cards) { card.Visibility = Visibility.Collapsed; } Pokemonparty = DatabaseOperations.SelectParty(trainerParty.Id); LoadPokemon(); }