private void ResetCollectionsViews() { this.PositiveQuirksListView.ItemsSource = Morgue.GetInstance().PositiveQuirks; this.NegativeQuirksListView.ItemsSource = Morgue.GetInstance().NegativeQuirks; this.DiseasesListView.ItemsSource = Morgue.GetInstance().Diseases; this.CausesOfDeathListView.ItemsSource = Morgue.GetInstance().CausesOfDeath; }
private void SearchTextBoxEvent(object sender, TextChangedEventArgs e) { if (ListTabControl.SelectedItem is TabItem tabitem) { string header = tabitem.Header as string; switch (header) { case "Positive Quirks": PositiveQuirksListView.ItemsSource = Morgue.GetInstance().PositiveQuirks.Where(q => q.QuirkName.ToLower().Contains(SearchTextBox.Text.ToLower().Trim())); break; case "Negative Quirks": NegativeQuirksListView.ItemsSource = Morgue.GetInstance().NegativeQuirks.Where(q => q.QuirkName.ToLower().Contains(SearchTextBox.Text.ToLower().Trim())); break; case "Diseases": DiseasesListView.ItemsSource = Morgue.GetInstance().Diseases.Where(d => d.DiseaseName.ToLower().Contains(SearchTextBox.Text.ToLower().Trim())); break; case "Causes of Death": CausesOfDeathListView.ItemsSource = Morgue.GetInstance().CausesOfDeath.Where(c => c.ToLower().Contains(SearchTextBox.Text.ToLower().Trim())); break; } } }
private void GetKeyDownEvent(object sender, KeyEventArgs e) { if (Keyboard.IsKeyDown(Key.S) && Keyboard.IsKeyDown(Key.LeftCtrl)) { ThreadPool.QueueUserWorkItem(o => Morgue.GetInstance().SaveMorgue()); MessageBox.Show("Saving morgue to disk..."); } }
public MainWindow() { Morgue.InitInstance(); InitializeComponent(); this.ChosenHeroDiseases = new ObservableCollection <HeroDisease>(); this.ChosenNegativeQuirks = new ObservableCollection <HeroQuirk>(); this.ChosenPositiveQuirks = new ObservableCollection <HeroQuirk>(); this.InitializeViews(); }
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); }
private void InitializeViews() { Dispatcher.Invoke(() => { this.HeroClassesComboBox.ItemsSource = Enum.GetNames(typeof(HeroClass)).Select(s => s.Replace('_', ' ')); this.HeroLevelsComboBox.ItemsSource = Enum.GetNames(typeof(HeroLevel)); this.VirtueComboBox.ItemsSource = Enum.GetNames(typeof(Virtue)); this.AfflictionComboBox.ItemsSource = Enum.GetNames(typeof(Affliction)); this.HeroLevelsComboBox.SelectedItem = this.HeroLevelsComboBox.Items.GetItemAt(0); this.HeroClassesComboBox.SelectedItem = this.HeroClassesComboBox.Items.GetItemAt(0); this.ResetCollectionsViews(); this.HeroesList.ItemsSource = Morgue.GetInstance().FallenHeroes; this.ChosenPositiveQuirksListView.ItemsSource = this.ChosenPositiveQuirks; this.ChosenNegativeQuirksListView.ItemsSource = this.ChosenNegativeQuirks; this.ChosenDiseasesListView.ItemsSource = this.ChosenHeroDiseases; this.SortModeComboBox.ItemsSource = Enum.GetValues(typeof(HeroesSortType)).Cast <HeroesSortType>(); }); }
private void SortModeComboBox_DropDownClosed(object sender, EventArgs e) { HeroesSortType sortType; try { sortType = (HeroesSortType)SortModeComboBox.SelectedItem; } catch (Exception) { return; } Morgue.GetInstance().SortFallenHeroes(sortType); Keyboard.ClearFocus(); if (this.HeroesList.Items.Count > 0) { this.HeroesList.ScrollIntoView(this.HeroesList.Items[0]); } }
private void SaveChangesEvent(object sender, RoutedEventArgs e) { ThreadPool.QueueUserWorkItem(o => Morgue.GetInstance().SaveMorgue()); MessageBox.Show("Saving fallen heroes...", "Saving", MessageBoxButton.OK); }