Пример #1
0
 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);
 }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        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();
        }
Пример #4
0
        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);
        }