void update_card_list() { CardList.BeginUpdate(); CardList.ShowGroups = true; List <ListViewItem> item_list = new List <ListViewItem>(); if (DeckView.IsCellSelected) { foreach (EncounterCard card in fDeck.Cards) { if (!DeckView.InSelectedCell(card)) { continue; } item_list.Add(add_card(card)); } if (item_list.Count == 0) { CardList.ShowGroups = false; ListViewItem lvi = new ListViewItem("(no cards)"); lvi.ForeColor = SystemColors.GrayText; item_list.Add(lvi); } } else { CardList.ShowGroups = false; ListViewItem lvi = new ListViewItem("(no cell selected)"); lvi.ForeColor = SystemColors.GrayText; item_list.Add(lvi); } CardList.Items.Clear(); CardList.Items.AddRange(item_list.ToArray()); CardList.EndUpdate(); ViewBtn.Enabled = (item_list.Count != 0); }
private void ViewBtn_Click(object sender, EventArgs e) { List <EncounterCard> cards = new List <EncounterCard>(); foreach (EncounterCard card in fDeck.Cards) { if (!DeckView.InSelectedCell(card)) { continue; } cards.Add(card); } if (cards.Count != 0) { DeckViewForm dlg = new DeckViewForm(cards); dlg.ShowDialog(); } }
void update_creature_list() { CreatureList.BeginUpdate(); CreatureList.ShowGroups = true; List <ListViewItem> item_list = new List <ListViewItem>(); if (DeckView.IsCellSelected) { List <ICreature> creatures = new List <ICreature>(); foreach (Creature c in Session.Creatures) { creatures.Add(c); } foreach (CustomCreature cc in Session.Project.CustomCreatures) { creatures.Add(cc); } foreach (ICreature c in creatures) { EncounterCard card = new EncounterCard(); card.CreatureID = c.ID; if (!DeckView.InSelectedCell(card)) { continue; } ListViewItem lvi = new ListViewItem(c.Name); lvi.Tag = c; string cat_name = (c.Category != "") ? c.Category : "Miscellaneous Creatures"; lvi.Group = CreatureList.Groups[cat_name]; item_list.Add(lvi); } if (item_list.Count == 0) { CreatureList.ShowGroups = false; ListViewItem lvi = new ListViewItem("(no creatures)"); lvi.ForeColor = SystemColors.GrayText; item_list.Add(lvi); } } else { CreatureList.ShowGroups = false; ListViewItem lvi = new ListViewItem("(no cell selected)"); lvi.ForeColor = SystemColors.GrayText; item_list.Add(lvi); } CreatureList.Items.Clear(); CreatureList.Items.AddRange(item_list.ToArray()); CreatureList.EndUpdate(); }