Example #1
0
        private void ouvrirÉquipeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ofdEquipe.ShowDialog() == DialogResult.OK)
            {
                string extension = System.IO.Path.GetExtension(ofdEquipe.FileName);
                switch (extension)
                {
                    case ".eqp":
                        Equipe eq = null;
                        try
                        {
                            eq = new Equipe();
                            eq.Load(ofdEquipe.FileName);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Fichier invalide.");
                            return;
                        }

                        equipe = eq;
                        equipe.LoadPokemons();

                        if (equipe.Pokemons[0] != null)
                            ChargerPokemon(1, equipe.Pokemons[0], equipe.PokemonsFiles[0]);
                        else
                            poke1 = null;
                        if (equipe.Pokemons[1] != null)
                            ChargerPokemon(2, equipe.Pokemons[1], equipe.PokemonsFiles[1]);
                        else
                            poke2 = null;
                        if (equipe.Pokemons[2] != null)
                            ChargerPokemon(3, equipe.Pokemons[2], equipe.PokemonsFiles[2]);
                        else
                            poke3 = null;
                        if (equipe.Pokemons[3] != null)
                            ChargerPokemon(4, equipe.Pokemons[3], equipe.PokemonsFiles[3]);
                        else
                            poke4 = null;
                        if (equipe.Pokemons[4] != null)
                            ChargerPokemon(5, equipe.Pokemons[4], equipe.PokemonsFiles[4]);
                        else
                            poke5 = null;
                        if (equipe.Pokemons[5] != null)
                            ChargerPokemon(6, equipe.Pokemons[5], equipe.PokemonsFiles[5]);
                        else
                            poke6 = null;

                        rbPoke1.Checked = true;
                        break;
                    case ".eqx":
                        EquipeExport equipeex = null;
                        try
                        {
                            equipeex = new EquipeExport();
                            equipeex.Load(ofdEquipe.FileName);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Fichier invalide.");
                            return;
                        }

                        ChargerPokemon(1, equipeex.Pokemons[0], null);
                        ChargerPokemon(2, equipeex.Pokemons[1], null);
                        ChargerPokemon(3, equipeex.Pokemons[2], null);
                        ChargerPokemon(4, equipeex.Pokemons[3], null);
                        ChargerPokemon(5, equipeex.Pokemons[4], null);
                        ChargerPokemon(6, equipeex.Pokemons[5], null);

                        break;
                    default:
                        break;
                }

            }
        }
Example #2
0
 private void fichierURAToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (sfdEquipeEx.ShowDialog() == DialogResult.OK)
     {
         EquipeExport equipeex = new EquipeExport();
         equipeex.Pokemons = new Pokemon[6];
         equipeex.Pokemons[0] = poke1;
         equipeex.Pokemons[1] = poke2;
         equipeex.Pokemons[2] = poke3;
         equipeex.Pokemons[3] = poke4;
         equipeex.Pokemons[4] = poke5;
         equipeex.Pokemons[5] = poke6;
         equipeex.Save(sfdEquipeEx.FileName);
     }
 }