private void List_DrawItem(object sender, DrawItemEventArgs e) { var list = (ListBox)sender; e.DrawBackground(); bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected); int index = e.Index; if (index >= 0 && index < list.Items.Count) { BanListCard card = (BanListCard)list.Items[index]; Graphics g = e.Graphics; if (!Program.CardData.ContainsKey(card.ID)) { list.Items.Remove(card); } else { g.FillRectangle((selected) ? new SolidBrush(Color.Blue) : new SolidBrush(Color.White), e.Bounds); // Print text g.DrawString((card.Name == "" ? card.ID.ToString() : card.Name), e.Font, (selected) ? Brushes.White : Brushes.Black, list.GetItemRectangle(index).Location); } } e.DrawFocusRectangle(); }
private void LoadBanList() { m_banlists = new Dictionary <string, List <BanListCard> >(); if (!File.Exists("lflist.conf")) { return; } var reader = new StreamReader(File.OpenRead("lflist.conf")); while (!reader.EndOfStream) { string line = reader.ReadLine(); if (string.IsNullOrEmpty(line) || line.StartsWith("#")) { continue; } if (line.StartsWith("!")) { if (!BanList.Items.Contains(line.Substring(1))) { BanList.Items.Add(line.Substring(1)); } } else { string[] parts = line.Split(' '); if (!Program.CardData.ContainsKey(Int32.Parse(parts[0]))) { continue; } if (Program.CardData[Int32.Parse(parts[0])].Name == "") { continue; } BanListCard card = new BanListCard { ID = Int32.Parse(parts[0]), Banvalue = Int32.Parse(parts[1]), Name = Program.CardData[Int32.Parse(parts[0])].Name }; if (!m_banlists.ContainsKey(BanList.Items[BanList.Items.Count - 1].ToString())) { m_banlists.Add(BanList.Items[BanList.Items.Count - 1].ToString(), new List <BanListCard>()); m_banlists[BanList.Items[BanList.Items.Count - 1].ToString()].Add(card); } else { if (!m_banlists[BanList.Items[BanList.Items.Count - 1].ToString()].Exists(banListCard => banListCard.ID == Int32.Parse(parts[0]))) { m_banlists[BanList.Items[BanList.Items.Count - 1].ToString()].Add(card); } } } } reader.Close(); }
private void DeleteItem(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back) { var list = (ListBox)sender; if (list.SelectedIndex != -1) { BanListCard card = (BanListCard)list.SelectedItem; m_banlists[BanList.SelectedItem.ToString()].Remove(card); list.Items.Remove(card); } } }
private void BanAnimeCardsBtn_Click(object sender, EventArgs e) { foreach (int id in Program.CardData.Keys) { if (Program.CardData[id].Ot == 4) { if (GetBanListCard(id) == null) { BanListCard card = new BanListCard {ID = id, Banvalue = 0, Name = Program.CardData[id].Name}; BannedList.Items.Add(card); m_banlists[BanList.SelectedItem.ToString()].Add(card); } } } }
private void List_DragDrop(object sender, DragEventArgs e) { var list = (ListBox)sender; int indexOfItemUnderMouseToDrop = list.IndexFromPoint(list.PointToClient(new Point(e.X, e.Y))); if (e.Data.GetDataPresent(DataFormats.StringFormat)) { int id = Int32.Parse(e.Data.GetData(DataFormats.Text).ToString()); CardInfos cardinfo = Program.CardData[id]; BanListCard bancard = new BanListCard() { ID = id, Name = cardinfo.Name, Banvalue = (list == BannedList ? 0:list == LimitedList ? 1:2) }; if (GetBanListCard(id) == null) { if (indexOfItemUnderMouseToDrop >= 0 && indexOfItemUnderMouseToDrop < list.Items.Count) { list.Items.Insert(indexOfItemUnderMouseToDrop, bancard); } else { list.Items.Add(bancard); } m_banlists[BanList.SelectedItem.ToString()].Add(bancard); } else { BanListCard foundcard = GetBanListCard(id); if (foundcard.Banvalue == 0) { MessageBox.Show(foundcard.Name + " is already contained in the Banned list."); } else if (foundcard.Banvalue == 1) { MessageBox.Show(foundcard.Name + " is already contained in the Limited list."); } else if (foundcard.Banvalue == 2) { MessageBox.Show(foundcard.Name + " is already contained in the SemiLimited list."); } } } }
private void BanAnimeCardsBtn_Click(object sender, EventArgs e) { foreach (int id in Program.CardData.Keys) { if (Program.CardData[id].Ot == 4) { if (GetBanListCard(id) == null) { BanListCard card = new BanListCard { ID = id, Banvalue = 0, Name = Program.CardData[id].Name }; BannedList.Items.Add(card); m_banlists[BanList.SelectedItem.ToString()].Add(card); } } } }
private void BanTCGBtn_Click(object sender, EventArgs e) { foreach (int id in CardManager.GetKeys()) { CardInfos card = CardManager.GetCard(id); if (card.Ot == 2) { if (GetBanListCard(id) == null) { BanListCard bancard = new BanListCard { ID = id, Banvalue = 0, Name = card.Name }; BannedList.Items.Add(bancard); m_banlists[BanList.SelectedItem.ToString()].Add(bancard); } } } }
private void LoadBanList() { m_banlists = new Dictionary<string, List<BanListCard>>(); if (!File.Exists("lflist.conf")) return; var reader = new StreamReader(File.OpenRead("lflist.conf")); while (!reader.EndOfStream) { string line = reader.ReadLine(); if (string.IsNullOrEmpty(line)|| line.StartsWith("#")) continue; if (line.StartsWith("!")) { if (!BanList.Items.Contains(line.Substring(1))) BanList.Items.Add(line.Substring(1)); } else { string[] parts = line.Split(new char[] { ' ' },StringSplitOptions.RemoveEmptyEntries); if (!CardManager.ContainsCard(Int32.Parse(parts[0]))) continue; if (CardManager.GetCard(Int32.Parse(parts[0])).Name == "") continue; BanListCard card = new BanListCard { ID = Int32.Parse(parts[0]), Banvalue = Int32.Parse(parts[1]), Name = CardManager.GetCard(Int32.Parse(parts[0])).Name }; if (!m_banlists.ContainsKey(BanList.Items[BanList.Items.Count - 1].ToString())) { m_banlists.Add(BanList.Items[BanList.Items.Count - 1].ToString(), new List<BanListCard>()); m_banlists[BanList.Items[BanList.Items.Count - 1].ToString()].Add(card); } else { if (!m_banlists[BanList.Items[BanList.Items.Count - 1].ToString()].Exists(banListCard => banListCard.ID == Int32.Parse(parts[0]))) m_banlists[BanList.Items[BanList.Items.Count - 1].ToString()].Add(card); } } } reader.Close(); }
private void List_DragDrop(object sender, DragEventArgs e) { var list = (ListBox)sender; int indexOfItemUnderMouseToDrop = list.IndexFromPoint(list.PointToClient(new Point(e.X, e.Y))); if (e.Data.GetDataPresent(DataFormats.StringFormat)) { int id = Int32.Parse(e.Data.GetData(DataFormats.Text).ToString()); CardInfos cardinfo = CardManager.GetCard(id); BanListCard bancard = new BanListCard() { ID = id, Name = cardinfo.Name, Banvalue = (list == BannedList ? 0:list == LimitedList ? 1:2)}; if (GetBanListCard(id) == null) { if (indexOfItemUnderMouseToDrop >= 0 && indexOfItemUnderMouseToDrop < list.Items.Count) list.Items.Insert(indexOfItemUnderMouseToDrop, bancard); else list.Items.Add(bancard); m_banlists[BanList.SelectedItem.ToString()].Add(bancard); } else { BanListCard foundcard = GetBanListCard(id); if (foundcard.Banvalue == 0) MessageBox.Show(foundcard.Name + " is already contained in the Banned list."); else if (foundcard.Banvalue == 1) MessageBox.Show(foundcard.Name + " is already contained in the Limited list."); else if (foundcard.Banvalue == 2) MessageBox.Show(foundcard.Name + " is already contained in the SemiLimited list."); } } }