public Character(string name, int level, Enums.CharacterSex sex, Enums.Races race, Enums.Professions profession) { this.Name = name; this.Level = level; this.Sex = sex; this.SexFirstLetter = sex.ToString()[0]; this.Race = race; this.Profession = profession; this.ListOfItems = new ObservableCollection <Classes.Equipment>(); }
/// <summary> /// Takes values form the form, perfoms all necesary checks, /// if validation pases, adds the character to the list and clears the form /// </summary> private void btnAdd_Click(object sender, RoutedEventArgs e) { string name = this.txtCharacterName.Text; int level = (int)this.slLevel.Value; Enums.CharacterSex sex = (Enums.CharacterSex)Enum.Parse(typeof(Enums.CharacterSex), this.cmbSex.Text); Enums.Races race = (Enums.Races)Enum.Parse(typeof(Enums.Races), this.cmbRaces.Text); Enums.Professions profession = (Enums.Professions)Enum.Parse(typeof(Enums.Professions), this.cmbProfessions.Text); if (String.IsNullOrEmpty(name) || String.IsNullOrWhiteSpace(name)) { txtCharacterNameIsEmptyOrWhiteSpace(); } else { Character character = new Character(name, level, sex, race, profession); this.ListOfCharacters.Add(character); PrepareForm(); } }