private void AddSpellToPanel(Spell spell, ListPanel panel) { panel.Add(CreateSpellButton(spell, panel)); //ButtonDeletable b = new ButtonDeletable(); //b.Dock = DockStyle.Top; //b.Text = spell.Name ?? "No Name"; //b.Click += (object o, EventArgs e) => //{ // ShowSpell(spell); //}; //panel.Add(b); }
private void CheckAndAddSpell(List <Spell> spellList, ListPanel panel) { var ib = new InputBox(); var res = ib.ShowDialog(); if (res == DialogResult.OK) { if (loadedGrimoire.GetSpellByName(ib.Data) != null) { MessageBox.Show($"Spell name \"{ib.Data}\" already exists in Grimoire \"{loadedGrimoire.Name}\"", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var s = new Spell(ib.Data); spellList.Add(s); AddSpellToPanel(s, panel); ShowSpell(s); } } }
void LoadSpellList(List <Spell> spellList, ListPanel panel) { panel.Clear(); for (int j = 0; j < spellList.Count; j++) { //Todo: custom control //ButtonDeletable b = new ButtonDeletable(); //b.Dock = DockStyle.Top; //b.Text = spellList[j].Name ?? "No Name"; //var spell = spellList[j]; //b.Click += (object o, EventArgs e) => //{ // editControl.Apply(); // editControl.Clear(); // ShowSpell(spell); //}; //panel.AddNoUpdate(b); var b = CreateSpellButton(spellList[j], panel); panel.AddNoUpdate(b); } panel.UpdateList(); }
private ButtonDeletable CreateSpellButton(Spell spell, ListPanel panel) { ButtonDeletable b = new ButtonDeletable(); b.Dock = DockStyle.Top; b.Text = spell.Name ?? "No Name"; b.Click += (object o, EventArgs e) => { editControl.Apply(); editControl.Clear(); ShowSpell(spell); }; b.DeleteClick += (object o, EventArgs e) => { loadedGrimoire.RemoveSpell(spell); panel.Remove(b); listPanelActions.Clear(); editControl.Clear(); SetEditControl(loadControlCurrent); }; return(b); }