Exemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //
            //  Creating a new class for the new character
            //
            CharacterClass NewChar = new CharacterClass();
            NewChar.Name = txtName.Text;
            NewChar.Age = txtAge.Text;
            NewChar.Gender = txtGender.Text;
            NewChar.Occupation = txtOccupation.Text;
            NewChar.Description = txtDescription.Text;
            NewChar.Hometown = txtHometown.Text;
            NewChar.Race = txtRace.Text;

            //
            //  Add character to main form's list
            //
            MainForm.AddNewCharacter(NewChar, pbImage.Image);

            //
            //  Show main form
            //  Enable main form
            //  Close this form
            //
            MainForm.Show();
            MainForm.Enabled = true;
            this.Close();
            
        }
Exemplo n.º 2
0
 public void DeleteCharacter(CharacterClass chrDel, frmListCharacters FLC)
 {
     bool Found = false;
     if (chrDel != null)
     {
         foreach (CharacterClass CC in CBC[0].Characters)
         {
             if (!Found)
             {
                 if (CC == chrDel)
                     Found = true;
             }
         }
     }
     if (Found)
     {
         CBC[0].Characters.Remove(chrDel);
         MessageBox.Show("Character has been deleted.", "Success");
     }
     else
         MessageBox.Show("Couldn't delete character.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     FLC.PopulateCharacters(CBC[0].Characters);
     blDataSaved = false;
     CheckStatus();
 }
Exemplo n.º 3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //
            //  Creating a new class for the new character
            //
            CharacterClass NewChar = new CharacterClass();
            NewChar.Name = txtName.Text;
            NewChar.Age = txtAge.Text;
            NewChar.Gender = txtGender.Text;
            NewChar.Occupation = txtOccupation.Text;
            NewChar.Description = txtDescription.Text;
            NewChar.Hometown = txtHometown.Text;
            NewChar.Race = txtRace.Text;

            //
            //  Add character to main form's list
            //
            //MainForm.AddNewCharacter(NewChar, pbImage.Image);
            MainForm.EditCharacter(GetCharacterByName(lbCharacters.SelectedItem.ToString()), NewChar, pbImage.Image, this);
        }
Exemplo n.º 4
0
 public void AddNewCharacter(CharacterClass chrNew, Image Picture)
 {
     chrNew.SavePicture = ImageToString(Picture);
     CBC[0].Characters.Add(chrNew);
     blDataSaved = false;
     CheckStatus();
 }
Exemplo n.º 5
0
        public void EditCharacter(CharacterClass chrOld, CharacterClass chrUpdate, Image Picture, frmListCharacters FLC)
        {
            bool Found = false;
            if (chrOld != null)
            {
                foreach (CharacterClass CC in CBC[0].Characters)
                {
                    if (!Found)
                    {
                        if (CC.Name == chrOld.Name)
                        {
                            CC.Name = chrUpdate.Name;
                            CC.Age = chrUpdate.Age;
                            CC.Race = chrUpdate.Race;
                            CC.Gender = chrUpdate.Gender;
                            CC.Occupation = chrUpdate.Occupation;
                            CC.Description = chrUpdate.Description;
                            CC.Hometown = chrUpdate.Hometown;
                            CC.SavePicture = ImageToString(Picture);
                            Found = true;
                            blDataSaved = false;
                        }
                    }
                }
            }
            if (Found)
                MessageBox.Show("Character edit successful!", "Editing...");
            else
                MessageBox.Show("Failed to edit character!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

        }