Пример #1
0
        /// <summary>
        /// Gestion du bouton pour valider et cr�er le personnage
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonValidate_Click(object sender, RoutedEventArgs e)
        {
            Genre resGender; //= (Genre) Convert.ToInt32(RadioButtonGenderFemale.IsChecked.Value | RadioButtonGenderMale.IsChecked.Value);

            if (RadioButtonGenderMale.IsChecked.Value == true)
            {
                resGender = Genre.Homme;
            }
            else
            {
                resGender = Genre.Femme;
            }

            PersonnageIHM personnage = new PersonnageIHM(FabriquePersonnage.Instance.Cree(ComboBoxClasse.SelectedItem.ToString(), TextBoxName.Text, resGender));

            personnage.Image = pathImage;

            AnnuairePersonnages.Instance.NouveauPersonnage(personnage.Personnage);

            //instanceImage = (BitmapImage)CharacterImage.Source;

            //DataWriteRead.WriteToBinaryFile<BitmapImage>("Data/images/" + personnage.Nom + "-" + AnnuairePersonnages.Instance.ListePersonnages.IndexOf(personnage), instanceImage, true);

            DataWriteRead.WriteToJsonFile <List <Personnage> >(Environment.CurrentDirectory + "/save.dat", AnnuairePersonnages.Instance.ListePersonnages);
            this.Close();
        }
Пример #2
0
        /// <summary>
        /// Event lors d'un changement dans la liste de personnage
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CharacterListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (CharacterListBox.SelectedItem != null)
            {
                instanceP = (PersonnageIHM)CharacterListBox.SelectedItem;

                // new System.Windows.Media.Imaging.BitmapImage(new Uri("Images/male.jpg", UriKind.Relative));
                LabelTitle.Content          = "Fiche de personnage : " + instanceP.Nom;
                TextBoxName.Text            = instanceP.Nom;
                ComboBoxClasse.SelectedItem = ComboBoxClasse.Items.IndexOf(instanceP.Classe);
                ComboBoxClasse.Text         = instanceP.Classe;

                if (instanceP.Sexe == Genre.Homme)
                {
                    RadioButtonGenderMale.IsChecked = true;
                }
                else
                {
                    RadioButtonGenderFemale.IsChecked = true;
                }


                CharacterImage.Source = new BitmapImage(new Uri("Images/" + instanceP.Image, UriKind.Relative));

                StatsTextBlock.Text = instanceP.statsToString();

                InventaireListBox.Items.Clear();

                foreach (Equipement equip in instanceP.Inventaire)
                {
                    InventaireListBox.Items.Add(equip);
                }

                InfosButtons.IsEnabled           = true;
                InventaireButton.IsEnabled       = true;
                DeleteEquipementButton.IsEnabled = false;
                DeleteButton.IsEnabled           = true;
                AddEquipementButton.IsEnabled    = true;
                LabelMoney.Content = "Argent: " + instanceP.Argent;
            }
            else
            {
                instanceP = null;
                DeleteButton.IsEnabled = false;
            }
        }