Beispiel #1
0
        private void OnCharacterEdit(object sender, EventArgs e)
        {
            //Get selected character
            var character = GetSelectedCharacters();

            if (character == null)
            {
                return;
            }

            var form = new CharacterForm("Edit Character");

            form.Character = character;

            if (form.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            try
            {
                _characters.Update(character.Id, form.Character);
                UpdateUI();
            } catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void OnCharacterEdit(object sender, EventArgs e)
        {
            // display UI
            var form = new CharacterForm();

            // change form title
            form.Text = "Edit Character";

            var character = _listCharacters.SelectedItem as Character;

            if (character == null)
            {
                return;
            }
            form.Character = character;

            // update list with new character
            while (true)
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                _roster.Update(character.Id, form.Character);

                break;
            }

            BindList();
        }
Beispiel #3
0
        private void OnCharacterAdd(object sender, EventArgs e)
        {
            //Display UI
            var form = new CharacterForm();

            while (true)
            {
                //Modal
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                //Add
                try
                {
                    OnSafeAdd(form);
                    break;
                } catch (InvalidOperationException)
                {
                    MessageBox.Show(this, "Pick Again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                } catch (Exception ex)
                {
                    //Recover from errors
                    DisplayError(ex);
                };
            }
            ;

            BindList();
        }
Beispiel #4
0
        private void OnCharacterNew(object sender, EventArgs e)
        {
            //Display UI
            var form = new CharacterForm();

            form.Text = "Create New Kaiju";

            while (true)
            {
                //Modal
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                //Add
                try
                {
                    OnSafeAdd(form);
                    break;
                } catch (Exception ex)
                {
                    //Recover from errors
                    DisplayError(ex);
                };
            }
            ;

            BindList();
        }
Beispiel #5
0
        private void DeleteCharacter()
        {
            // Get selected name, if any
            var itemName = GetSelectedCharacter();

            if (itemName == null)
            {
                return;
            }

            // Show form with selected name
            var form = new CharacterForm();

            form.Character = itemName;

            if (MessageBox.Show($"Are you sure you want to DELETE {itemName.Name}?", "Delete Character",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            // Get selected movie, if any
            var item = GetSelectedCharacter();

            if (item == null)
            {
                return;
            }

            // Remove from database and refresh
            _database.Remove(item.Name);
            RefreshCharacters();
        }
Beispiel #6
0
        private void OnCharacterEdit(object sender, EventArgs e)
        {
            var form = new CharacterForm();

            var character = GetSelectedCharacter();

            if (character == null)
            {
                return;
            }

            form.Character = character;

            while (true)
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    _characters.Update(character.Id, form.Character);
                    break;
                } catch (Exception ex)
                {
                    DisplayError(ex);
                };
            }
            ;

            BindList();
        }
Beispiel #7
0
        private void OnCharacterAdd(object sender, EventArgs e)
        {
            var form = new CharacterForm();

            while (true)
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    OnSafeAdd(form);
                    break;
                } catch (InvalidOperationException)
                {
                    MessageBox.Show(this, "Choose a better character.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                } catch (Exception ex)
                {
                    DisplayError(ex);
                };
            }
            ;
            BindList();
        }
Beispiel #8
0
 private void OnSafeAdd(CharacterForm form)
 {
     try
     {
         _kaiju.Add(form.Kaiju);
     } catch (Exception e)
     {
         throw e;
     };
 }
Beispiel #9
0
 public void EditCharacter()
 {
     if (listBoxCharacterList.SelectedItem != null)
     {
         CharacterForm cf = new CharacterForm();
         cf.Character = GetSelectedCharacter();
         cf.ShowDialog();
         RefreshList();
     }
 }
Beispiel #10
0
        private void OnCharacterNew(object sender, EventArgs e)
        {
            var form = new CharacterForm();

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                AddCharacter(form.Character);
                UpdateUI();
            }
        }
Beispiel #11
0
        private void OnCharacterAdd(object sender, EventArgs e)
        {
            var form = new CharacterForm();

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }
            database.Add(form.Character);
            RefreshCharacters();
        }
Beispiel #12
0
        private void OnCharacterAdd(object sender, EventArgs e)
        {
            var form   = new CharacterForm();
            var result = form.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }
            AddCharacter(null);
        }
Beispiel #13
0
        private void OnCharacterAdd(object sender, EventArgs e)
        {
            var form   = new CharacterForm();
            var result = form.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }
            _character = form.Character;
            MessageBox.Show("Save successful");
        }
Beispiel #14
0
        private void OnCharacterNew(object sender, EventArgs e)
        {
            var form = new CharacterForm();

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _character = form.SelectedCharacter;
            AddCharacter(form.SelectedCharacter);
        }
Beispiel #15
0
        private void OnCharacterNew(object sender, EventArgs e)
        {
            //Creates an instance of Character Form
            var form = new CharacterForm();

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _database.Add(form.Character); //Calls Add method in database to store the Character
            RefreshCharacters();
        }
Beispiel #16
0
        private void OnnewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var form = new CharacterForm();

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }
            Character Name = form.Characters;

            Database.Add(Name);
            RefreshCharacters();
        }
Beispiel #17
0
 private void OnSafeAdd(CharacterForm form)
 {
     try
     {
         _characters.Add(form.Character);
     } catch (NotImplementedException e)
     {
         throw new Exception("Not implemented yet", e);
     } catch (Exception e)
     {
         throw;
     };
 }
Beispiel #18
0
        //Event Handler for adding a character
        private void OnCharacterAdd(object sender, EventArgs e)
        {
            var form = new CharacterForm();

            if (form.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            _characters[GetNextEmptyPosition()] = form.CurrentCharacter;

            BindList();
        }
Beispiel #19
0
        public void NewCharacter()
        {
            CharacterForm characterForm = new CharacterForm();

            characterForm.ShowDialog(this);
            Character newCharacter = characterForm.Character;

            if (newCharacter != null)
            {
                _charDB.Add(newCharacter);
                RefreshList();
            }
        }
Beispiel #20
0
        private void OnCharacterNew(object sender, EventArgs e)
        {
            var form = new CharacterForm();

            var result = form.ShowDialog(this); //Blocks until form is dismissed/

            if (result == DialogResult.Cancel)
            {
                return;
            }

            _character = form.Character;

            MessageBox.Show("Save successful");

            RefreshRoster();
        }
Beispiel #21
0
        private void OnCharacterNew(object sender, EventArgs e)
        {
            var form = new CharacterForm();

            var result = form.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                return;
            }

            //_characters = form.Character;
            AddCharacter(form.Character);

            MessageBox.Show("Save successful");

            // RefreshRoster();
        }
Beispiel #22
0
        private void onCharacterNew(object sender, EventArgs e)
        {
            var form = new CharacterForm("Create New Character");

            //display error if character is not unique
            if (form.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    _characters.Add(form.Character);
                    UpdateUI();
                } catch (ArgumentException ex)
                {
                    MessageBox.Show(ex.Message, "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                };
            }
        }
Beispiel #23
0
        private void OnCharacterNew(object sender, EventArgs e)
        {
            // display UI
            var form = new CharacterForm();

            while (true)
            {
                // add new character
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                _roster.Add(form.Character);
                break;
            }

            BindList();
        }
Beispiel #24
0
        /// <summary>
        /// Show window for updating an existing character
        /// </summary>
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (charactersListBox.SelectedIndex == -1)
            {
                MessageBox.Show("Select a character in the list to update.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Show window to update character
            CharacterForm form = new CharacterForm(characters[charactersListBox.SelectedIndex]);

            if (form.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            // Update the list
            charactersListBox.Items[charactersListBox.SelectedIndex] = form.ProcessedCharacter;
        }
Beispiel #25
0
        private void OnCharacterEdit(object sender, EventArgs e)
        {
            var item = GetSelectedCharacter();

            if (item == null)
            {
                return;
            }

            var form = new CharacterForm();

            form.Character = item;
            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _database.Edit(item.Name, form.Character);
            RefreshCharacters();
        }
Beispiel #26
0
        private void OnCharacterEdit(object sender, EventArgs e)
        {
            var character = GetSelectedCharacter();

            if (character == null)
            {
                return;
            }

            var form = new CharacterForm();

            form.Character = character;

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                RemoveCharacter(character);
                AddCharacter(form.Character);
                UpdateUI();
            }
        }
Beispiel #27
0
        private void OnCharacterEdit(object sender, EventArgs e)
        {
            var character = GetSelectedCharacter();

            if (character == null)
            {
                return;
            }

            var form = new CharacterForm(character, "Edit Character");

            var result = form.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            EditCharacter(character.Id, form.Character);
        }
Beispiel #28
0
        private void EditCharacter()
        {
            var item = GetSelectedCharacter();

            if (item == null)
            {
                return;
            }

            var form = new CharacterForm();

            form.Character = item;
            form.Text      = "Edit Character";
            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _database.Edit(item.Name, form.Character);
            RefreshCharacters();
        }
Beispiel #29
0
        private void OnCharacterEdit(object sender, EventArgs e)
        {
            var character = GetSelectedCharacter();

            if (character == null)
            {
                return;
            }

            var form = new CharacterForm();

            form.Character = character;
            form.Text      = "Edit Character";

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                _characters.Update(character.Id, form.Character);
                UpdateUI();
            }
            ;
        }
Beispiel #30
0
        private void OnCharacterEdit(object sender, EventArgs e)
        {
            var character = GetSelectedCharacter();

            if (character == null)
            {
                return;
            }

            var form = new CharacterForm();

            form.SelectedCharacter = character;

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _character = form.SelectedCharacter;
            RefreshRoster();
        }