LoadAction() public method

public LoadAction ( Ability values ) : void
values Ability
return void
        /* Edits selected item in the TraitList. If it's an Ability/Attack,
        Open the appropriate window and load that data. */
        private void editTrait(object sender, MouseEventArgs e)
        {                        
            if (TraitsList.SelectedItem == null) return;
                
            if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Legendary")
            {
                AddLegendaryForm loadLegendary = new AddLegendaryForm();
                    
                foreach (Legendary legendary in Monster._Legendaries)
                {
                    if (legendary.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                    {
                        loadLegendary.LoadLegendary(legendary);
                        loadLegendary.Show();

                        loadLegendary.FormClosing += (senderx, ex) =>
                        {
                            loadLegendary.SerializeTraits();
                            int index = Monster._Legendaries.IndexOf(legendary);
                            Monster._Legendaries.RemoveAt(index);
                            Monster._Legendaries.Insert(index, loadLegendary.LegendaryAbility);

                            index = TraitsList.Items.IndexOf(TraitsList.SelectedItem);
                            TraitsList.Items.RemoveAt(index);
                            TraitsList.Items.Insert(index, "Legendary: " + loadLegendary.LegendaryAbility.Title);
                        };
                        return;
                    }
                }
            }

            if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Action")
            {
                AddActionForm loadAttack = new AddActionForm();

                foreach (Ability attack in Monster._Actions)
                {
                    if (attack.isDamage)
                    {
                        if (attack.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                        {
                            loadAttack.LoadAttack(attack);                                
                            loadAttack.Show();

                            loadAttack.FormClosing += (senderx, ex) =>
                            {
                                int index = Monster._Actions.IndexOf(attack);
                                Monster._Actions.RemoveAt(index);                                    
                                Monster._Actions.Insert(index, loadAttack.NewAttack);

                                index = TraitsList.Items.IndexOf(TraitsList.SelectedItem);
                                TraitsList.Items.RemoveAt(index);
                                TraitsList.Items.Insert(index, "Action: " + loadAttack.NewAttack.Title);
                            };
                            return;
                        }
                    }

                    if (!attack.isDamage)
                    {
                        if (attack.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                        {
                            loadAttack.LoadAction((Ability)attack);
                            loadAttack.Show();

                            loadAttack.FormClosing += (senderx, ex) =>
                            {
                                int index = Monster._Actions.IndexOf(attack);
                                Monster._Actions.RemoveAt(index);
                                Monster._Actions.Insert(index, loadAttack.NewAbility);

                                index = TraitsList.Items.IndexOf(TraitsList.SelectedItem);
                                TraitsList.Items.RemoveAt(index);
                                TraitsList.Items.Insert(index, "Action: " + loadAttack.NewAbility.Title);
                            };
                            return;
                        }
                    }
                }
            }

            if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Reaction")
            {
                AddActionForm loadReaction = new AddActionForm();

                foreach (Ability reaction in Monster._Reactions)
                {
                    if (reaction.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                    {
                        loadReaction.LoadReaction(reaction);
                        loadReaction.Show();

                        loadReaction.FormClosing += (senderx, ex) =>
                        {
                            int index = Monster._Reactions.IndexOf(reaction);
                            Monster._Reactions.RemoveAt(index);
                            Monster._Reactions.Insert(index, loadReaction.NewReaction);

                            index = TraitsList.Items.IndexOf(TraitsList.SelectedItem);
                            TraitsList.Items.RemoveAt(index);
                            TraitsList.Items.Insert(index, "Reaction: " + loadReaction.NewReaction.Title);
                        };
                        return;
                    }                        
                }
            }

            if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Ability")
            {
                AddAbilityForm loadAbility = new AddAbilityForm();

                foreach (Ability ability in Monster._Abilities)
                {
                    if (ability.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                    {
                        if (ability.isSpell)
                        {
                            loadAbility.LoadSpell(ability);
                        }
                        else
                        {
                            loadAbility.LoadAbility(ability);
                        }
                        loadAbility.Show();

                        loadAbility.FormClosing += (senderx, ex) =>
                        {
                            int index = Monster._Abilities.IndexOf(ability);
                            Monster._Abilities.RemoveAt(index);
                            Monster._Abilities.Insert(index, loadAbility.NewAbility);

                            index = TraitsList.Items.IndexOf(TraitsList.SelectedItem);
                            TraitsList.Items.RemoveAt(index);
                            TraitsList.Items.Insert(index, "Ability: " + loadAbility.NewAbility.Title);
                        };
                        return;
                    }
                }
            }
        }