public HeroInfo(HeroDeath hd) { this.@class = hd.HeroClass; this.name = hd.HeroName; this.level = hd.HeroLevel; this.deathCause = hd.CauseOfDeath; this.affliction = hd.Affliction == null ? global::Affliction.None : hd.Affliction.GetValueOrDefault(); this.virtue = hd.Virtue == null ? global::Virtue.None : hd.Virtue.GetValueOrDefault(); }
private void AddHeroEvent(object sender, RoutedEventArgs e) { HeroDeath hd = this.GetHeroFromGUI(); if (hd != null) { Morgue.GetInstance().AddHero(hd); HeroesList.Items.Refresh(); ResetControls(); } }
private HeroDeath GetHeroFromGUI() { string heroName = HeroNameTextBox.Text; if (String.IsNullOrWhiteSpace(heroName)) { MessageBox.Show("Please provide a valid name for your hero!"); return(null); } HeroClass @class = (HeroClass)Enum.Parse(typeof(HeroClass), (HeroClassesComboBox.SelectedItem as string).Replace(' ', '_')); HeroLevel level = (HeroLevel)Enum.Parse(typeof(HeroLevel), HeroLevelsComboBox.SelectedItem as string); IList <HeroQuirk> negativeQuirks, positiveQuirks; IList <HeroDisease> diseases; negativeQuirks = new List <HeroQuirk>(this.ChosenNegativeQuirks); positiveQuirks = new List <HeroQuirk>(this.ChosenPositiveQuirks); diseases = new List <HeroDisease>(this.ChosenHeroDiseases); string causeOfDeath = CausesOfDeathListView.SelectedItem as string; if (causeOfDeath == null) { MessageBox.Show("Please select a cause of death for your hero!"); return(null); } Affliction?affliction = AfflictionComboBox.SelectedIndex == -1 ? null : (Affliction?)Enum.Parse(typeof(Affliction), AfflictionComboBox.SelectedItem as string); Virtue? virtue = VirtueComboBox.SelectedIndex == -1 ? null : (Virtue?)Enum.Parse(typeof(Virtue), VirtueComboBox.SelectedItem as string); HeroDeath hd = new HeroDeath() { Affliction = affliction, CauseOfDeath = causeOfDeath, Diseases = diseases, HeroClass = @class, HeroLevel = level, PositiveQuirks = positiveQuirks, NegativeQuirks = negativeQuirks, HeroName = heroName, Virtue = virtue }; hd.ImagePath = Morgue.GetInstance().ClassPortraits[hd.HeroClass]; return(hd); }
public HeroDeathInfoWindow(HeroDeath d) { this.heroDeathInfo = d; this.InitializeComponent(); this.HeroPortrait.Source = new BitmapImage(d.ImagePath); var info = d.GetHeroInfo(); StringBuilder sb = new StringBuilder(); this.HeroInfoTextBlock.Text = sb. Append(info.name).Append("\n"). Append(info.level.ToString()).Append(" "). Append([email protected]().Replace('_', ' ')).Append("\n"). Append("Cause of death: ").Append("\n").Append(info.deathCause). Append("\n").Append("Virtue: ").Append(info.virtue.ToString()). Append("\n").Append("Affliction: ").Append(info.affliction.ToString()). ToString(); this.HeroPositiveQuirks.ItemsSource = d.PositiveQuirks; this.HeroNegativeQuirks.ItemsSource = d.NegativeQuirks; this.HeroDiseases.ItemsSource = d.Diseases; }