/// <summary> /// selects a spell book to load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SelectSpellBookToolStripMenuItemClick(object sender, EventArgs e) { var ofd = new OpenFileDialog { Title = "Open Spell Book", Filter = "SpellBook Files | *.sb" }; try { DialogResult result = ofd.ShowDialog(); if (result == DialogResult.OK) { PlayerSpellBook = new SpellBook(); _player = new PlayerBook(); PlayerSpellBook.BookName = ofd.SafeFileName; _handler.ReadBinaryFile(PlayerSpellBook.BookName, ref PlayerSpellBook); PlayerBook.PlayerSpellBook = PlayerSpellBook; PreparePlayerForm(); _player.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.ToString()); } }
/// <summary> /// Creates a new spell book /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewSpellBookToolStripMenuItemClick(object sender, EventArgs e) { var newSpellBookDialog = new CreateSpellBook(); if (newSpellBookDialog.ShowDialog(this) == DialogResult.OK) { PlayerSpellBook = new SpellBook { BookName = newSpellBookDialog.BookName }; _player = new PlayerBook(); PlayerBook.PlayerSpellBook = PlayerSpellBook; PreparePlayerForm(); _player.Show(); } newSpellBookDialog.Dispose(); }
/// <summary> /// loads the proper info into the player spell book /// </summary> private void PreparePlayerForm() { _player = new PlayerBook(); PlayerBook.PlayerSpellBook = PlayerSpellBook; }