예제 #1
0
        /// <summary>
        /// Add a PACKS Kit to the character.
        /// </summary>
        public void AddPACKSKit()
        {
            frmSelectPACKSKit frmPickPACKSKit = new frmSelectPACKSKit(_objCharacter);
            frmPickPACKSKit.ShowDialog(this);

            bool blnCreateChildren = true;

            // If the form was canceled, don't do anything.
            if (frmPickPACKSKit.DialogResult == DialogResult.Cancel)
                return;

            XmlDocument objXmlDocument = XmlManager.Instance.Load("packs.xml");

            // Do not create child items for Gear if the chosen Kit is in the Custom category since these items will contain the exact plugins desired.
            if (frmPickPACKSKit.SelectedCategory == "Custom")
                blnCreateChildren = false;

            XmlNode objXmlKit = objXmlDocument.SelectSingleNode("/chummer/packs/pack[name = \"" + frmPickPACKSKit.SelectedKit + "\" and category = \"" + frmPickPACKSKit.SelectedCategory + "\"]");
            // Update Qualities.
            if (objXmlKit["qualities"] != null)
            {
                XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml");

                // Positive Qualities.
                foreach (XmlNode objXmlQuality in objXmlKit.SelectNodes("qualities/positive/quality"))
                {
                    XmlNode objXmlQualityNode = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQuality.InnerText + "\"]");

                    TreeNode objNode = new TreeNode();
                    List<Weapon> objWeapons = new List<Weapon>();
                    List<TreeNode> objWeaponNodes = new List<TreeNode>();
                    Quality objQuality = new Quality(_objCharacter);
                    string strForceValue = "";

                    if (objXmlQuality.Attributes["select"] != null)
                        strForceValue = objXmlQuality.Attributes["select"].InnerText;

                    objQuality.Create(objXmlQualityNode, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes, strForceValue);
                    _objCharacter.Qualities.Add(objQuality);

                    treQualities.Nodes[0].Nodes.Add(objNode);
                    treQualities.Nodes[0].Expand();

                    // Add any created Weapons to the character.
                    foreach (Weapon objWeapon in objWeapons)
                        _objCharacter.Weapons.Add(objWeapon);

                    // Create the Weapon Node if one exists.
                    foreach (TreeNode objWeaponNode in objWeaponNodes)
                    {
                        objWeaponNode.ContextMenuStrip = cmsWeapon;
                        treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                        treWeapons.Nodes[0].Expand();
                    }
                }

                // Negative Qualities.
                foreach (XmlNode objXmlQuality in objXmlKit.SelectNodes("qualities/negative/quality"))
                {
                    XmlNode objXmlQualityNode = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQuality.InnerText + "\"]");

                    TreeNode objNode = new TreeNode();
                    List<Weapon> objWeapons = new List<Weapon>();
                    List<TreeNode> objWeaponNodes = new List<TreeNode>();
                    Quality objQuality = new Quality(_objCharacter);
                    string strForceValue = "";

                    if (objXmlQuality.Attributes["select"] != null)
                        strForceValue = objXmlQuality.Attributes["select"].InnerText;

                    objQuality.Create(objXmlQualityNode, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes, strForceValue);
                    _objCharacter.Qualities.Add(objQuality);

                    treQualities.Nodes[1].Nodes.Add(objNode);
                    treQualities.Nodes[1].Expand();

                    // Add any created Weapons to the character.
                    foreach (Weapon objWeapon in objWeapons)
                        _objCharacter.Weapons.Add(objWeapon);

                    // Create the Weapon Node if one exists.
                    foreach (TreeNode objWeaponNode in objWeaponNodes)
                    {
                        objWeaponNode.ContextMenuStrip = cmsWeapon;
                        treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                        treWeapons.Nodes[0].Expand();
                    }
                }
            }

            // Update Attributes.
            if (objXmlKit["attributes"] != null)
            {
                // Reset all Attributes back to 1 so we don't go over any BP limits.
                nudBOD.Value = nudBOD.Minimum;
                nudAGI.Value = nudAGI.Minimum;
                nudREA.Value = nudREA.Minimum;
                nudSTR.Value = nudSTR.Minimum;
                nudCHA.Value = nudCHA.Minimum;
                nudINT.Value = nudINT.Minimum;
                nudLOG.Value = nudLOG.Minimum;
                nudWIL.Value = nudWIL.Minimum;
                nudEDG.Value = nudEDG.Minimum;
                nudMAG.Value = nudMAG.Minimum;
                nudRES.Value = nudRES.Minimum;
                foreach (XmlNode objXmlAttribute in objXmlKit["attributes"])
                {
                    // The Attribute is calculated as given value - (6 - Metatype Maximum) so that each Metatype has the values from the file adjusted correctly.
                    switch (objXmlAttribute.Name)
                    {
                        case "bod":
                            nudBOD.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.BOD.MetatypeMaximum);
                            break;
                        case "agi":
                            nudAGI.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.AGI.MetatypeMaximum);
                            break;
                        case "rea":
                            nudREA.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.REA.MetatypeMaximum);
                            break;
                        case "str":
                            nudSTR.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.STR.MetatypeMaximum);
                            break;
                        case "cha":
                            nudCHA.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.CHA.MetatypeMaximum);
                            break;
                        case "int":
                            nudINT.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.INT.MetatypeMaximum);
                            break;
                        case "log":
                            nudLOG.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.LOG.MetatypeMaximum);
                            break;
                        case "wil":
                            nudWIL.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.WIL.MetatypeMaximum);
                            break;
                        case "mag":
                            nudMAG.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.MAG.MetatypeMaximum);
                            break;
                        case "res":
                            nudRES.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.RES.MetatypeMaximum);
                            break;
                        default:
                            nudEDG.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.EDG.MetatypeMaximum);
                            break;
                    }
                }
            }

            // Update Skills.
            if (objXmlKit["skills"] != null)
            {
                // Active Skills.
                foreach (XmlNode objXmlSkill in objXmlKit.SelectNodes("skills/skill"))
                {
                    if (objXmlSkill["name"].InnerText.Contains("Exotic"))
                    {
                        int i = panActiveSkills.Controls.Count;
                        Skill objSkill = new Skill(_objCharacter);

                        SkillControl objSkillControl = new SkillControl(_objCharacter);
                        objSkillControl.SkillObject = objSkill;
                        objSkillControl.Width = 510;

                        // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                        objSkillControl.RatingChanged += objActiveSkill_RatingChanged;
                        objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                        objSkillControl.SkillName = objXmlSkill["name"].InnerText;

                        switch (objXmlSkill["name"].InnerText)
                        {
                            case "Exotic Ranged Weapon":
                            case "Exotic Melee Weapon":
                                objSkill.Attribute = "AGI";
                                objSkillControl.SkillCategory = "Combat Active";
                                objSkill.Default = true;
                                break;
                            default:
                                objSkill.Attribute = "REA";
                                objSkillControl.SkillCategory = "Vehicle Active";
                                objSkill.Default = false;
                                break;
                        }
                        objSkill.ExoticSkill = true;
                        _objCharacter.Skills.Add(objSkill);


						if (_objCharacter.IgnoreRules)
						{
							objSkillControl.SkillRatingMaximum = 12;
						}
						else
						{
							objSkillControl.SkillRatingMaximum = 6;
						}

						// Make sure it's not going above the maximum number.
						if (Convert.ToInt32(objXmlSkill["rating"].InnerText) > objSkillControl.SkillRatingMaximum)
                            objSkillControl.SkillRating = objSkillControl.SkillRatingMaximum;
                        else
                            objSkillControl.SkillRating = Convert.ToInt32(objXmlSkill["rating"].InnerText);

                        if (objXmlSkill["spec"] != null)
                            objSkillControl.SkillSpec = objXmlSkill["spec"].InnerText;
                        else
                            objSkillControl.SkillSpec = "";

                        // Set the SkillControl's Location since scrolling the Panel causes it to actually change the child Controls' Locations.
                        objSkillControl.Location = new Point(0, objSkillControl.Height * i + panActiveSkills.AutoScrollPosition.Y);
                        panActiveSkills.Controls.Add(objSkillControl);
                    }
                    else
                    {
                        // Find the correct Skill Control.
                        SkillControl objSkillControl = new SkillControl(_objCharacter);
                        foreach (SkillControl objControl in panActiveSkills.Controls)
                        {
                            if (objControl.SkillName == objXmlSkill["name"].InnerText)
                            {
                                objSkillControl = objControl;
                                break;
                            }
                        }

                        // Make sure it's not going above the maximum number.
                        if (Convert.ToInt32(objXmlSkill["rating"].InnerText) > objSkillControl.SkillRatingMaximum)
                            objSkillControl.SkillRating = objSkillControl.SkillRatingMaximum;
                        else
                            objSkillControl.SkillRating = Convert.ToInt32(objXmlSkill["rating"].InnerText);

                        if (objXmlSkill["spec"] != null)
                            objSkillControl.SkillSpec = objXmlSkill["spec"].InnerText;
                        else
                            objSkillControl.SkillSpec = "";
                    }
                }

                // Skill Groups.
                foreach (XmlNode objXmlGroup in objXmlKit.SelectNodes("skills/skillgroup"))
                {
                    // Find the correct SkillGroupControl.
                    SkillGroupControl objSkillGroupControl = new SkillGroupControl(_objCharacter.Options, _objCharacter);
                    foreach (SkillGroupControl objControl in panSkillGroups.Controls)
                    {
                        if (objControl.GroupName == objXmlGroup["name"].InnerText)
                        {
                            objSkillGroupControl = objControl;
                            break;
                        }
                    }

                    // Make sure it's not going above the maximum number.
                    if (Convert.ToInt32(objXmlGroup["base"].InnerText) > objSkillGroupControl.GroupRatingMaximum)
                    {
                        objSkillGroupControl.BaseRating = objSkillGroupControl.GroupRatingMaximum;
                        objSkillGroupControl.KarmaRating = 0;
                    }
                    else if (Convert.ToInt32(objXmlGroup["base"].InnerText) + Convert.ToInt32(objXmlGroup["karma"].InnerText) > objSkillGroupControl.GroupRatingMaximum)
                    {
                        objSkillGroupControl.BaseRating = Convert.ToInt32(objXmlGroup["base"].InnerText);
                        objSkillGroupControl.KarmaRating = objSkillGroupControl.GroupRatingMaximum - objSkillGroupControl.BaseRating;
                    }
                    else
                    {
                        objSkillGroupControl.BaseRating = Convert.ToInt32(objXmlGroup["base"].InnerText);
                        objSkillGroupControl.KarmaRating = Convert.ToInt32(objXmlGroup["karma"].InnerText);
                    }
                }
            }

            // Update Knowledge Skills.
            if (objXmlKit["knowledgeskills"] != null)
            {
                foreach (XmlNode objXmlSkill in objXmlKit.SelectNodes("knowledgeskills/skill"))
                {
                    int i = panKnowledgeSkills.Controls.Count;
                    Skill objSkill = new Skill(_objCharacter);
                    objSkill.Name = objXmlSkill["name"].InnerText;

                    SkillControl objSkillControl = new SkillControl(_objCharacter);
                    objSkillControl.SkillObject = objSkill;

                    // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                    objSkillControl.RatingChanged += objKnowledgeSkill_RatingChanged;
                    objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                    objSkillControl.DeleteSkill += objKnowledgeSkill_DeleteSkill;

                    objSkillControl.KnowledgeSkill = true;
                    objSkillControl.AllowDelete = true;

					if (_objCharacter.IgnoreRules)
					{
						objSkillControl.SkillRatingMaximum = 12;
					}
					else
					{
						objSkillControl.SkillRatingMaximum = 6;
					}
					// Set the SkillControl's Location since scrolling the Panel causes it to actually change the child Controls' Locations.
					objSkillControl.Location = new Point(0, objSkillControl.Height * i + panKnowledgeSkills.AutoScrollPosition.Y);
                    panKnowledgeSkills.Controls.Add(objSkillControl);

                    objSkillControl.SkillName = objXmlSkill["name"].InnerText;

                    // Make sure it's not going above the maximum number.
                    if (Convert.ToInt32(objXmlSkill["rating"].InnerText) > objSkillControl.SkillRatingMaximum)
                        objSkillControl.SkillRating = objSkillControl.SkillRatingMaximum;
                    else
                        objSkillControl.SkillRating = Convert.ToInt32(objXmlSkill["rating"].InnerText);

                    if (objXmlSkill["spec"] != null)
                        objSkillControl.SkillSpec = objXmlSkill["spec"].InnerText;
                    else
                        objSkillControl.SkillSpec = "";

                    if (objXmlSkill["category"] != null)
                        objSkillControl.SkillCategory = objXmlSkill["category"].InnerText;

                    _objCharacter.Skills.Add(objSkill);
                }
            }

            // Select a Martial Art.
            if (objXmlKit["selectmartialart"] != null)
            {
                string strForcedValue = "";
                int intRating = 1;
                if (objXmlKit["selectmartialart"].Attributes["select"] != null)
                    strForcedValue = objXmlKit["selectmartialart"].Attributes["select"].InnerText;
                if (objXmlKit["selectmartialart"].Attributes["rating"] != null)
                    intRating = Convert.ToInt32(objXmlKit["selectmartialart"].Attributes["rating"].InnerText);

                frmSelectMartialArt frmPickMartialArt = new frmSelectMartialArt(_objCharacter);
                frmPickMartialArt.ForcedValue = strForcedValue;
                frmPickMartialArt.ShowDialog(this);

                if (frmPickMartialArt.DialogResult != DialogResult.Cancel)
                {
                    // Open the Martial Arts XML file and locate the selected piece.
                    XmlDocument objXmlMartialArtDocument = XmlManager.Instance.Load("martialarts.xml");

                    XmlNode objXmlArt = objXmlMartialArtDocument.SelectSingleNode("/chummer/martialarts/martialart[name = \"" + frmPickMartialArt.SelectedMartialArt + "\"]");

                    TreeNode objNode = new TreeNode();
                    MartialArt objMartialArt = new MartialArt(_objCharacter);
                    objMartialArt.Create(objXmlArt, objNode, _objCharacter);
                    objMartialArt.Rating = intRating;
                    _objCharacter.MartialArts.Add(objMartialArt);

                    objNode.ContextMenuStrip = cmsMartialArts;

                    treMartialArts.Nodes[0].Nodes.Add(objNode);
                    treMartialArts.Nodes[0].Expand();

                    treMartialArts.SelectedNode = objNode;
                }
            }

            // Update Martial Arts.
            if (objXmlKit["martialarts"] != null)
            {
                // Open the Martial Arts XML file and locate the selected art.
                XmlDocument objXmlMartialArtDocument = XmlManager.Instance.Load("martialarts.xml");

                foreach (XmlNode objXmlArt in objXmlKit.SelectNodes("martialarts/martialart"))
                {
                    TreeNode objNode = new TreeNode();
                    MartialArt objArt = new MartialArt(_objCharacter);
                    XmlNode objXmlArtNode = objXmlMartialArtDocument.SelectSingleNode("/chummer/martialarts/martialart[name = \"" + objXmlArt["name"].InnerText + "\"]");
                    objArt.Create(objXmlArtNode, objNode, _objCharacter);
                    objArt.Rating = Convert.ToInt32(objXmlArt["rating"].InnerText);
                    _objCharacter.MartialArts.Add(objArt);

                    // Check for Advantages.
                    foreach (XmlNode objXmlAdvantage in objXmlArt.SelectNodes("techniques/technique"))
                    {
                        TreeNode objChildNode = new TreeNode();
                        MartialArtAdvantage objAdvantage = new MartialArtAdvantage(_objCharacter);
                        XmlNode objXmlAdvantageNode = objXmlMartialArtDocument.SelectSingleNode("/chummer/martialarts/martialart[name = \"" + objXmlArt["name"].InnerText + "\"]/techniques/technique[. = \"" + objXmlAdvantage.InnerText + "\"]");
                        objAdvantage.Create(objXmlAdvantageNode, _objCharacter, objChildNode);
                        objArt.Advantages.Add(objAdvantage);

                        objNode.Nodes.Add(objChildNode);
                        objNode.Expand();
                    }

                    treMartialArts.Nodes[0].Nodes.Add(objNode);
                    treMartialArts.Nodes[0].Expand();
                }
            }

            // Update Adept Powers.
            if (objXmlKit["powers"] != null)
            {
                // Open the Powers XML file and locate the selected power.
                XmlDocument objXmlPowerDocument = XmlManager.Instance.Load("powers.xml");

                foreach (XmlNode objXmlPower in objXmlKit.SelectNodes("powers/power"))
                {
                    XmlNode objXmlPowerNode = objXmlPowerDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower["name"].InnerText + "\"]");

                    int i = panPowers.Controls.Count;

                    Power objPower = new Power(_objCharacter);
                    _objCharacter.Powers.Add(objPower);

                    PowerControl objPowerControl = new PowerControl();
                    objPowerControl.PowerObject = objPower;

                    // Attach an EventHandler for the PowerRatingChanged Event.
                    objPowerControl.PowerRatingChanged += objPower_PowerRatingChanged;
                    objPowerControl.DeletePower += objPower_DeletePower;

                    objPowerControl.PowerName = objXmlPowerNode["name"].InnerText;
                    objPowerControl.PointsPerLevel = Convert.ToDecimal(objXmlPowerNode["points"].InnerText, GlobalOptions.Instance.CultureInfo);
                    objPowerControl.AdeptWayDiscount = Convert.ToDecimal(objXmlPowerNode["adeptway"].InnerText, GlobalOptions.Instance.CultureInfo);
                    if (objXmlPowerNode["levels"].InnerText == "no")
                    {
                        objPowerControl.LevelEnabled = false;
                    }
                    else
                    {
                        objPowerControl.LevelEnabled = true;
                        if (objXmlPowerNode["levels"].InnerText != "yes")
                            objPower.MaxLevels = Convert.ToInt32(objXmlPowerNode["levels"].InnerText);
                    }

                    objPower.Source = objXmlPowerNode["source"].InnerText;
                    objPower.Page = objXmlPowerNode["page"].InnerText;
                    if (objXmlPowerNode["doublecost"] != null)
                        objPower.DoubleCost = false;

                    if (objXmlPowerNode.InnerXml.Contains("bonus"))
                    {
                        objPower.Bonus = objXmlPowerNode["bonus"];

                        if (objXmlPower["name"].Attributes["select"] != null)
                            _objImprovementManager.ForcedValue = objXmlPower["name"].Attributes["select"].InnerText;

                        _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Power, objPower.InternalId, objPower.Bonus, false, Convert.ToInt32(objPower.Rating), objPower.DisplayNameShort);
                        objPowerControl.Extra = _objImprovementManager.SelectedValue;
                    }

                    objPowerControl.Top = i * objPowerControl.Height;
                    panPowers.Controls.Add(objPowerControl);

                    // Set the Rating of the Power if applicable.
                    if (objXmlPower["rating"] != null)
                        objPowerControl.PowerLevel = Convert.ToInt32(objXmlPower["rating"].InnerText);
                }
            }

            // Update Complex Forms.
            if (objXmlKit["programs"] != null)
            {
                // Open the Programs XML file and locate the selected program.
                XmlDocument objXmlProgramDocument = XmlManager.Instance.Load("complexforms.xml");

                foreach (XmlNode objXmlProgram in objXmlKit.SelectNodes("complexforms/complexform"))
                {
                    XmlNode objXmlProgramNode = objXmlProgramDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + objXmlProgram["name"].InnerText + "\"]");

                    string strForceValue = "";
                    if (objXmlProgram.Attributes["select"] != null)
                        strForceValue = objXmlProgram.Attributes["select"].InnerText;

                    TreeNode objNode = new TreeNode();
                    ComplexForm objProgram = new ComplexForm(_objCharacter);
                    objProgram.Create(objXmlProgramNode, _objCharacter, objNode, strForceValue);

                    treComplexForms.Nodes[0].Nodes.Add(objNode);
                    treComplexForms.Nodes[0].Expand();

                    _objCharacter.ComplexForms.Add(objProgram);

                    treComplexForms.SortCustom();
                }
            }

            // Update Spells.
            if (objXmlKit["spells"] != null)
            {
                XmlDocument objXmlSpellDocument = XmlManager.Instance.Load("spells.xml");

                foreach (XmlNode objXmlSpell in objXmlKit.SelectNodes("spells/spell"))
                {
                    // Make sure the Spell has not already been added to the character.
                    bool blnFound = false;
                    foreach (TreeNode nodSpell in treSpells.Nodes[0].Nodes)
                    {
                        if (nodSpell.Text == objXmlSpell.InnerText)
                        {
                            blnFound = true;
                            break;
                        }
                    }

                    // The Spell is not in the list, so add it.
                    if (!blnFound)
                    {
                        string strForceValue = "";
                        if (objXmlSpell.Attributes["select"] != null)
                            strForceValue = objXmlSpell.Attributes["select"].InnerText;

                        XmlNode objXmlSpellNode = objXmlSpellDocument.SelectSingleNode("/chummer/spells/spell[name = \"" + objXmlSpell.InnerText + "\"]");

                        Spell objSpell = new Spell(_objCharacter);
                        TreeNode objNode = new TreeNode();
                        objSpell.Create(objXmlSpellNode, _objCharacter, objNode, strForceValue);
                        objNode.ContextMenuStrip = cmsSpell;
                        _objCharacter.Spells.Add(objSpell);

                        switch (objSpell.Category)
                        {
                            case "Combat":
                                treSpells.Nodes[0].Nodes.Add(objNode);
                                treSpells.Nodes[0].Expand();
                                break;
                            case "Detection":
                                treSpells.Nodes[1].Nodes.Add(objNode);
                                treSpells.Nodes[1].Expand();
                                break;
                            case "Health":
                                treSpells.Nodes[2].Nodes.Add(objNode);
                                treSpells.Nodes[2].Expand();
                                break;
                            case "Illusion":
                                treSpells.Nodes[3].Nodes.Add(objNode);
                                treSpells.Nodes[3].Expand();
                                break;
                            case "Manipulation":
                                treSpells.Nodes[4].Nodes.Add(objNode);
                                treSpells.Nodes[4].Expand();
                                break;
                            case "Rituals":
                                int intNode = 5;
                                if (_objCharacter.AdeptEnabled && !_objCharacter.MagicianEnabled)
                                    intNode = 0;
                                treSpells.Nodes[intNode].Nodes.Add(objNode);
                                treSpells.Nodes[intNode].Expand();
                                break;
                        }

                        treSpells.SortCustom();
                    }
                }
            }

            // Update Spirits.
            if (objXmlKit["spirits"] != null)
            {
                foreach (XmlNode objXmlSpirit in objXmlKit.SelectNodes("spirits/spirit"))
                {
                    int i = panSpirits.Controls.Count;

                    Spirit objSpirit = new Spirit(_objCharacter);
                    _objCharacter.Spirits.Add(objSpirit);

                    SpiritControl objSpiritControl = new SpiritControl();
                    objSpiritControl.SpiritObject = objSpirit;
                    objSpiritControl.EntityType = SpiritType.Spirit;

                    // Attach an EventHandler for the ServicesOwedChanged Event.
                    objSpiritControl.ServicesOwedChanged += objSpirit_ServicesOwedChanged;
                    objSpiritControl.ForceChanged += objSpirit_ForceChanged;
                    objSpiritControl.BoundChanged += objSpirit_BoundChanged;
                    objSpiritControl.DeleteSpirit += objSpirit_DeleteSpirit;

                    objSpiritControl.Name = objXmlSpirit["name"].InnerText;
                    objSpiritControl.Force = Convert.ToInt32(objXmlSpirit["force"].InnerText);
                    objSpiritControl.ServicesOwed = Convert.ToInt32(objXmlSpirit["services"].InnerText);

                    objSpiritControl.Top = i * objSpiritControl.Height;
                    panSpirits.Controls.Add(objSpiritControl);
                }
            }

            // Update Lifestyles.
            if (objXmlKit["lifestyles"] != null)
            {
                XmlDocument objXmlLifestyleDocument = XmlManager.Instance.Load("lifestyles.xml");

                foreach (XmlNode objXmlLifestyle in objXmlKit.SelectNodes("lifestyles/lifestyle"))
                {
                    string strName = objXmlLifestyle["name"].InnerText;
                    int intMonths = Convert.ToInt32(objXmlLifestyle["months"].InnerText);

                    // Create the Lifestyle.
                    TreeNode objNode = new TreeNode();
                    Lifestyle objLifestyle = new Lifestyle(_objCharacter);

                    XmlNode objXmlLifestyleNode = objXmlLifestyleDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"" + strName + "\"]");
                    if (objXmlLifestyleNode != null)
                    {
                        // This is a standard Lifestyle, so just use the Create method.
                        objLifestyle.Create(objXmlLifestyleNode, objNode);
                        objLifestyle.Months = intMonths;
                    }
                    else
                    {
                        // This is an Advanced Lifestyle, so build it manually.
                        objLifestyle.Name = strName;
                        objLifestyle.Months = intMonths;
                        objLifestyle.Cost = Convert.ToInt32(objXmlLifestyle["cost"].InnerText);
                        objLifestyle.Dice = Convert.ToInt32(objXmlLifestyle["dice"].InnerText);
                        objLifestyle.Multiplier = Convert.ToInt32(objXmlLifestyle["multiplier"].InnerText);
                        objLifestyle.BaseLifestyle = objXmlLifestyle["baselifestyle"].InnerText;
                        objLifestyle.Source = "SR5";
                        objLifestyle.Page = "373";
                        objLifestyle.Comforts = Convert.ToInt32(objXmlLifestyle["comforts"].InnerText);
                        objLifestyle.ComfortsEntertainment = Convert.ToInt32(objXmlLifestyle["comfortsentertainment"].InnerText);
                        objLifestyle.Security = Convert.ToInt32(objXmlLifestyle["security"].InnerText);
                        objLifestyle.SecurityEntertainment = Convert.ToInt32(objXmlLifestyle["securityentertainment"].InnerText);
                        objLifestyle.Area = Convert.ToInt32(objXmlLifestyle["area"].InnerText);
                        objLifestyle.AreaEntertainment = Convert.ToInt32(objXmlLifestyle["areaentertainment"].InnerText);

                        foreach (LifestyleQuality objXmlQuality in objXmlLifestyle.SelectNodes("lifestylequalities/lifestylequality"))
                            objLifestyle.LifestyleQualities.Add(objXmlQuality);

                        objNode.Text = strName;
                    }

                    // Add the Lifestyle to the character and Lifestyle Tree.
                    if (objLifestyle.BaseLifestyle != "")
                        objNode.ContextMenuStrip = cmsAdvancedLifestyle;
                    else
                        objNode.ContextMenuStrip = cmsLifestyleNotes;
                    _objCharacter.Lifestyles.Add(objLifestyle);
                    treLifestyles.Nodes[0].Nodes.Add(objNode);
                    treLifestyles.Nodes[0].Expand();
                }
            }

            // Update NuyenBP.
            if (objXmlKit["nuyenbp"] != null)
            {
                int intAmount = Convert.ToInt32(objXmlKit["nuyenbp"].InnerText);
                //if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
                //intAmount *= 2;

                // Make sure we don't go over the field's maximum which would throw an Exception.
                if (nudNuyen.Value + intAmount > nudNuyen.Maximum)
                    nudNuyen.Value = nudNuyen.Maximum;
                else
                    nudNuyen.Value += intAmount;
            }

            // Update Armor.
            if (objXmlKit["armors"] != null)
            {
                XmlDocument objXmlArmorDocument = XmlManager.Instance.Load("armor.xml");

                foreach (XmlNode objXmlArmor in objXmlKit.SelectNodes("armors/armor"))
                {
                    XmlNode objXmlArmorNode = objXmlArmorDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + objXmlArmor["name"].InnerText + "\"]");

                    Armor objArmor = new Armor(_objCharacter);
                    TreeNode objNode = new TreeNode();
                    objArmor.Create(objXmlArmorNode, objNode, cmsArmorMod, Convert.ToInt32(objXmlArmor["rating"].InnerText), false, blnCreateChildren);
                    _objCharacter.Armor.Add(objArmor);

                    // Look for Armor Mods.
                    if (objXmlArmor["mods"] != null)
                    {
                        foreach (XmlNode objXmlMod in objXmlArmor.SelectNodes("mods/mod"))
                        {
                            List<Weapon> lstWeapons = new List<Weapon>();
                            List<TreeNode> lstWeaponNodes = new List<TreeNode>();
                            XmlNode objXmlModNode = objXmlArmorDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlMod["name"].InnerText + "\"]");
                            ArmorMod objMod = new ArmorMod(_objCharacter);
                            TreeNode objModNode = new TreeNode();
                            int intRating = 0;
                            if (objXmlMod["rating"] != null)
                                intRating = Convert.ToInt32(objXmlMod["rating"].InnerText);
                            objMod.Create(objXmlModNode, objModNode, intRating, lstWeapons, lstWeaponNodes);
                            objModNode.ContextMenuStrip = cmsArmorMod;
                            objMod.Parent = objArmor;

                            objArmor.ArmorMods.Add(objMod);

                            objNode.Nodes.Add(objModNode);
                            objNode.Expand();

                            // Add any Weapons created by the Mod.
                            foreach (Weapon objWeapon in lstWeapons)
                                _objCharacter.Weapons.Add(objWeapon);

                            foreach (TreeNode objWeaponNode in lstWeaponNodes)
                            {
                                objWeaponNode.ContextMenuStrip = cmsWeapon;
                                treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                                treWeapons.Nodes[0].Expand();
                            }
                        }
                    }

                    XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
                    foreach (XmlNode objXmlGear in objXmlArmor.SelectNodes("gears/gear"))
                        AddPACKSGear(objXmlGearDocument, objXmlGear, objNode, objArmor, cmsArmorGear, blnCreateChildren);

                    objNode.ContextMenuStrip = cmsArmor;
                    treArmor.Nodes[0].Nodes.Add(objNode);
                    treArmor.Nodes[0].Expand();
                }
            }

            // Update Weapons.
            if (objXmlKit["weapons"] != null)
            {
                XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");

                pgbProgress.Visible = true;
                pgbProgress.Value = 0;
                pgbProgress.Maximum = objXmlKit.SelectNodes("weapons/weapon").Count;
                int i = 0;
                foreach (XmlNode objXmlWeapon in objXmlKit.SelectNodes("weapons/weapon"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    XmlNode objXmlWeaponNode = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlWeapon["name"].InnerText + "\"]");

                    Weapon objWeapon = new Weapon(_objCharacter);
                    TreeNode objNode = new TreeNode();
                    objWeapon.Create(objXmlWeaponNode, _objCharacter, objNode, cmsWeapon, cmsWeaponAccessory, cmsWeaponMod, blnCreateChildren);
                    _objCharacter.Weapons.Add(objWeapon);

                    // Look for Weapon Accessories.
                    if (objXmlWeapon["accessories"] != null)
                    {
                        foreach (XmlNode objXmlAccessory in objXmlWeapon.SelectNodes("accessories/accessory"))
                        {
                            XmlNode objXmlAccessoryNode = objXmlWeaponDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + objXmlAccessory["name"].InnerText + "\"]");
                            WeaponAccessory objMod = new WeaponAccessory(_objCharacter);
                            TreeNode objModNode = new TreeNode();
                            string strMount = "";
							int intRating = 0;
                            if (objXmlAccessory["mount"] != null)
                                strMount = objXmlAccessory["mount"].InnerText;
                            objMod.Create(objXmlAccessoryNode, objModNode, strMount, intRating);
                            objModNode.ContextMenuStrip = cmsWeaponAccessory;
                            objMod.Parent = objWeapon;

                            objWeapon.WeaponAccessories.Add(objMod);

                            XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
                            foreach (XmlNode objXmlGear in objXmlAccessory.SelectNodes("gears/gear"))
                                AddPACKSGear(objXmlGearDocument, objXmlGear, objModNode, objMod, cmsWeaponAccessoryGear, blnCreateChildren);

                            objNode.Nodes.Add(objModNode);
                            objNode.Expand();
                        }
                    }

                    // Look for Weapon Mods.
                    if (objXmlWeapon["mods"] != null)
                    {
                        foreach (XmlNode objXmlMod in objXmlWeapon.SelectNodes("mods/mod"))
                        {
                            XmlNode objXmlModNode = objXmlWeaponDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlMod["name"].InnerText + "\"]");
                            WeaponMod objMod = new WeaponMod(_objCharacter);
                            TreeNode objModNode = new TreeNode();
                            objMod.Create(objXmlModNode, objModNode);
                            objModNode.ContextMenuStrip = cmsWeaponMod;
                            objMod.Parent = objWeapon;

                            objWeapon.WeaponMods.Add(objMod);

                            objNode.Nodes.Add(objModNode);
                            objNode.Expand();
                        }
                    }

                    // Look for an Underbarrel Weapon.
                    if (objXmlWeapon["underbarrel"] != null)
                    {
                        XmlNode objXmlUnderbarrelNode = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlWeapon["underbarrel"].InnerText + "\"]");

                        Weapon objUnderbarrelWeapon = new Weapon(_objCharacter);
                        TreeNode objUnderbarrelNode = new TreeNode();
                        objUnderbarrelWeapon.Create(objXmlUnderbarrelNode, _objCharacter, objUnderbarrelNode, cmsWeapon, cmsWeaponAccessory, cmsWeaponMod, blnCreateChildren);
                        objWeapon.UnderbarrelWeapons.Add(objUnderbarrelWeapon);
                        objNode.Nodes.Add(objUnderbarrelNode);
                        objNode.Expand();
                    }

                    objNode.ContextMenuStrip = cmsWeapon;
                    treWeapons.Nodes[0].Nodes.Add(objNode);
                    treWeapons.Nodes[0].Expand();

                    Application.DoEvents();
                }
            }

            // Update Cyberware.
            if (objXmlKit["cyberwares"] != null)
            {
                XmlDocument objXmlCyberwareDocument = XmlManager.Instance.Load("cyberware.xml");
                XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");

                pgbProgress.Visible = true;
                pgbProgress.Value = 0;
                pgbProgress.Maximum = objXmlKit.SelectNodes("cyberwares/cyberware").Count;
                int i = 0;
                foreach (XmlNode objXmlCyberware in objXmlKit.SelectNodes("cyberwares/cyberware"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    List<Weapon> objWeapons = new List<Weapon>();
                    List<TreeNode> objWeaponNodes = new List<TreeNode>();
                    TreeNode objNode = new TreeNode();
                    Cyberware objCyberware = new Cyberware(_objCharacter);
                    Grade objGrade = objCyberware.ConvertToCyberwareGrade(objXmlCyberware["grade"].InnerText, Improvement.ImprovementSource.Cyberware);

                    int intRating = 0;
                    if (objXmlCyberware["rating"] != null)
                        intRating = Convert.ToInt32(objXmlCyberware["rating"].InnerText);

                    XmlNode objXmlCyberwareNode = objXmlCyberwareDocument.SelectSingleNode("/chummer/cyberwares/cyberware[name = \"" + objXmlCyberware["name"].InnerText + "\"]");
                    objCyberware.Create(objXmlCyberwareNode, _objCharacter, objGrade, Improvement.ImprovementSource.Cyberware, intRating, objNode, objWeapons, objWeaponNodes, true, blnCreateChildren);
                    _objCharacter.Cyberware.Add(objCyberware);

                    // Add any children.
                    if (objXmlCyberware["cyberwares"] != null)
                    {
                        foreach (XmlNode objXmlChild in objXmlCyberware.SelectNodes("cyberwares/cyberware"))
                        {
                            TreeNode objChildNode = new TreeNode();
                            Cyberware objChildCyberware = new Cyberware(_objCharacter);

                            int intChildRating = 0;
                            if (objXmlChild["rating"] != null)
                                intChildRating = Convert.ToInt32(objXmlChild["rating"].InnerText);

                            XmlNode objXmlChildNode = objXmlCyberwareDocument.SelectSingleNode("/chummer/cyberwares/cyberware[name = \"" + objXmlChild["name"].InnerText + "\"]");
                            objChildCyberware.Create(objXmlChildNode, _objCharacter, objGrade, Improvement.ImprovementSource.Cyberware, intChildRating, objChildNode, objWeapons, objWeaponNodes, true, blnCreateChildren);
                            objCyberware.Children.Add(objChildCyberware);
                            objChildNode.ContextMenuStrip = cmsCyberware;

                            foreach (XmlNode objXmlGear in objXmlChild.SelectNodes("gears/gear"))
                                AddPACKSGear(objXmlGearDocument, objXmlGear, objChildNode, objChildCyberware, cmsCyberwareGear, blnCreateChildren);

                            objNode.Nodes.Add(objChildNode);
                            objNode.Expand();
                        }
                    }

                    foreach (XmlNode objXmlGear in objXmlCyberware.SelectNodes("gears/gear"))
                        AddPACKSGear(objXmlGearDocument, objXmlGear, objNode, objCyberware, cmsCyberwareGear, blnCreateChildren);

                    objNode.ContextMenuStrip = cmsCyberware;
                    treCyberware.Nodes[0].Nodes.Add(objNode);
                    treCyberware.Nodes[0].Expand();

                    // Add any Weapons created by the Gear.
                    foreach (Weapon objWeapon in objWeapons)
                        _objCharacter.Weapons.Add(objWeapon);

                    foreach (TreeNode objWeaponNode in objWeaponNodes)
                    {
                        objWeaponNode.ContextMenuStrip = cmsWeapon;
                        treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                        treWeapons.Nodes[0].Expand();
                    }

                    Application.DoEvents();
                }

                treCyberware.SortCustom();
            }

            // Update Bioware.
            if (objXmlKit["biowares"] != null)
            {
                XmlDocument objXmlBiowareDocument = XmlManager.Instance.Load("bioware.xml");

                pgbProgress.Visible = true;
                pgbProgress.Value = 0;
                pgbProgress.Maximum = objXmlKit.SelectNodes("biowares/bioware").Count;
                int i = 0;

                foreach (XmlNode objXmlBioware in objXmlKit.SelectNodes("biowares/bioware"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    List<Weapon> objWeapons = new List<Weapon>();
                    List<TreeNode> objWeaponNodes = new List<TreeNode>();
                    TreeNode objNode = new TreeNode();
                    Cyberware objCyberware = new Cyberware(_objCharacter);
                    Grade objGrade = objCyberware.ConvertToCyberwareGrade(objXmlBioware["grade"].InnerText, Improvement.ImprovementSource.Bioware);

                    int intRating = 0;
                    if (objXmlBioware["rating"] != null)
                        intRating = Convert.ToInt32(objXmlBioware["rating"].InnerText);

                    XmlNode objXmlBiowareNode = objXmlBiowareDocument.SelectSingleNode("/chummer/biowares/bioware[name = \"" + objXmlBioware["name"].InnerText + "\"]");
                    objCyberware.Create(objXmlBiowareNode, _objCharacter, objGrade, Improvement.ImprovementSource.Bioware, intRating, objNode, objWeapons, objWeaponNodes, true, blnCreateChildren);
                    _objCharacter.Cyberware.Add(objCyberware);

                    objNode.ContextMenuStrip = cmsBioware;
                    treCyberware.Nodes[1].Nodes.Add(objNode);
                    treCyberware.Nodes[1].Expand();

                    // Add any Weapons created by the Gear.
                    foreach (Weapon objWeapon in objWeapons)
                        _objCharacter.Weapons.Add(objWeapon);

                    foreach (TreeNode objWeaponNode in objWeaponNodes)
                    {
                        objWeaponNode.ContextMenuStrip = cmsWeapon;
                        treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                        treWeapons.Nodes[0].Expand();
                    }

                    Application.DoEvents();
                }

                treCyberware.SortCustom();
            }

            // Update Gear.
            if (objXmlKit["gears"] != null)
            {
                XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");

                pgbProgress.Visible = true;
                pgbProgress.Value = 0;
                pgbProgress.Maximum = objXmlKit.SelectNodes("gears/gear").Count;
                int i = 0;

                foreach (XmlNode objXmlGear in objXmlKit.SelectNodes("gears/gear"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    AddPACKSGear(objXmlGearDocument, objXmlGear, treGear.Nodes[0], _objCharacter, cmsGear, blnCreateChildren);

                    Application.DoEvents();
                }
            }

            // Update Vehicles.
            if (objXmlKit["vehicles"] != null)
            {
                XmlDocument objXmlVehicleDocument = XmlManager.Instance.Load("vehicles.xml");

                pgbProgress.Visible = true;
                pgbProgress.Value = 0;
                pgbProgress.Maximum = objXmlKit.SelectNodes("vehicles/vehicle").Count;
                int i = 0;

                foreach (XmlNode objXmlVehicle in objXmlKit.SelectNodes("vehicles/vehicle"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    Gear objDefaultSensor = new Gear(_objCharacter);

                    TreeNode objNode = new TreeNode();
                    Vehicle objVehicle = new Vehicle(_objCharacter);

                    XmlNode objXmlVehicleNode = objXmlVehicleDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + objXmlVehicle["name"].InnerText + "\"]");
                    objVehicle.Create(objXmlVehicleNode, objNode, cmsVehicle, cmsVehicleGear, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod, blnCreateChildren);
                    _objCharacter.Vehicles.Add(objVehicle);

                    // Grab the default Sensor that comes with the Vehicle.
                    foreach (Gear objSensorGear in objVehicle.Gear)
                    {
                        if (objSensorGear.Category == "Sensors" && objSensorGear.Cost == "0" && objSensorGear.Rating == 0)
                        {
                            objDefaultSensor = objSensorGear;
                            break;
                        }
                    }

                    // Add any Vehicle Mods.
                    if (objXmlVehicle["mods"] != null)
                    {
                        foreach (XmlNode objXmlMod in objXmlVehicle.SelectNodes("mods/mod"))
                        {
                            TreeNode objModNode = new TreeNode();
                            VehicleMod objMod = new VehicleMod(_objCharacter);

                            int intRating = 0;
                            if (objXmlMod["rating"] != null)
                                intRating = Convert.ToInt32(objXmlMod["rating"].InnerText);

                            XmlNode objXmlModNode = objXmlVehicleDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlMod["name"].InnerText + "\"]");
                            objMod.Create(objXmlModNode, objModNode, intRating);
                            objVehicle.Mods.Add(objMod);

                            objNode.Nodes.Add(objModNode);
                            objNode.Expand();
                        }
                    }

                    // Add any Vehicle Gear.
                    if (objXmlVehicle["gears"] != null)
                    {
                        XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");

                        foreach (XmlNode objXmlGear in objXmlVehicle.SelectNodes("gears/gear"))
                        {
                            List<Weapon> objWeapons = new List<Weapon>();
                            List<TreeNode> objWeaponNodes = new List<TreeNode>();
                            TreeNode objGearNode = new TreeNode();
                            Gear objGear = new Gear(_objCharacter);
                            int intQty = 1;

                            int intRating = 0;
                            if (objXmlGear["rating"] != null)
                                intRating = Convert.ToInt32(objXmlGear["rating"].InnerText);
                            string strForceValue = "";
                            if (objXmlGear["name"].Attributes["select"] != null)
                                strForceValue = objXmlGear["name"].Attributes["select"].InnerText;
                            if (objXmlGear["qty"] != null)
                                intQty = Convert.ToInt32(objXmlGear["qty"].InnerText);

                            XmlNode objXmlGearNode = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear["name"].InnerText + "\"]");
                            objGear.Create(objXmlGearNode, _objCharacter, objGearNode, intRating, objWeapons, objWeaponNodes, strForceValue, false, false, false, blnCreateChildren, false);
                            objGear.Quantity = intQty;
                            objGearNode.Text = objGear.DisplayName;
                            objVehicle.Gear.Add(objGear);

                            // Look for child components.
                            if (objXmlGear["gears"] != null)
                            {
                                foreach (XmlNode objXmlChild in objXmlGear.SelectNodes("gears/gear"))
                                {
                                    AddPACKSGear(objXmlGearDocument, objXmlChild, objGearNode, objGear, cmsVehicleGear, blnCreateChildren);
                                }
                            }

                            objGearNode.Expand();
                            objGearNode.ContextMenuStrip = cmsVehicleGear;
                            objNode.Nodes.Add(objGearNode);
                            objNode.Expand();

                            // If this is a Sensor, it will replace the Vehicle's base sensor, so remove it.
                            if (objGear.Category == "Sensors" && objGear.Cost == "0" && objGear.Rating == 0)
                            {
                                objVehicle.Gear.Remove(objDefaultSensor);
                                foreach (TreeNode objSensorNode in objNode.Nodes)
                                {
                                    if (objSensorNode.Tag.ToString() == objDefaultSensor.InternalId)
                                    {
                                        objSensorNode.Remove();
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    // Add any Vehicle Weapons.
                    if (objXmlVehicle["weapons"] != null)
                    {
                        XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");

                        foreach (XmlNode objXmlWeapon in objXmlVehicle.SelectNodes("weapons/weapon"))
                        {
                            TreeNode objWeaponNode = new TreeNode();
                            Weapon objWeapon = new Weapon(_objCharacter);

                            XmlNode objXmlWeaponNode = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlWeapon["name"].InnerText + "\"]");
                            objWeapon.Create(objXmlWeaponNode, _objCharacter, objWeaponNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod, blnCreateChildren);
                            objWeapon.VehicleMounted = true;

                            // Find the first Weapon Mount in the Vehicle.
                            foreach (VehicleMod objMod in objVehicle.Mods)
                            {
                                if (objMod.Name.StartsWith("Weapon Mount") || objMod.Name.StartsWith("Heavy Weapon Mount"))
                                {
                                    objMod.Weapons.Add(objWeapon);
                                    foreach (TreeNode objModNode in objNode.Nodes)
                                    {
                                        if (objModNode.Tag.ToString() == objMod.InternalId)
                                        {
                                            objWeaponNode.ContextMenuStrip = cmsVehicleWeapon;
                                            objModNode.Nodes.Add(objWeaponNode);
                                            objModNode.Expand();
                                            break;
                                        }
                                    }
                                    break;
                                }
                            }

                            // Look for Weapon Accessories.
                            if (objXmlWeapon["accessories"] != null)
                            {
                                foreach (XmlNode objXmlAccessory in objXmlWeapon.SelectNodes("accessories/accessory"))
                                {
                                    XmlNode objXmlAccessoryNode = objXmlWeaponDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + objXmlAccessory["name"].InnerText + "\"]");
                                    WeaponAccessory objMod = new WeaponAccessory(_objCharacter);
                                    TreeNode objModNode = new TreeNode();
                                    string strMount = "";
									int intRating = 0;
									if (objXmlAccessory["mount"] != null)
                                        strMount = objXmlAccessory["mount"].InnerText;
                                    objMod.Create(objXmlAccessoryNode, objModNode, strMount,intRating);
                                    objModNode.ContextMenuStrip = cmsWeaponAccessory;
                                    objMod.Parent = objWeapon;

                                    objWeapon.WeaponAccessories.Add(objMod);

                                    objWeaponNode.Nodes.Add(objModNode);
                                    objWeaponNode.Expand();
                                }
                            }

                            // Look for Weapon Mods.
                            if (objXmlWeapon["mods"] != null)
                            {
                                foreach (XmlNode objXmlMod in objXmlWeapon.SelectNodes("mods/mod"))
                                {
                                    XmlNode objXmlModNode = objXmlWeaponDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlMod["name"].InnerText + "\"]");
                                    WeaponMod objMod = new WeaponMod(_objCharacter);
                                    TreeNode objModNode = new TreeNode();
                                    objMod.Create(objXmlModNode, objModNode);
                                    objModNode.ContextMenuStrip = cmsVehicleWeaponMod;
                                    objMod.Parent = objWeapon;

                                    objWeapon.WeaponMods.Add(objMod);

                                    objWeaponNode.Nodes.Add(objModNode);
                                    objWeaponNode.Expand();
                                }
                            }
                        }
                    }

                    objNode.ContextMenuStrip = cmsVehicle;
                    treVehicles.Nodes[0].Nodes.Add(objNode);
                    treVehicles.Nodes[0].Expand();

                    Application.DoEvents();
                }
            }

            pgbProgress.Visible = false;

            if (frmPickPACKSKit.AddAgain)
                AddPACKSKit();

            PopulateGearList();
            UpdateCharacterInfo();
        }
예제 #2
0
        private void frmCreate_Load(object sender, EventArgs e)
        {
            _blnLoading = true;
            if (!_objCharacter.IsCritter && (_objCharacter.BuildMethod == CharacterBuildMethod.BP && _objCharacter.BuildPoints == 0) || (_objCharacter.BuildMethod == CharacterBuildMethod.Karma && _objCharacter.BuildKarma == 0))
            {
                _blnFreestyle = true;
            }

            // Set the Statusbar Labels if we're using Karma to build.
            if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
            {
                tabBPSummary.Text = LanguageManager.Instance.GetString("Tab_BPSummary_Karma");
                lblQualityBPLabel.Text = LanguageManager.Instance.GetString("Label_Karma");
            }

            // Remove the Magician, Adept, and Technomancer tabs since they are not in use until the appropriate Quality is selected.
            if (!_objCharacter.MagicianEnabled)
                tabCharacterTabs.TabPages.Remove(tabMagician);
            if (!_objCharacter.AdeptEnabled)
                tabCharacterTabs.TabPages.Remove(tabAdept);
            if (!_objCharacter.TechnomancerEnabled)
                tabCharacterTabs.TabPages.Remove(tabTechnomancer);
            if (!_objCharacter.CritterEnabled)
                tabCharacterTabs.TabPages.Remove(tabCritter);

            if (_objCharacter.BlackMarket)
            {
                chkCyberwareBlackMarketDiscount.Visible = true;
                chkArmorBlackMarketDiscount.Visible = true;
                chkWeaponBlackMarketDiscount.Visible = true;
                chkGearBlackMarketDiscount.Visible = true;
                chkVehicleBlackMarketDiscount.Visible = true;
            }

            if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
            {
                if (!_objCharacter.MAGEnabled && !_objCharacter.RESEnabled)
                    tabCharacterTabs.TabPages.Remove(tabInitiation);
                else
                {
                    if (_objCharacter.MAGEnabled)
                    {
                        tabInitiation.Text = LanguageManager.Instance.GetString("Tab_Initiation");
                        lblInitiateGradeLabel.Text = LanguageManager.Instance.GetString("Label_InitiationGrade");
                        cmdAddMetamagic.Text = LanguageManager.Instance.GetString("Button_AddMetamagic");
                        chkInitiationGroup.Text = LanguageManager.Instance.GetString("Checkbox_GroupInitiation");
                        chkInitiationOrdeal.Text = LanguageManager.Instance.GetString("Checkbox_InitiationOrdeal");
                        chkJoinGroup.Text = LanguageManager.Instance.GetString("Checkbox_JoinedGroup");
                        chkJoinGroup.Checked = _objCharacter.GroupMember;
                        txtGroupName.Text = _objCharacter.GroupName;
                        txtGroupNotes.Text = _objCharacter.GroupNotes;
                    }
                    else
                    {
                        tabInitiation.Text = LanguageManager.Instance.GetString("Tab_Submersion");
                        lblInitiateGradeLabel.Text = LanguageManager.Instance.GetString("Label_SubmersionGrade");
                        cmdAddMetamagic.Text = LanguageManager.Instance.GetString("Button_AddEcho");
                        chkInitiationGroup.Text = LanguageManager.Instance.GetString("Checkbox_NetworkSubmersion");
                        chkInitiationOrdeal.Text = LanguageManager.Instance.GetString("Checkbox_SubmersionTask");
                        chkJoinGroup.Text = LanguageManager.Instance.GetString("Checkbox_JoinedNetwork");
                        chkJoinGroup.Checked = _objCharacter.GroupMember;
                        txtGroupName.Text = _objCharacter.GroupName;
                        txtGroupNotes.Text = _objCharacter.GroupNotes;
                    }
                }
            }
            else
            {
                if (!_objCharacter.InitiationEnabled)
                    tabCharacterTabs.TabPages.Remove(tabInitiation);
            }

            // If the character has a mugshot, decode it and put it in the PictureBox.
            if (_objCharacter.Mugshot != "")
            {
                byte[] bytImage = Convert.FromBase64String(_objCharacter.Mugshot);
                MemoryStream objStream = new MemoryStream(bytImage, 0, bytImage.Length);
                objStream.Write(bytImage, 0, bytImage.Length);
                Image imgMugshot = Image.FromStream(objStream, true);
                picMugshot.Image = imgMugshot;
            }

            // Populate character information fields.
            XmlDocument objMetatypeDoc = new XmlDocument();
            XmlNode objMetatypeNode;
            string strMetatype = "";
            string strBook = "";
            string strPage = "";

            objMetatypeDoc = XmlManager.Instance.Load("metatypes.xml");
            {
                objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
                if (objMetatypeNode == null)
                    objMetatypeDoc = XmlManager.Instance.Load("critters.xml");
                objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");

                if (objMetatypeNode["translate"] != null)
                    strMetatype = objMetatypeNode["translate"].InnerText;
                else
                    strMetatype = _objCharacter.Metatype;

                strBook = _objOptions.LanguageBookShort(objMetatypeNode["source"].InnerText);
                if (objMetatypeNode["altpage"] != null)
                    strPage = objMetatypeNode["altpage"].InnerText;
                else
                    strPage = objMetatypeNode["page"].InnerText;

                if (_objCharacter.Metavariant != "")
                {
                    objMetatypeNode = objMetatypeNode.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]");

                    if (objMetatypeNode["translate"] != null)
                        strMetatype += " (" + objMetatypeNode["translate"].InnerText + ")";
                    else
                        strMetatype += " (" + _objCharacter.Metavariant + ")";

                    strBook = _objOptions.LanguageBookShort(objMetatypeNode["source"].InnerText);
                    if (objMetatypeNode["altpage"] != null)
                        strPage = objMetatypeNode["altpage"].InnerText;
                    else
                        strPage = objMetatypeNode["page"].InnerText;
                }
            }
            lblMetatype.Text = strMetatype;
            lblMetatypeSource.Text = strBook + " " + strPage;
            txtCharacterName.Text = _objCharacter.Name;
            txtSex.Text = _objCharacter.Sex;
            txtAge.Text = _objCharacter.Age;
            txtEyes.Text = _objCharacter.Eyes;
            txtHeight.Text = _objCharacter.Height;
            txtWeight.Text = _objCharacter.Weight;
            txtSkin.Text = _objCharacter.Skin;
            txtHair.Text = _objCharacter.Hair;
            txtDescription.Text = _objCharacter.Description;
            txtBackground.Text = _objCharacter.Background;
            txtConcept.Text = _objCharacter.Concept;
            txtNotes.Text = _objCharacter.Notes;
            txtAlias.Text = _objCharacter.Alias;
            txtPlayerName.Text = _objCharacter.PlayerName;

            // Check for Special Attributes.
            lblMAGLabel.Enabled = _objCharacter.MAGEnabled;
            lblMAGAug.Enabled = _objCharacter.MAGEnabled;
            nudMAG.Enabled = _objCharacter.MAGEnabled;
            lblMAGMetatype.Enabled = _objCharacter.MAGEnabled;
            lblFoci.Visible = _objCharacter.MAGEnabled;
            treFoci.Visible = _objCharacter.MAGEnabled;
            cmdCreateStackedFocus.Visible = _objCharacter.MAGEnabled;

            lblRESLabel.Enabled = _objCharacter.RESEnabled;
            lblRESAug.Enabled = _objCharacter.RESEnabled;
            nudRES.Enabled = _objCharacter.RESEnabled;
            lblRESMetatype.Enabled = _objCharacter.RESEnabled;

            // Define the XML objects that will be used.
            XmlDocument objXmlDocument = new XmlDocument();

            // Populate the Qualities list.
            foreach (Quality objQuality in _objCharacter.Qualities)
            {
                TreeNode objNode = new TreeNode();
                objNode.Text = objQuality.DisplayName;
                objNode.Tag = objQuality.InternalId;
                objNode.ContextMenuStrip = cmsQuality;

                if (objQuality.Notes != string.Empty)
                    objNode.ForeColor = Color.SaddleBrown;
                else
                {
                    if (objQuality.OriginSource == QualitySource.Metatype || objQuality.OriginSource == QualitySource.MetatypeRemovable)
                        objNode.ForeColor = SystemColors.GrayText;
                }
                objNode.ToolTipText = objQuality.Notes;

                if (objQuality.Type == QualityType.Positive)
                {
                    treQualities.Nodes[0].Nodes.Add(objNode);
                    treQualities.Nodes[0].Expand();
                }
                else
                {
                    treQualities.Nodes[1].Nodes.Add(objNode);
                    treQualities.Nodes[1].Expand();
                }
            }

            // Populate the Magician Traditions list.
            objXmlDocument = XmlManager.Instance.Load("traditions.xml");
            List<ListItem> lstTraditions = new List<ListItem>();
            ListItem objBlank = new ListItem();
            objBlank.Value = "";
            objBlank.Name = "";
            lstTraditions.Add(objBlank);
            foreach (XmlNode objXmlTradition in objXmlDocument.SelectNodes("/chummer/traditions/tradition[" + _objOptions.BookXPath() + "]"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlTradition["id"].InnerText;
                if (objXmlTradition["translate"] != null)
                    objItem.Name = objXmlTradition["translate"].InnerText;
                else
                    objItem.Name = objXmlTradition["name"].InnerText;
                lstTraditions.Add(objItem);
            }
            SortListItem objSort = new SortListItem();
            lstTraditions.Sort(objSort.Compare);
            cboTradition.ValueMember = "Value";
            cboTradition.DisplayMember = "Name";
            cboTradition.DataSource = lstTraditions;

            // Populate the Technomancer Streams list.
            objXmlDocument = XmlManager.Instance.Load("streams.xml");
            List<ListItem> lstStreams = new List<ListItem>();
            lstStreams.Add(objBlank);
            foreach (XmlNode objXmlTradition in objXmlDocument.SelectNodes("/chummer/traditions/tradition[" + _objOptions.BookXPath() + "]"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlTradition["id"].InnerText;
                if (objXmlTradition["translate"] != null)
                    objItem.Name = objXmlTradition["translate"].InnerText;
                else
                    objItem.Name = objXmlTradition["name"].InnerText;
                lstStreams.Add(objItem);
            }
            lstStreams.Sort(objSort.Compare);
            cboStream.ValueMember = "Value";
            cboStream.DisplayMember = "Name";
            cboStream.DataSource = lstStreams;

            // Load the Metatype information before going anywhere else. Doing this later causes the Attributes to get messed up because of calls
            // to UpdateCharacterInformation();
            MetatypeSelected();

            // If the character is a Mystic Adept, set the values for the Mystic Adept NUD.
            if (_objCharacter.AdeptEnabled && _objCharacter.MagicianEnabled)
            {
                nudMysticAdeptMAGMagician.Maximum = _objCharacter.MAG.TotalValue;
                nudMysticAdeptMAGMagician.Value = _objCharacter.MAGMagician;
                lblMysticAdeptMAGAdept.Text = _objCharacter.MAGAdept.ToString();

                lblMysticAdeptAssignment.Visible = true;
                lblMysticAdeptAssignmentAdept.Visible = true;
                lblMysticAdeptAssignmentMagician.Visible = true;
                lblMysticAdeptMAGAdept.Visible = true;
                nudMysticAdeptMAGMagician.Visible = true;
            }

            // Nuyen can be affected by Qualities, so adjust the total amount available to the character.
            if (!_objCharacter.IgnoreRules)
                nudNuyen.Maximum = _objCharacter.NuyenMaximumBP;
            else
                nudNuyen.Maximum = 100000;

            // Nuyen.
            nudNuyen.Value = _objCharacter.NuyenBP;

            // Load the Skills information.
            objXmlDocument = XmlManager.Instance.Load("skills.xml");

            // Populate the Skills Controls.
            XmlNodeList objXmlNodeList = objXmlDocument.SelectNodes("/chummer/skills/skill[" + _objCharacter.Options.BookXPath() + "]");
            // Counter to keep track of the number of Controls that have been added to the Panel so we can determine their vertical positioning.
            int i = -1;
            foreach (Skill objSkill in _objCharacter.Skills)
            {
                if (!objSkill.KnowledgeSkill && !objSkill.ExoticSkill)
                {
                    i++;
                    SkillControl objSkillControl = new SkillControl();
                    objSkillControl.SkillObject = objSkill;

                    // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                    objSkillControl.RatingChanged += objActiveSkill_RatingChanged;
                    objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                    objSkillControl.BreakGroupClicked += objSkill_BreakGroupClicked;

                    objSkillControl.SkillName = objSkill.Name;
                    objSkillControl.SkillCategory = objSkill.SkillCategory;
                    objSkillControl.SkillGroup = objSkill.SkillGroup;
                    objSkillControl.SkillRatingMaximum = objSkill.RatingMaximum;
                    objSkillControl.SkillRating = objSkill.Rating;
                    objSkillControl.SkillSpec = objSkill.Specialization;

                    XmlNode objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + objSkill.Name + "\"]");
                    // Populate the Skill's Specializations (if any).
                    foreach (XmlNode objXmlSpecialization in objXmlSkill.SelectNodes("specs/spec"))
                    {
                        if (objXmlSpecialization.Attributes["translate"] != null)
                            objSkillControl.AddSpec(objXmlSpecialization.Attributes["translate"].InnerText);
                        else
                            objSkillControl.AddSpec(objXmlSpecialization.InnerText);
                    }

                    // Set the control's vertical position and add it to the Skills Panel.
                    objSkillControl.Top = i * objSkillControl.Height;
                    objSkillControl.Width = 510;
                    objSkillControl.AutoScroll = false;
                    panActiveSkills.Controls.Add(objSkillControl);
                }
            }

            // Exotic Skills.
            foreach (Skill objSkill in _objCharacter.Skills)
            {
                if (objSkill.ExoticSkill)
                {
                    i++;
                    SkillControl objSkillControl = new SkillControl();
                    objSkillControl.SkillObject = objSkill;

                    // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                    objSkillControl.RatingChanged += objActiveSkill_RatingChanged;
                    objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                    objSkillControl.BreakGroupClicked += objSkill_BreakGroupClicked;

                    objSkillControl.SkillName = objSkill.Name;
                    objSkillControl.SkillCategory = objSkill.SkillCategory;
                    objSkillControl.SkillGroup = objSkill.SkillGroup;
                    objSkillControl.SkillRatingMaximum = objSkill.RatingMaximum;
                    objSkillControl.SkillRating = objSkill.Rating;
                    objSkillControl.SkillSpec = objSkill.Specialization;

                    XmlNode objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + objSkill.Name + "\"]");
                    // Populate the Skill's Specializations (if any).
                    foreach (XmlNode objXmlSpecialization in objXmlSkill.SelectNodes("specs/spec"))
                    {
                        if (objXmlSpecialization.Attributes["translate"] != null)
                            objSkillControl.AddSpec(objXmlSpecialization.Attributes["translate"].InnerText);
                        else
                            objSkillControl.AddSpec(objXmlSpecialization.InnerText);
                    }

                    // Look through the Weapons file and grab the names of items that are part of the appropriate Exotic Category or use the matching Exoctic Skill.
                    XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");
                    XmlNodeList objXmlWeaponList = objXmlWeaponDocument.SelectNodes("/chummer/weapons/weapon[category = \"" + objSkill.Name + "s\" or useskill = \"" + objSkill.Name + "\"]");
                    foreach (XmlNode objXmlWeapon in objXmlWeaponList)
                    {
                        if (objXmlWeapon["translate"] != null)
                            objSkillControl.AddSpec(objXmlWeapon["translate"].InnerText);
                        else
                            objSkillControl.AddSpec(objXmlWeapon["name"].InnerText);
                    }

                    // Set the control's vertical position and add it to the Skills Panel.
                    objSkillControl.Top = i * objSkillControl.Height;
                    objSkillControl.Width = 510;
                    objSkillControl.AutoScroll = false;
                    panActiveSkills.Controls.Add(objSkillControl);
                }
            }

            // Populate the Skill Groups list.
            i = -1;
            foreach (SkillGroup objGroup in _objCharacter.SkillGroups)
            {
                i++;
                SkillGroupControl objGroupControl = new SkillGroupControl(_objCharacter.Options);
                objGroupControl.SkillGroupObject = objGroup;

                // Attach an EventHandler for the GetRatingChanged Event.
                objGroupControl.GroupRatingChanged += objGroup_RatingChanged;

                // Populate the control, set its vertical position and add it to the Skill Groups Panel. A Skill Group cannot start with a Rating higher than 4.
                objGroupControl.GroupName = objGroup.Name;
                if (objGroup.Rating > objGroup.RatingMaximum)
                    objGroup.RatingMaximum = objGroup.Rating;
                objGroupControl.GroupRatingMaximum = objGroup.RatingMaximum;
                objGroupControl.GroupRating = objGroup.Rating;
                objGroupControl.Top = i * objGroupControl.Height;
                objGroupControl.Width = 250;

                // Loop through all of the Active Skills the character has and set their maximums if needed.
                if (objGroup.RatingMaximum > 6)
                {
                    foreach (SkillControl objSkill in panActiveSkills.Controls)
                    {
                        if (objSkill.IsGrouped && objSkill.SkillGroup == objGroup.Name)
                        {
                            objSkill.SkillRatingMaximum = objGroup.RatingMaximum;
                            objSkill.SkillObject.RatingMaximum = objGroup.RatingMaximum;
                            objSkill.SkillRating = objGroup.Rating;
                        }
                    }
                }

                if (_objCharacter.SensitiveSystem)
                {
                    cmdAddBioware.Enabled = false;
                }

                if (_objCharacter.Uneducated)
                {
                    objGroupControl.IsEnabled = !objGroup.HasTechnicalSkills;
                }

                if (_objCharacter.Uncouth)
                {
                    objGroupControl.IsEnabled = !objGroup.HasSocialSkills;
                }

                if (_objCharacter.Infirm)
                {
                    objGroupControl.IsEnabled = !objGroup.HasPhysicalSkills;
                }

                panSkillGroups.Controls.Add(objGroupControl);
            }

            // Populate Knowledge Skills.
            i = -1;
            foreach (Skill objSkill in _objCharacter.Skills)
            {
                if (objSkill.KnowledgeSkill)
                {
                    i++;
                    SkillControl objSkillControl = new SkillControl();
                    objSkillControl.SkillObject = objSkill;

                    // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                    objSkillControl.RatingChanged += objKnowledgeSkill_RatingChanged;
                    objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                    objSkillControl.DeleteSkill += objKnowledgeSkill_DeleteSkill;
                    objSkillControl.BreakGroupClicked += objSkill_BreakGroupClicked;

                    objSkillControl.KnowledgeSkill = true;
                    objSkillControl.SkillCategory = objSkill.SkillCategory;
                    objSkillControl.AllowDelete = true;
                    objSkillControl.SkillRatingMaximum = objSkill.RatingMaximum;
                    objSkillControl.SkillRating = objSkill.Rating;
                    objSkillControl.SkillName = objSkill.Name;
                    objSkillControl.SkillSpec = objSkill.Specialization;
                    objSkillControl.Top = i * objSkillControl.Height;
                    objSkillControl.AutoScroll = false;
                    panKnowledgeSkills.Controls.Add(objSkillControl);
                }
            }

            // Populate Contacts and Enemies.
            int intContact = -1;
            int intEnemy = -1;
            foreach (Contact objContact in _objCharacter.Contacts)
            {
                if (objContact.EntityType == ContactType.Contact)
                {
                    intContact++;
                    ContactControl objContactControl = new ContactControl();
                    // Attach an EventHandler for the ConnectionRatingChanged, LoyaltyRatingChanged, DeleteContact, and FileNameChanged Events.
                    objContactControl.ConnectionRatingChanged += objContact_ConnectionRatingChanged;
                    objContactControl.ConnectionGroupRatingChanged += objContact_ConnectionGroupRatingChanged;
                    objContactControl.LoyaltyRatingChanged += objContact_LoyaltyRatingChanged;
                    objContactControl.DeleteContact += objContact_DeleteContact;
                    objContactControl.FileNameChanged += objContact_FileNameChanged;

                    objContactControl.ContactObject = objContact;
                    objContactControl.ContactName = objContact.Name;
                    objContactControl.ConnectionRating = objContact.Connection;
                    objContactControl.LoyaltyRating = objContact.Loyalty;
                    objContactControl.EntityType = objContact.EntityType;
                    objContactControl.BackColor = objContact.Colour;

                    objContactControl.Top = intContact * objContactControl.Height;
                    panContacts.Controls.Add(objContactControl);
                }
                if (objContact.EntityType == ContactType.Enemy)
                {
                    intEnemy++;
                    ContactControl objContactControl = new ContactControl();
                    // Attach an EventHandler for the ConnectioNRatingChanged, LoyaltyRatingChanged, DeleteContact, and FileNameChanged Events.
                    objContactControl.ConnectionRatingChanged += objEnemy_ConnectionRatingChanged;
                    objContactControl.ConnectionGroupRatingChanged += objEnemy_ConnectionGroupRatingChanged;
                    objContactControl.LoyaltyRatingChanged += objEnemy_LoyaltyRatingChanged;
                    objContactControl.DeleteContact += objEnemy_DeleteContact;
                    objContactControl.FileNameChanged += objEnemy_FileNameChanged;

                    objContactControl.ContactObject = objContact;
                    objContactControl.ContactName = objContact.Name;
                    objContactControl.ConnectionRating = objContact.Connection;
                    objContactControl.LoyaltyRating = objContact.Loyalty;
                    objContactControl.EntityType = objContact.EntityType;
                    objContactControl.BackColor = objContact.Colour;

                    objContactControl.Top = intEnemy * objContactControl.Height;
                    panEnemies.Controls.Add(objContactControl);
                }
                if (objContact.EntityType == ContactType.Pet)
                {
                    PetControl objContactControl = new PetControl();
                    // Attach an EventHandler for the DeleteContact and FileNameChanged Events.
                    objContactControl.DeleteContact += objPet_DeleteContact;
                    objContactControl.FileNameChanged += objPet_FileNameChanged;

                    objContactControl.ContactObject = objContact;
                    objContactControl.ContactName = objContact.Name;
                    objContactControl.BackColor = objContact.Colour;

                    panPets.Controls.Add(objContactControl);
                }
            }

            // Populate Armor.
            // Start by populating Locations.
            foreach (string strLocation in _objCharacter.ArmorBundles)
            {
                TreeNode objLocation = new TreeNode();
                objLocation.Tag = strLocation;
                objLocation.Text = strLocation;
                objLocation.ContextMenuStrip = cmsArmorLocation;
                treArmor.Nodes.Add(objLocation);
            }
            foreach (Armor objArmor in _objCharacter.Armor)
            {
                _objFunctions.CreateArmorTreeNode(objArmor, treArmor, cmsArmor, cmsArmorMod, cmsArmorGear);
            }

            // Populate Weapons.
            // Start by populating Locations.
            foreach (string strLocation in _objCharacter.WeaponLocations)
            {
                TreeNode objLocation = new TreeNode();
                objLocation.Tag = strLocation;
                objLocation.Text = strLocation;
                objLocation.ContextMenuStrip = cmsWeaponLocation;
                treWeapons.Nodes.Add(objLocation);
            }
            foreach (Weapon objWeapon in _objCharacter.Weapons)
            {
                _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponMod, cmsWeaponAccessory, cmsWeaponAccessoryGear);
            }

            PopulateCyberwareList();

            // Populate Spell list.
            foreach (Spell objSpell in _objCharacter.Spells)
            {
                TreeNode objNode = new TreeNode();
                objNode.Text = objSpell.DisplayName;
                objNode.Tag = objSpell.InternalId;
                objNode.ContextMenuStrip = cmsSpell;
                if (objSpell.Notes != string.Empty)
                    objNode.ForeColor = Color.SaddleBrown;
                objNode.ToolTipText = objSpell.Notes;

                switch (objSpell.Category)
                {
                    case "Combat":
                        treSpells.Nodes[0].Nodes.Add(objNode);
                        treSpells.Nodes[0].Expand();
                        break;
                    case "Detection":
                        treSpells.Nodes[1].Nodes.Add(objNode);
                        treSpells.Nodes[1].Expand();
                        break;
                    case "Health":
                        treSpells.Nodes[2].Nodes.Add(objNode);
                        treSpells.Nodes[2].Expand();
                        break;
                    case "Illusion":
                        treSpells.Nodes[3].Nodes.Add(objNode);
                        treSpells.Nodes[3].Expand();
                        break;
                    case "Manipulation":
                        treSpells.Nodes[4].Nodes.Add(objNode);
                        treSpells.Nodes[4].Expand();
                        break;
                }
            }

            // Populate Adept Powers.
            i = -1;
            foreach (Power objPower in _objCharacter.Powers)
            {
                i++;
                PowerControl objPowerControl = new PowerControl();
                objPowerControl.PowerObject = objPower;

                // Attach an EventHandler for the PowerRatingChanged Event.
                objPowerControl.PowerRatingChanged += objPower_PowerRatingChanged;
                objPowerControl.DeletePower += objPower_DeletePower;

                objPowerControl.RefreshMaximum(_objCharacter.MAG.TotalValue);
                if (objPower.Rating < 1)
                    objPower.Rating = 1;
                objPowerControl.PowerLevel = Convert.ToInt32(objPower.Rating);
                if (objPower.DiscountedAdeptWay)
                    objPowerControl.DiscountedByAdeptWay = true;
                if (objPower.DiscountedGeas)
                    objPowerControl.DiscountedByGeas = true;

                objPowerControl.Top = i * objPowerControl.Height;
                panPowers.Controls.Add(objPowerControl);
            }

            // Populate Magician Spirits.
            i = -1;
            foreach (Spirit objSpirit in _objCharacter.Spirits)
            {
                if (objSpirit.EntityType == SpiritType.Spirit)
                {
                    i++;
                    SpiritControl objSpiritControl = new SpiritControl();
                    objSpiritControl.SpiritObject = objSpirit;

                    // Attach an EventHandler for the ServicesOwedChanged Event.
                    objSpiritControl.ServicesOwedChanged += objSpirit_ServicesOwedChanged;
                    objSpiritControl.ForceChanged += objSpirit_ForceChanged;
                    objSpiritControl.BoundChanged += objSpirit_BoundChanged;
                    objSpiritControl.DeleteSpirit += objSpirit_DeleteSpirit;
                    objSpiritControl.FileNameChanged += objSpirit_FileNameChanged;

                    objSpiritControl.SpiritName = objSpirit.Name;
                    objSpiritControl.ServicesOwed = objSpirit.ServicesOwed;
                    if (_objCharacter.AdeptEnabled && _objCharacter.MagicianEnabled)
                        objSpiritControl.ForceMaximum = _objCharacter.MAGMagician;
                    else
                        objSpiritControl.ForceMaximum = _objCharacter.MAG.TotalValue;
                    objSpiritControl.CritterName = objSpirit.CritterName;
                    objSpiritControl.Force = objSpirit.Force;
                    objSpiritControl.Bound = objSpirit.Bound;
                    objSpiritControl.RebuildSpiritList(_objCharacter.MagicTradition);

                    objSpiritControl.Top = i * objSpiritControl.Height;
                    panSpirits.Controls.Add(objSpiritControl);
                }
            }

            // Populate Technomancer Sprites.
            i = -1;
            foreach (Spirit objSpirit in _objCharacter.Spirits)
            {
                if (objSpirit.EntityType == SpiritType.Sprite)
                {
                    i++;
                    SpiritControl objSpiritControl = new SpiritControl();
                    objSpiritControl.SpiritObject = objSpirit;
                    objSpiritControl.EntityType = SpiritType.Sprite;

                    // Attach an EventHandler for the ServicesOwedChanged Event.
                    objSpiritControl.ServicesOwedChanged += objSprite_ServicesOwedChanged;
                    objSpiritControl.ForceChanged += objSprite_ForceChanged;
                    objSpiritControl.BoundChanged += objSprite_BoundChanged;
                    objSpiritControl.DeleteSpirit += objSprite_DeleteSpirit;
                    objSpiritControl.FileNameChanged += objSprite_FileNameChanged;

                    objSpiritControl.SpiritName = objSpirit.Name;
                    objSpiritControl.ServicesOwed = objSpirit.ServicesOwed;
                    objSpiritControl.ForceMaximum = _objCharacter.RES.TotalValue;
                    objSpiritControl.CritterName = objSpiritControl.CritterName;
                    objSpiritControl.Force = objSpirit.Force;
                    objSpiritControl.Bound = objSpirit.Bound;
                    objSpiritControl.RebuildSpiritList(_objCharacter.TechnomancerStream);

                    objSpiritControl.Top = i * objSpiritControl.Height;
                    panSprites.Controls.Add(objSpiritControl);
                }
            }

            // Populate Technomancer Complex Forms/Programs.
            foreach (TechProgram objProgram in _objCharacter.TechPrograms)
            {
                TreeNode objNode = new TreeNode();
                objNode.Text = objProgram.DisplayName;
                if (objProgram.Extra != "")
                    objNode.Text += " (" + objProgram.Extra + ")";
                objNode.Tag = objProgram.InternalId;
                if (Convert.ToInt32(objProgram.CalculatedCapacity) > 0)
                    objNode.ContextMenuStrip = cmsComplexForm;
                if (objProgram.Notes != string.Empty)
                    objNode.ForeColor = Color.SaddleBrown;
                objNode.ToolTipText = objProgram.Notes;

                foreach (TechProgramOption objOption in objProgram.Options)
                {
                    TreeNode objChild = new TreeNode();
                    objChild.Text = objOption.DisplayName;
                    objChild.ContextMenuStrip = cmsComplexFormPlugin;
                    if (objOption.Extra != "")
                        objChild.Text += " (" + objProgram.Extra + ")";
                    objChild.Tag = objOption.InternalId;
                    if (objOption.Notes != string.Empty)
                        objChild.ForeColor = Color.SaddleBrown;
                    objChild.ToolTipText = objOption.Notes;
                    objNode.Nodes.Add(objChild);
                    objNode.Expand();
                }

                switch (objProgram.Category)
                {
                    case "Advanced":
                        treComplexForms.Nodes[0].Nodes.Add(objNode);
                        treComplexForms.Nodes[0].Expand();
                        break;
                    case "ARE Programs":
                        treComplexForms.Nodes[1].Nodes.Add(objNode);
                        treComplexForms.Nodes[1].Expand();
                        break;
                    case "Autosoft":
                        treComplexForms.Nodes[2].Nodes.Add(objNode);
                        treComplexForms.Nodes[2].Expand();
                        break;
                    case "Common Use":
                        treComplexForms.Nodes[3].Nodes.Add(objNode);
                        treComplexForms.Nodes[3].Expand();
                        break;
                    case "Hacking":
                        treComplexForms.Nodes[4].Nodes.Add(objNode);
                        treComplexForms.Nodes[4].Expand();
                        break;
                    case "Malware":
                        treComplexForms.Nodes[5].Nodes.Add(objNode);
                        treComplexForms.Nodes[5].Expand();
                        break;
                    case "Sensor Software":
                        treComplexForms.Nodes[6].Nodes.Add(objNode);
                        treComplexForms.Nodes[6].Expand();
                        break;
                    case "Skillsofts":
                        treComplexForms.Nodes[7].Nodes.Add(objNode);
                        treComplexForms.Nodes[7].Expand();
                        break;
                    case "Tactical AR Software":
                        treComplexForms.Nodes[8].Nodes.Add(objNode);
                        treComplexForms.Nodes[8].Expand();
                        break;
                }
            }

            // Populate Martial Arts.
            foreach (MartialArt objMartialArt in _objCharacter.MartialArts)
            {
                TreeNode objMartialArtNode = new TreeNode();
                objMartialArtNode.Text = objMartialArt.DisplayName;
                objMartialArtNode.Tag = objMartialArt.Name;
                objMartialArtNode.ContextMenuStrip = cmsMartialArts;
                if (objMartialArt.Notes != string.Empty)
                    objMartialArtNode.ForeColor = Color.SaddleBrown;
                objMartialArtNode.ToolTipText = objMartialArt.Notes;

                foreach (MartialArtAdvantage objAdvantage in objMartialArt.Advantages)
                {
                    TreeNode objAdvantageNode = new TreeNode();
                    objAdvantageNode.Text = objAdvantage.DisplayName;
                    objAdvantageNode.Tag = objAdvantage.InternalId;
                    objMartialArtNode.Nodes.Add(objAdvantageNode);
                    objMartialArtNode.Expand();
                }

                treMartialArts.Nodes[0].Nodes.Add(objMartialArtNode);
                treMartialArts.Nodes[0].Expand();
            }

            // Populate Martial Art Maneuvers.
            foreach (MartialArtManeuver objManeuver in _objCharacter.MartialArtManeuvers)
            {
                TreeNode objManeuverNode = new TreeNode();
                objManeuverNode.Text = objManeuver.DisplayName;
                objManeuverNode.Tag = objManeuver.InternalId;
                objManeuverNode.ContextMenuStrip = cmsMartialArtManeuver;
                if (objManeuver.Notes != string.Empty)
                    objManeuverNode.ForeColor = Color.SaddleBrown;
                objManeuverNode.ToolTipText = objManeuver.Notes;

                treMartialArts.Nodes[1].Nodes.Add(objManeuverNode);
                treMartialArts.Nodes[1].Expand();
            }

            // Populate Lifestyles.
            foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
            {
                TreeNode objLifestyleNode = new TreeNode();
                objLifestyleNode.Text = objLifestyle.DisplayName;
                objLifestyleNode.Tag = objLifestyle.InternalId;
                if (objLifestyle.Comforts != "")
                    objLifestyleNode.ContextMenuStrip = cmsAdvancedLifestyle;
                else
                    objLifestyleNode.ContextMenuStrip = cmsLifestyleNotes;
                if (objLifestyle.Notes != string.Empty)
                    objLifestyleNode.ForeColor = Color.SaddleBrown;
                objLifestyleNode.ToolTipText = objLifestyle.Notes;
                treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode);
            }
            treLifestyles.Nodes[0].Expand();

            PopulateGearList();

            // Populate Foci.
            _objController.PopulateFocusList(treFoci);

            // Populate Vehicles.
            foreach (Vehicle objVehicle in _objCharacter.Vehicles)
            {
                _objFunctions.CreateVehicleTreeNode(objVehicle, treVehicles, cmsVehicle, cmsVehicleLocation, cmsVehicleWeapon, cmsVehicleWeaponMod, cmsVehicleWeaponAccessory, cmsVehicleWeaponAccessoryGear, cmsVehicleGear);
            }

            // Populate Initiation/Submersion information.
            if (_objCharacter.InitiateGrade > 0 || _objCharacter.SubmersionGrade > 0)
            {
                foreach (Metamagic objMetamagic in _objCharacter.Metamagics)
                {
                    TreeNode objNode = new TreeNode();
                    objNode.Text = objMetamagic.DisplayName;
                    objNode.Tag = objMetamagic.InternalId;
                    objNode.ContextMenuStrip = cmsMetamagic;
                    if (objMetamagic.Notes != string.Empty)
                        objNode.ForeColor = Color.SaddleBrown;
                    objNode.ToolTipText = objMetamagic.Notes;
                    treMetamagic.Nodes.Add(objNode);
                }

                if (_objCharacter.InitiateGrade > 0)
                    lblInitiateGrade.Text = _objCharacter.InitiateGrade.ToString();
                else
                    lblInitiateGrade.Text = _objCharacter.SubmersionGrade.ToString();
            }

            // Populate Critter Powers.
            foreach (CritterPower objPower in _objCharacter.CritterPowers)
            {
                TreeNode objNode = new TreeNode();
                objNode.Text = objPower.DisplayName;
                objNode.Tag = objPower.InternalId;
                objNode.ContextMenuStrip = cmsCritterPowers;
                if (objPower.Notes != string.Empty)
                    objNode.ForeColor = Color.SaddleBrown;
                objNode.ToolTipText = objPower.Notes;

                if (objPower.Category != "Weakness")
                {
                    treCritterPowers.Nodes[0].Nodes.Add(objNode);
                    treCritterPowers.Nodes[0].Expand();
                }
                else
                {
                    treCritterPowers.Nodes[1].Nodes.Add(objNode);
                    treCritterPowers.Nodes[1].Expand();
                }
            }

            // Load the Cyberware information.
            objXmlDocument = XmlManager.Instance.Load("cyberware.xml");

            // Populate the Grade list.
            List<ListItem> lstCyberwareGrades = new List<ListItem>();
            foreach (Grade objGrade in GlobalOptions.CyberwareGrades)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objGrade.Name;
                objItem.Name = objGrade.DisplayName;
                lstCyberwareGrades.Add(objItem);
            }
            cboCyberwareGrade.ValueMember = "Value";
            cboCyberwareGrade.DisplayMember = "Name";
            cboCyberwareGrade.DataSource = lstCyberwareGrades;

            _blnLoading = false;

            // Select the Magician's Tradition.
            if (_objCharacter.MagicTradition != Guid.Empty)
                cboTradition.SelectedValue = _objCharacter.MagicTradition;

            // Select the Technomancer's Stream.
            if (_objCharacter.TechnomancerStream != Guid.Empty)
                cboStream.SelectedValue = _objCharacter.TechnomancerStream;

            // Clear the Dirty flag which gets set when creating a new Character.
            CalculateBP();
            _blnIsDirty = false;
            UpdateWindowTitle();
            if (_objCharacter.AdeptEnabled)
                CalculatePowerPoints();

            treGear.ItemDrag += treGear_ItemDrag;
            treGear.DragEnter += treGear_DragEnter;
            treGear.DragDrop += treGear_DragDrop;

            treLifestyles.ItemDrag += treLifestyles_ItemDrag;
            treLifestyles.DragEnter += treLifestyles_DragEnter;
            treLifestyles.DragDrop += treLifestyles_DragDrop;

            treArmor.ItemDrag += treArmor_ItemDrag;
            treArmor.DragEnter += treArmor_DragEnter;
            treArmor.DragDrop += treArmor_DragDrop;

            treWeapons.ItemDrag += treWeapons_ItemDrag;
            treWeapons.DragEnter += treWeapons_DragEnter;
            treWeapons.DragDrop += treWeapons_DragDrop;

            treVehicles.ItemDrag += treVehicles_ItemDrag;
            treVehicles.DragEnter += treVehicles_DragEnter;
            treVehicles.DragDrop += treVehicles_DragDrop;

            treImprovements.ItemDrag += treImprovements_ItemDrag;
            treImprovements.DragEnter += treImprovements_DragEnter;
            treImprovements.DragDrop += treImprovements_DragDrop;

            // Merge the ToolStrips.
            ToolStripManager.RevertMerge("toolStrip");
            ToolStripManager.Merge(toolStrip, "toolStrip");

            // If this is a Sprite, re-label the Mental Attribute Labels.
            if (_objCharacter.Metatype.EndsWith("Sprite"))
            {
                lblBODLabel.Enabled = false;
                nudBOD.Enabled = false;
                lblAGILabel.Enabled = false;
                nudAGI.Enabled = false;
                lblREALabel.Enabled = false;
                nudREA.Enabled = false;
                lblSTRLabel.Enabled = false;
                nudSTR.Enabled = false;
                lblCHALabel.Text = LanguageManager.Instance.GetString("String_AttributePilot");
                lblINTLabel.Text = LanguageManager.Instance.GetString("String_AttributeResponse");
                lblLOGLabel.Text = LanguageManager.Instance.GetString("String_AttributeFirewall");
                lblWILLabel.Enabled = false;
                nudWIL.Enabled = false;
            }
            else if (_objCharacter.Metatype.EndsWith("A.I.") || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients")
            {
                lblRatingLabel.Visible = true;
                lblRating.Visible = true;
                lblSystemLabel.Visible = true;
                lblSystem.Visible = true;
                lblFirewallLabel.Visible = true;
                lblFirewall.Visible = true;
                lblResponseLabel.Visible = true;
                nudResponse.Visible = true;
                nudResponse.Enabled = true;
                nudResponse.Value = _objCharacter.Response;
                lblSignalLabel.Visible = true;
                nudSignal.Visible = true;
                nudSignal.Enabled = true;
                nudSignal.Value = _objCharacter.Signal;

                // Disable the Physical Attribute controls.
                lblBODLabel.Enabled = false;
                lblAGILabel.Enabled = false;
                lblREALabel.Enabled = false;
                lblSTRLabel.Enabled = false;
                nudBOD.Enabled = false;
                nudAGI.Enabled = false;
                nudREA.Enabled = false;
                nudSTR.Enabled = false;
            }

            mnuSpecialConvertToFreeSprite.Visible = _objCharacter.IsSprite;

            // Run through all of the Skills and Enable/Disable them as needed.
            foreach (SkillControl objSkillControl in panActiveSkills.Controls)
            {
                if (objSkillControl.Attribute == "MAG")
                    objSkillControl.Enabled = _objCharacter.MAGEnabled;
                if (objSkillControl.Attribute == "RES")
                    objSkillControl.Enabled = _objCharacter.RESEnabled;
            }
            // Run through all of the Skill Groups and Disable them if all of their Skills are currently inaccessible.
            foreach (SkillGroupControl objSkillGroupControl in panSkillGroups.Controls)
            {
                bool blnEnabled = false;
                foreach (Skill objSkill in _objCharacter.Skills)
                {
                    if (objSkill.SkillGroup == objSkillGroupControl.GroupName)
                    {
                        if (objSkill.Attribute == "MAG" || objSkill.Attribute == "RES")
                        {
                            if (objSkill.Attribute == "MAG" && _objCharacter.MAGEnabled)
                                blnEnabled = true;
                            if (objSkill.Attribute == "RES" && _objCharacter.RESEnabled)
                                blnEnabled = true;
                        }
                        else
                            blnEnabled = true;
                    }
                }
                objSkillGroupControl.IsEnabled = blnEnabled;
                if (!blnEnabled)
                    objSkillGroupControl.GroupRating = 0;
            }

            // Populate the Skill Filter DropDown.
            List<ListItem> lstFilter = new List<ListItem>();
            ListItem itmAll = new ListItem();
            itmAll.Value = "0";
            itmAll.Name = LanguageManager.Instance.GetString("String_SkillFilterAll");
            ListItem itmRatingAboveZero = new ListItem();
            itmRatingAboveZero.Value = "1";
            itmRatingAboveZero.Name = LanguageManager.Instance.GetString("String_SkillFilterRatingAboveZero");
            ListItem itmTotalRatingAboveZero = new ListItem();
            itmTotalRatingAboveZero.Value = "2";
            itmTotalRatingAboveZero.Name = LanguageManager.Instance.GetString("String_SkillFilterTotalRatingAboveZero");
            ListItem itmRatingEqualZero = new ListItem();
            itmRatingEqualZero.Value = "3";
            itmRatingEqualZero.Name = LanguageManager.Instance.GetString("String_SkillFilterRatingZero");
            lstFilter.Add(itmAll);
            lstFilter.Add(itmRatingAboveZero);
            lstFilter.Add(itmTotalRatingAboveZero);
            lstFilter.Add(itmRatingEqualZero);

            objXmlDocument = XmlManager.Instance.Load("skills.xml");
            objXmlNodeList = objXmlDocument.SelectNodes("/chummer/categories/category[@type = \"active\"]");
            foreach (XmlNode objNode in objXmlNodeList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objNode.InnerText;
                if (objNode.Attributes["translate"] != null)
                    objItem.Name = LanguageManager.Instance.GetString("Label_Category") + " " + objNode.Attributes["translate"].InnerText;
                else
                    objItem.Name = LanguageManager.Instance.GetString("Label_Category") + " " + objNode.InnerText;
                lstFilter.Add(objItem);
            }

            // Add items for Attributes.
            ListItem itmBOD = new ListItem();
            itmBOD.Value = "BOD";
            itmBOD.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeBODShort");
            ListItem itmAGI = new ListItem();
            itmAGI.Value = "AGI";
            itmAGI.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeAGIShort");
            ListItem itmREA = new ListItem();
            itmREA.Value = "REA";
            itmREA.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeREAShort");
            ListItem itmSTR = new ListItem();
            itmSTR.Value = "STR";
            itmSTR.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeSTRShort");
            ListItem itmCHA = new ListItem();
            itmCHA.Value = "CHA";
            itmCHA.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeCHAShort");
            ListItem itmINT = new ListItem();
            itmINT.Value = "INT";
            itmINT.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeINTShort");
            ListItem itmLOG = new ListItem();
            itmLOG.Value = "LOG";
            itmLOG.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeLOGShort");
            ListItem itmWIL = new ListItem();
            itmWIL.Value = "WIL";
            itmWIL.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeWILShort");
            ListItem itmMAG = new ListItem();
            itmMAG.Value = "MAG";
            itmMAG.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeMAGShort");
            ListItem itmRES = new ListItem();
            itmRES.Value = "RES";
            itmRES.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeRESShort");
            lstFilter.Add(itmBOD);
            lstFilter.Add(itmAGI);
            lstFilter.Add(itmREA);
            lstFilter.Add(itmSTR);
            lstFilter.Add(itmCHA);
            lstFilter.Add(itmINT);
            lstFilter.Add(itmLOG);
            lstFilter.Add(itmWIL);
            lstFilter.Add(itmMAG);
            lstFilter.Add(itmRES);

            // Add Skill Groups to the filter.
            objXmlNodeList = objXmlDocument.SelectNodes("/chummer/categories/category[@type = \"active\"]");
            foreach (SkillGroup objGroup in _objCharacter.SkillGroups)
            {
                ListItem itmGroup = new ListItem();
                itmGroup.Value = "GROUP:" + objGroup.Name;
                itmGroup.Name = LanguageManager.Instance.GetString("String_ExpenseSkillGroup") + ": " + objGroup.DisplayName;
                lstFilter.Add(itmGroup);
            }

            cboSkillFilter.DataSource = lstFilter;
            cboSkillFilter.ValueMember = "Value";
            cboSkillFilter.DisplayMember = "Name";
            cboSkillFilter.SelectedIndex = 0;
            cboSkillFilter_SelectedIndexChanged(null, null);

            if (_objCharacter.MetatypeCategory == "Mundane Critters")
                mnuSpecialMutantCritter.Visible = true;
            if (_objCharacter.MetatypeCategory == "Mutant Critters")
                mnuSpecialToxicCritter.Visible = true;
            if (_objCharacter.MetatypeCategory == "Cyberzombie")
                mnuSpecialCyberzombie.Visible = false;

            _objFunctions.SortTree(treCyberware);
            _objFunctions.SortTree(treSpells);
            _objFunctions.SortTree(treComplexForms);
            _objFunctions.SortTree(treQualities);
            _objFunctions.SortTree(treCritterPowers);
            _objFunctions.SortTree(treMartialArts);
            UpdateMentorSpirits();
            UpdateInitiationGradeList();
            RefreshImprovements();

            UpdateCharacterInfo();

            _blnIsDirty = false;
            UpdateWindowTitle(false);
            RefreshPasteStatus();

            // Stupid hack to get the MDI icon to show up properly.
            this.Icon = this.Icon.Clone() as System.Drawing.Icon;
        }
예제 #3
0
        private void frmCreate_Load(object sender, EventArgs e)
        {
	        Timekeeper.Finish("load_free");
			Timekeeper.Start("load_frm_create");
            _blnLoading = true;
            if (!_objCharacter.IsCritter && (_objCharacter.BuildMethod == CharacterBuildMethod.Karma && _objCharacter.BuildKarma == 0) || (_objCharacter.BuildMethod == CharacterBuildMethod.Priority && _objCharacter.BuildKarma == 0))
            {
                _blnFreestyle = true;
                tssBPRemain.Visible = false;
                tssBPRemainLabel.Visible = false;
            }

            // Initialize elements if we're using Priority to build.
            if (_objCharacter.BuildMethod == CharacterBuildMethod.Priority || _objCharacter.BuildMethod == CharacterBuildMethod.SumtoTen)
            {
                // Load the Priority information.
                if (_objCharacter.GameplayOption == "")
                {
                    _objCharacter.GameplayOption = "Standard";
                }
                XmlDocument objXmlDocumentGameplayOptions = XmlManager.Instance.Load("gameplayoptions.xml");
                XmlNode objXmlGameplayOption = objXmlDocumentGameplayOptions.SelectSingleNode("/chummer/gameplayoptions/gameplayoption[name = \"" + _objCharacter.GameplayOption + "\"]");
                string strKarma = objXmlGameplayOption["karma"].InnerText;
                string strNuyen = objXmlGameplayOption["maxnuyen"].InnerText;
                if (!_objOptions.FreeContactsMultiplierEnabled)
                {
                    string strContactMultiplier = objXmlGameplayOption["contactmultiplier"].InnerText;
                    _objCharacter.ContactMultiplier = Convert.ToInt32(strContactMultiplier);
                }
                else
                {
                    _objCharacter.ContactMultiplier = _objOptions.FreeContactsMultiplier;
                }
                _objCharacter.MaxKarma = Convert.ToInt32(strKarma);
                _objCharacter.MaxNuyen = Convert.ToInt32(strNuyen);



                lblPBuildSpecial.Text = String.Format("{0} " + LanguageManager.Instance.GetString("String_Of") + " {1}", (_objCharacter.Special).ToString(), _objCharacter.TotalSpecial.ToString());
                lblPBuildAttributes.Text = String.Format("{0} " + LanguageManager.Instance.GetString("String_Of") + " {1}", (_objCharacter.Attributes).ToString(), _objCharacter.TotalAttributes.ToString());
                lblPBuildSpells.Text = String.Format("{0} " + LanguageManager.Instance.GetString("String_Of") + " {1}", (_objCharacter.SpellLimit - _objCharacter.Spells.Count).ToString(), _objCharacter.SpellLimit.ToString());
                lblPBuildComplexForms.Text = String.Format("{0} " + LanguageManager.Instance.GetString("String_Of") + " {1}", (_objCharacter.CFPLimit - _objCharacter.ComplexForms.Count).ToString(), _objCharacter.CFPLimit.ToString());
                tabInfo.TabPages.RemoveAt(0);


            }
            else
            {
                tabInfo.TabPages.RemoveAt(1);
            }

            int count = 0;
            foreach (Contact contact in _objCharacter.Contacts)
                count += contact.ContactPoints;

            

            // Set the movement speed defaults
            lblMovement.Text = _objCharacter.Movement;

			tssBPLabel.Text = LanguageManager.Instance.GetString("Label_Karma");
			tssBPRemainLabel.Text = LanguageManager.Instance.GetString("Label_KarmaRemaining");
			tabBPSummary.Text = LanguageManager.Instance.GetString("Tab_BPSummary_Karma");
			lblQualityBPLabel.Text = LanguageManager.Instance.GetString("Label_Karma");

			// Set the Statusbar Labels if we're using Karma to build.
			if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma || _objCharacter.BuildMethod == CharacterBuildMethod.LifeModule)
            {
                
                //TODO: Fix the UI for karmagen

                nudAGI.Enabled = false;
                nudBOD.Enabled = false;
                nudSTR.Enabled = false;
                nudREA.Enabled = false;
                nudINT.Enabled = false;
                nudCHA.Enabled = false;
                nudLOG.Enabled = false;
                nudWIL.Enabled = false;
                nudEDG.Enabled = false;
                nudRES.Enabled = false;
                nudMAG.Enabled = false;

            }
            nudNuyen.Value = _objCharacter.NuyenBP;

            // Remove the Magician, Adept, and Technomancer tabs since they are not in use until the appropriate Quality is selected.
            if (!_objCharacter.MagicianEnabled && !_objCharacter.AdeptEnabled)
                tabCharacterTabs.TabPages.Remove(tabMagician);
            if (!_objCharacter.AdeptEnabled)
                tabCharacterTabs.TabPages.Remove(tabAdept);
            if (!_objCharacter.TechnomancerEnabled)
                tabCharacterTabs.TabPages.Remove(tabTechnomancer);
            if (!_objCharacter.CritterEnabled)
                tabCharacterTabs.TabPages.Remove(tabCritter);
            if (_objCharacter.AdeptEnabled && !_objCharacter.MagicianEnabled)
            {
                // Hide the pieces that only apply to mages or mystic adepts
                treSpells.Nodes[4].Remove();
                treSpells.Nodes[3].Remove();
                treSpells.Nodes[2].Remove();
                treSpells.Nodes[1].Remove();
                treSpells.Nodes[0].Remove();
                lblDrainAttributesLabel.Visible = false;
                lblDrainAttributes.Visible = false;
                lblDrainAttributesValue.Visible = false;
                lblSpirits.Visible = false;
                cmdAddSpirit.Visible = false;
                panSpirits.Visible = false;
            }

            // Set the visibility of the Bioware Suites menu options.
            mnuSpecialAddBiowareSuite.Visible = _objCharacter.Options.AllowBiowareSuites;
            mnuSpecialCreateBiowareSuite.Visible = _objCharacter.Options.AllowBiowareSuites;

            if (_objCharacter.BlackMarket)
            {
                chkCyberwareBlackMarketDiscount.Visible = true;
                chkArmorBlackMarketDiscount.Visible = true;
                chkWeaponBlackMarketDiscount.Visible = true;
                chkGearBlackMarketDiscount.Visible = true;
                chkVehicleBlackMarketDiscount.Visible = true;
            }

            // Remove the Improvements Tab.
            tabCharacterTabs.TabPages.Remove(tabImprovements);

            if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
            {
                if (!_objCharacter.MAGEnabled && !_objCharacter.RESEnabled)
                    tabCharacterTabs.TabPages.Remove(tabInitiation);
                else
                {
                    if (_objCharacter.MAGEnabled)
                    {
                        tabInitiation.Text = LanguageManager.Instance.GetString("Tab_Initiation");
                        cmdAddMetamagic.Text = LanguageManager.Instance.GetString("Button_AddMetamagic");
                        chkInitiationGroup.Text = LanguageManager.Instance.GetString("Checkbox_GroupInitiation");
                        chkInitiationOrdeal.Text = LanguageManager.Instance.GetString("Checkbox_InitiationOrdeal");
                    }
                    else
                    {
                        tabInitiation.Text = LanguageManager.Instance.GetString("Tab_Submersion");
                        cmdAddMetamagic.Text = LanguageManager.Instance.GetString("Button_AddSubmersionGrade");
                        chkInitiationGroup.Text = LanguageManager.Instance.GetString("Checkbox_NetworkSubmersion");
                        chkInitiationOrdeal.Text = LanguageManager.Instance.GetString("Checkbox_SubmersionTask");
                    }
                }
            }
            else
            {
                if ((!_objCharacter.MAGEnabled && !_objCharacter.RESEnabled) || !_objCharacter.Options.AllowInitiationInCreateMode)
                    tabCharacterTabs.TabPages.Remove(tabInitiation);
            }

            // If the character has a mugshot, decode it and put it in the PictureBox.
            if (_objCharacter.Mugshot != "")
            {
                byte[] bytImage = Convert.FromBase64String(_objCharacter.Mugshot);
                MemoryStream objStream = new MemoryStream(bytImage, 0, bytImage.Length);
                objStream.Write(bytImage, 0, bytImage.Length);
                Image imgMugshot = Image.FromStream(objStream, true);
                picMugshot.Image = imgMugshot;
            }

            // Populate character information fields.
            XmlDocument objMetatypeDoc = new XmlDocument();
            XmlNode objMetatypeNode;
            string strMetatype = "";
            string strBook = "";
            string strPage = "";

            objMetatypeDoc = XmlManager.Instance.Load("metatypes.xml");
            {
                objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
                if (objMetatypeNode == null)
                    objMetatypeDoc = XmlManager.Instance.Load("critters.xml");
                objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");

                if (objMetatypeNode["translate"] != null)
                    strMetatype = objMetatypeNode["translate"].InnerText;
                else
                    strMetatype = _objCharacter.Metatype;

                strBook = _objOptions.LanguageBookShort(objMetatypeNode["source"].InnerText);
                if (objMetatypeNode["altpage"] != null)
                    strPage = objMetatypeNode["altpage"].InnerText;
                else
                    strPage = objMetatypeNode["page"].InnerText;

                if (_objCharacter.Metavariant != "")
                {
                    objMetatypeNode = objMetatypeNode.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]");

                    if (objMetatypeNode["translate"] != null)
                        strMetatype += " (" + objMetatypeNode["translate"].InnerText + ")";
                    else
                        strMetatype += " (" + _objCharacter.Metavariant + ")";

                    strBook = _objOptions.LanguageBookShort(objMetatypeNode["source"].InnerText);
                    if (objMetatypeNode["altpage"] != null)
                        strPage = objMetatypeNode["altpage"].InnerText;
                    else
                        strPage = objMetatypeNode["page"].InnerText;
                }
            }
            lblMetatype.Text = strMetatype;
            lblMetatypeSource.Text = strBook + " " + strPage;
            txtCharacterName.Text = _objCharacter.Name;
            txtSex.Text = _objCharacter.Sex;
            txtAge.Text = _objCharacter.Age;
            txtEyes.Text = _objCharacter.Eyes;
            txtHeight.Text = _objCharacter.Height;
            txtWeight.Text = _objCharacter.Weight;
            txtSkin.Text = _objCharacter.Skin;
            txtHair.Text = _objCharacter.Hair;
            txtDescription.Text = _objCharacter.Description;
            txtBackground.Text = _objCharacter.Background;
            txtConcept.Text = _objCharacter.Concept;
            txtNotes.Text = _objCharacter.Notes;
            txtAlias.Text = _objCharacter.Alias;
            txtPlayerName.Text = _objCharacter.PlayerName;

            // Check for Special Attributes.
            lblMAGLabel.Enabled = _objCharacter.MAGEnabled;
            lblMAGAug.Enabled = _objCharacter.MAGEnabled;
            if ((_objCharacter.BuildMethod != CharacterBuildMethod.Karma) && (_objCharacter.BuildMethod != CharacterBuildMethod.LifeModule))
            {
                nudMAG.Enabled = _objCharacter.MAGEnabled;
            }
            nudKMAG.Enabled = _objCharacter.MAGEnabled;
            lblMAGMetatype.Enabled = _objCharacter.MAGEnabled;
            lblFoci.Visible = _objCharacter.MAGEnabled;
            treFoci.Visible = _objCharacter.MAGEnabled;
            cmdCreateStackedFocus.Visible = _objCharacter.MAGEnabled;

			if (_objCharacter.Metatype == "A.I.")
			{
				lblDEPAug.Enabled = true;
				lblDEPLabel.Enabled = true;
				if ((_objCharacter.BuildMethod != CharacterBuildMethod.Karma) && (_objCharacter.BuildMethod != CharacterBuildMethod.LifeModule))
				{ 
					nudDEP.Enabled = true;
				}
				nudKDEP.Enabled = true;
				lblDEPMetatype.Enabled = true;
			}

            lblRESLabel.Enabled = _objCharacter.RESEnabled;
            lblRESAug.Enabled = _objCharacter.RESEnabled;
            if (_objCharacter.BuildMethod != CharacterBuildMethod.Karma || _objCharacter.BuildMethod != CharacterBuildMethod.LifeModule)
            {
                nudRES.Enabled = _objCharacter.RESEnabled;
            }
            nudKRES.Enabled = _objCharacter.RESEnabled;
            lblRESMetatype.Enabled = _objCharacter.RESEnabled;

            // Define the XML objects that will be used.
            XmlDocument objXmlDocument = new XmlDocument();

			if (_objCharacter.BuildMethod == CharacterBuildMethod.LifeModule)
			{
				cmdLifeModule.Visible = true;
				treQualities.Nodes.Add(new TreeNode("Life Modules"));
				btnCreateBackstory.Visible = true;
				btnCreateBackstory.Visible = _objCharacter.Options.AutomaticBackstory;
			}

            // Populate the Qualities list.
            foreach (Quality objQuality in _objCharacter.Qualities)
            {
                treQualities.Add(objQuality, cmsQuality);
            }

            // Populate the Magician Traditions list.
            objXmlDocument = XmlManager.Instance.Load("traditions.xml");
            List<ListItem> lstTraditions = new List<ListItem>();
            ListItem objBlank = new ListItem();
            objBlank.Value = "";
            objBlank.Name = "";
            lstTraditions.Add(objBlank);
            foreach (XmlNode objXmlTradition in objXmlDocument.SelectNodes("/chummer/traditions/tradition[" + _objOptions.BookXPath() + "]"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlTradition["name"].InnerText;
                if (objXmlTradition["translate"] != null)
                    objItem.Name = objXmlTradition["translate"].InnerText;
                else
                    objItem.Name = objXmlTradition["name"].InnerText;
                lstTraditions.Add(objItem);
            }
            SortListItem objSort = new SortListItem();
            lstTraditions.Sort(objSort.Compare);
            cboTradition.ValueMember = "Value";
            cboTradition.DisplayMember = "Name";
            cboTradition.DataSource = lstTraditions;

            // Populate the Magician Custom Drain Options list.
            objXmlDocument = XmlManager.Instance.Load("traditions.xml");
            List<ListItem> lstDrainAttributes = new List<ListItem>();
            ListItem objDrainBlank = new ListItem();
            objDrainBlank.Value = "";
            objDrainBlank.Name = "";
            lstDrainAttributes.Add(objDrainBlank);
            foreach (XmlNode objXmlDrain in objXmlDocument.SelectNodes("/chummer/drainattributes/drainattribute"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlDrain["name"].InnerText;
                if (objXmlDrain["translate"] != null)
                    objItem.Name = objXmlDrain["translate"].InnerText;
                else
                    objItem.Name = objXmlDrain["name"].InnerText;
                lstDrainAttributes.Add(objItem);
            }
            SortListItem objDrainSort = new SortListItem();
            lstDrainAttributes.Sort(objDrainSort.Compare);
            cboDrain.ValueMember = "Value";
            cboDrain.DisplayMember = "Name";
            cboDrain.DataSource = lstDrainAttributes;

            // Populate the Magician Custom Spirits lists - Combat.
            objXmlDocument = XmlManager.Instance.Load("traditions.xml");
            List<ListItem> lstSpirit = new List<ListItem>();
            ListItem objSpiritBlank = new ListItem();
            objSpiritBlank.Value = "";
            objSpiritBlank.Name = "";
            lstSpirit.Add(objSpiritBlank);
            foreach (XmlNode objXmlSpirit in objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSpirit["name"].InnerText;
                if (objXmlSpirit["translate"] != null)
                    objItem.Name = objXmlSpirit["translate"].InnerText;
                else
                    objItem.Name = objXmlSpirit["name"].InnerText;
                lstSpirit.Add(objItem);
            }
            SortListItem objSpiritSort = new SortListItem();
            lstSpirit.Sort(objSpiritSort.Compare);

            cboSpiritCombat.ValueMember = "Value";
            cboSpiritCombat.DisplayMember = "Name";
            cboSpiritCombat.DataSource = lstSpirit;

            // Populate the Magician Custom Spirits lists - Detection.
            lstSpirit = new List<ListItem>();
            objSpiritBlank = new ListItem();
            objSpiritBlank.Value = "";
            objSpiritBlank.Name = "";
            lstSpirit.Add(objSpiritBlank);
            foreach (XmlNode objXmlSpirit in objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSpirit["name"].InnerText;
                if (objXmlSpirit["translate"] != null)
                    objItem.Name = objXmlSpirit["translate"].InnerText;
                else
                    objItem.Name = objXmlSpirit["name"].InnerText;
                lstSpirit.Add(objItem);
            }
            objSpiritSort = new SortListItem();
            lstSpirit.Sort(objSpiritSort.Compare);

            cboSpiritDetection.ValueMember = "Value";
            cboSpiritDetection.DisplayMember = "Name";
            cboSpiritDetection.DataSource = lstSpirit;

            // Populate the Magician Custom Spirits lists - Health.
            lstSpirit = new List<ListItem>();
            objSpiritBlank = new ListItem();
            objSpiritBlank.Value = "";
            objSpiritBlank.Name = "";
            lstSpirit.Add(objSpiritBlank);
            foreach (XmlNode objXmlSpirit in objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSpirit["name"].InnerText;
                if (objXmlSpirit["translate"] != null)
                    objItem.Name = objXmlSpirit["translate"].InnerText;
                else
                    objItem.Name = objXmlSpirit["name"].InnerText;
                lstSpirit.Add(objItem);
            }
            objSpiritSort = new SortListItem();
            lstSpirit.Sort(objSpiritSort.Compare);

            cboSpiritHealth.ValueMember = "Value";
            cboSpiritHealth.DisplayMember = "Name";
            cboSpiritHealth.DataSource = lstSpirit;

            // Populate the Magician Custom Spirits lists - Illusion.
            lstSpirit = new List<ListItem>();
            objSpiritBlank = new ListItem();
            objSpiritBlank.Value = "";
            objSpiritBlank.Name = "";
            lstSpirit.Add(objSpiritBlank);
            foreach (XmlNode objXmlSpirit in objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSpirit["name"].InnerText;
                if (objXmlSpirit["translate"] != null)
                    objItem.Name = objXmlSpirit["translate"].InnerText;
                else
                    objItem.Name = objXmlSpirit["name"].InnerText;
                lstSpirit.Add(objItem);
            }
            objSpiritSort = new SortListItem();
            lstSpirit.Sort(objSpiritSort.Compare);

            cboSpiritIllusion.ValueMember = "Value";
            cboSpiritIllusion.DisplayMember = "Name";
            cboSpiritIllusion.DataSource = lstSpirit;

            // Populate the Magician Custom Spirits lists - Manipulation.
            lstSpirit = new List<ListItem>();
            objSpiritBlank = new ListItem();
            objSpiritBlank.Value = "";
            objSpiritBlank.Name = "";
            lstSpirit.Add(objSpiritBlank);
            foreach (XmlNode objXmlSpirit in objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSpirit["name"].InnerText;
                if (objXmlSpirit["translate"] != null)
                    objItem.Name = objXmlSpirit["translate"].InnerText;
                else
                    objItem.Name = objXmlSpirit["name"].InnerText;
                lstSpirit.Add(objItem);
            }
            objSpiritSort = new SortListItem();
            lstSpirit.Sort(objSpiritSort.Compare);

            cboSpiritManipulation.ValueMember = "Value";
            cboSpiritManipulation.DisplayMember = "Name";
            cboSpiritManipulation.DataSource = lstSpirit;

            // Load the Metatype information before going anywhere else. Doing this later causes the Attributes to get messed up because of calls
            // to UpdateCharacterInformation();
            MetatypeSelected();

            // If the character is a Mystic Adept, set the values for the Mystic Adept NUD.
            if (_objCharacter.AdeptEnabled && _objCharacter.MagicianEnabled)
            {
                nudMysticAdeptMAGMagician.Maximum = _objCharacter.MAG.TotalValue;
                nudMysticAdeptMAGMagician.Value = _objCharacter.MAGMagician;

                lblMysticAdeptAssignment.Visible = true;
                nudMysticAdeptMAGMagician.Visible = true;
            }

            // Nuyen can be affected by Qualities, so adjust the total amount available to the character.
            if (_objCharacter.IgnoreRules == false)
            {
                if (_objCharacter.BuildMethod == CharacterBuildMethod.SumtoTen || _objCharacter.BuildMethod == CharacterBuildMethod.Priority)
                {
                    nudNuyen.Maximum = _objCharacter.MaxNuyen;
                }
                else if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma || _objCharacter.BuildMethod == CharacterBuildMethod.LifeModule)
                {
                    nudNuyen.Maximum = 200;
                }
            }
            else
            {
                //nudNuyen.Maximum = decimal.MaxValue;
            }
	        if (_objCharacter.BornRich) nudNuyen.Maximum += 30;
			nudNuyen.Value = _objCharacter.NuyenBP;

			// Load the Skills information.
			objXmlDocument = XmlManager.Instance.Load("skills.xml");

            // Populate the Skills Controls.
            XmlNodeList objXmlNodeList = objXmlDocument.SelectNodes("/chummer/skills/skill[" + _objCharacter.Options.BookXPath() + "]");
            // Counter to keep track of the number of Controls that have been added to the Panel so we can determine their vertical positioning.
            int i = -1;
            if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
            {
                label8.Visible = false;
                label14.Visible = false;
            }
            foreach (Skill objSkill in _objCharacter.Skills)
            {
                if (!objSkill.KnowledgeSkill && !objSkill.ExoticSkill)
                {
                    i++;
                    SkillControl objSkillControl = new SkillControl(_objCharacter);
                    objSkillControl.SkillObject = objSkill;

                    // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                    objSkillControl.RatingChanged += objActiveSkill_RatingChanged;
                    objSkillControl.BuyWithKarmaChanged += objActiveSkill_BuyWithKarmaChanged;
                    objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                    objSkillControl.BreakGroupClicked += objSkill_BreakGroupClicked;

                    objSkillControl.SkillName = objSkill.Name;
                    objSkillControl.SkillCategory = objSkill.SkillCategory;
                    objSkillControl.SkillGroup = objSkill.SkillGroup;
                    objSkillControl.SkillRatingMaximum = objSkill.RatingMaximum;
                    objSkillControl.SkillRating = objSkill.Rating;
                    objSkillControl.SkillBase = objSkill.Base;
                    objSkillControl.SkillKarma = objSkill.Karma;
                    objSkillControl.SkillSpec = objSkill.Specialization;

                    XmlNode objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + objSkill.Name + "\"]");
                    // Populate the Skill's Specializations (if any).
                    foreach (XmlNode objXmlSpecialization in objXmlSkill.SelectNodes("specs/spec"))
                    {
                        if (objXmlSpecialization.Attributes["translate"] != null)
                            objSkillControl.AddSpec(objXmlSpecialization.Attributes["translate"].InnerText);
                        else
                            objSkillControl.AddSpec(objXmlSpecialization.InnerText);
                    }

                    // Set the control's vertical position and add it to the Skills Panel.
                    objSkillControl.Top = i * objSkillControl.Height;
                    objSkillControl.Width = 510;
                    objSkillControl.AutoScroll = false;
                    panActiveSkills.Controls.Add(objSkillControl);
                }
            }

            // Exotic Skills.
            foreach (Skill objSkill in _objCharacter.Skills)
            {
                if (objSkill.ExoticSkill)
                {
                    i++;
                    SkillControl objSkillControl = new SkillControl(_objCharacter);
                    objSkillControl.SkillObject = objSkill;

                    // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                    objSkillControl.RatingChanged += objActiveSkill_RatingChanged;
                    objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                    objSkillControl.BreakGroupClicked += objSkill_BreakGroupClicked;
                    objSkillControl.BuyWithKarmaChanged += objActiveSkill_BuyWithKarmaChanged;

                    objSkillControl.SkillName = objSkill.Name;
                    objSkillControl.SkillCategory = objSkill.SkillCategory;
                    objSkillControl.SkillGroup = objSkill.SkillGroup;
                    objSkillControl.SkillRatingMaximum = objSkill.RatingMaximum;
                    objSkillControl.SkillBase = objSkill.Base;
                    objSkillControl.SkillKarma = objSkill.Karma;
                    objSkillControl.SkillRating = objSkill.Rating;
                    objSkillControl.SkillSpec = objSkill.Specialization;

                    XmlNode objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + objSkill.Name + "\"]");
                    // Populate the Skill's Specializations (if any).
                    foreach (XmlNode objXmlSpecialization in objXmlSkill.SelectNodes("specs/spec"))
                    {
                        if (objXmlSpecialization.Attributes["translate"] != null)
                            objSkillControl.AddSpec(objXmlSpecialization.Attributes["translate"].InnerText);
                        else
                            objSkillControl.AddSpec(objXmlSpecialization.InnerText);
                    }

                    // Look through the Weapons file and grab the names of items that are part of the appropriate Exotic Category or use the matching Exoctic Skill.
                    XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");
                    XmlNodeList objXmlWeaponList = objXmlWeaponDocument.SelectNodes("/chummer/weapons/weapon[category = \"" + objSkill.Name + "s\" or useskill = \"" + objSkill.Name + "\"]");
                    foreach (XmlNode objXmlWeapon in objXmlWeaponList)
                    {
                        if (objXmlWeapon["translate"] != null)
                            objSkillControl.AddSpec(objXmlWeapon["translate"].InnerText);
                        else
                            objSkillControl.AddSpec(objXmlWeapon["name"].InnerText);
                    }

                    // Set the control's vertical position and add it to the Skills Panel.
                    objSkillControl.Top = i * objSkillControl.Height;
                    objSkillControl.Width = 510;
                    objSkillControl.AutoScroll = false;
                    panActiveSkills.Controls.Add(objSkillControl);
                }
            }

            // Populate the Skill Groups list.
            i = -1;
            foreach (SkillGroup objGroup in _objCharacter.SkillGroups)
            {
                i++;
                SkillGroupControl objGroupControl = new SkillGroupControl(_objCharacter.Options, _objCharacter);
                objGroupControl.SkillGroupObject = objGroup;

				if (_objCharacter.IgnoreRules)
				{
					objGroup.RatingMaximum = 12;
                }

                // Attach an EventHandler for the GetRatingChanged Event.
                objGroupControl.GroupRatingChanged += objGroup_RatingChanged;

                // Populate the control, set its vertical position and add it to the Skill Groups Panel. A Skill Group cannot start with a Rating higher than 4.
                objGroupControl.GroupName = objGroup.Name;
                if (objGroup.Rating > objGroup.RatingMaximum)
                    objGroup.RatingMaximum = objGroup.Rating;
                objGroupControl.GroupRatingMaximum = objGroup.RatingMaximum;
                // objGroupControl.GroupRating = objGroup.Rating;
                objGroupControl.BaseRating = objGroup.Base;
                objGroupControl.KarmaRating = objGroup.Karma;
                objGroupControl.Top = i * objGroupControl.Height;
                objGroupControl.Width = 250;

                // Loop through all of the Active Skills the character has and set their maximums if needed.
                if (objGroup.RatingMaximum > 6)
                {
                    foreach (SkillControl objSkill in panActiveSkills.Controls)
                    {
                        if (objSkill.IsGrouped && objSkill.SkillGroup == objGroup.Name)
                        {
                            objSkill.SkillRatingMaximum = objGroup.RatingMaximum;
                            objSkill.SkillObject.RatingMaximum = objGroup.RatingMaximum;
                            objSkill.SkillRating = objGroup.Rating;
                        }
                    }
                }

                /*if (_objCharacter.Uneducated)
                {
                    objGroupControl.IsEnabled = !objGroup.HasTechnicalSkills;
                }*/

                if (_objCharacter.Uncouth)
                {
                    objGroupControl.IsEnabled = !objGroup.HasSocialSkills;
                }

                panSkillGroups.Controls.Add(objGroupControl);
            }

            // Populate Knowledge Skills.
            i = -1;
            foreach (Skill objSkill in _objCharacter.Skills)
            {
                if (objSkill.KnowledgeSkill)
                {
                    i++;
                    SkillControl objSkillControl = new SkillControl(_objCharacter);
                    objSkillControl.SkillObject = objSkill;

                    // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                    objSkillControl.RatingChanged += objKnowledgeSkill_RatingChanged;
                    objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                    objSkillControl.DeleteSkill += objKnowledgeSkill_DeleteSkill;
                    objSkillControl.BreakGroupClicked += objSkill_BreakGroupClicked;
                    objSkillControl.BuyWithKarmaChanged += objKnowledgeSkill_BuyWithKarmaChanged;
	                objSkillControl.MergeClicked += knoSkill_MergeClick;
                    objSkillControl.KnowledgeSkill = true;
                    objSkillControl.SkillCategory = objSkill.SkillCategory;
                    objSkillControl.AllowDelete = true;
                    objSkillControl.SkillRatingMaximum = objSkill.RatingMaximum;
                    objSkillControl.SkillBase = objSkill.Base;
                    objSkillControl.SkillKarma = objSkill.Karma;
                    objSkillControl.SkillRating = objSkill.Rating;
                    objSkillControl.SkillName = objSkill.Name;
                    objSkillControl.SkillSpec = objSkill.Specialization;
                    objSkillControl.Top = i * objSkillControl.Height;
                    objSkillControl.AutoScroll = false;
                    panKnowledgeSkills.Controls.Add(objSkillControl);
                    ////Handler for pre-5.163 Point Buy characters that had skill points in their knowledge skills
                    //if (objSkill.Base != 0 && !objSkill.CharacterObject.Options.FreeKarmaKnowledge && _objCharacter.BuildMethod == CharacterBuildMethod.Karma) 
                    //{  //lets no keep this code here!
                    //    objSkill.Base = 0;
                    //}
                }
            }

            // Populate Contacts and Enemies.
            int intContact = -1;
            int intEnemy = -1;
            foreach (Contact objContact in _objCharacter.Contacts)
            {
                if (objContact.EntityType == ContactType.Contact)
                {
                    intContact++;
                    ContactControl objContactControl = new ContactControl(_objCharacter);
                    // Attach an EventHandler for the ConnectionRatingChanged, LoyaltyRatingChanged, DeleteContact, FileNameChanged Events and OtherCostChanged
                    objContactControl.ConnectionRatingChanged += objContact_ConnectionRatingChanged;
                    objContactControl.LoyaltyRatingChanged += objContact_LoyaltyRatingChanged;
                    objContactControl.DeleteContact += objContact_DeleteContact;
                    objContactControl.FileNameChanged += objContact_FileNameChanged;
                    objContactControl.FreeRatingChanged += objContact_OtherCostChanged;
                    objContactControl.ContactObject = objContact;
                    objContactControl.ContactName = objContact.Name;
                    objContactControl.ContactLocation = objContact.Location;
                    objContactControl.ContactRole = objContact.Role;
                    objContactControl.ConnectionRating = objContact.Connection;
                    objContactControl.LoyaltyRating = objContact.Loyalty;
                    objContactControl.EntityType = objContact.EntityType;
                    objContactControl.BackColor = objContact.Colour;
                    objContactControl.IsGroup = objContact.IsGroup;
					objContactControl.MouseDown += panContactControl_MouseDown;

					objContactControl.Top = intContact * objContactControl.Height;

                    panContacts.Controls.Add(objContactControl);
                }
                if (objContact.EntityType == ContactType.Enemy)
                {
                    intEnemy++;
                    ContactControl objContactControl = new ContactControl(_objCharacter);
                    // Attach an EventHandler for the ConnectioNRatingChanged, LoyaltyRatingChanged, DeleteContact, and FileNameChanged Events.
                    objContactControl.ConnectionRatingChanged += objEnemy_ConnectionRatingChanged;
                    objContactControl.LoyaltyRatingChanged += objEnemy_LoyaltyRatingChanged;
                    objContactControl.GroupStatusChanged += objEnemy_GroupStatusChanged;
                    objContactControl.FreeRatingChanged += objEnemy_FreeStatusChanged;
                    objContactControl.DeleteContact += objEnemy_DeleteContact;
                    objContactControl.FileNameChanged += objEnemy_FileNameChanged;

                    objContactControl.ContactObject = objContact;
                    objContactControl.IsEnemy = true;
                    objContactControl.ContactName = objContact.Name;
                    objContactControl.ContactLocation = objContact.Location;
                    objContactControl.ContactRole = objContact.Role;
                    objContactControl.ConnectionRating = objContact.Connection;
                    objContactControl.LoyaltyRating = objContact.Loyalty;
                    objContactControl.EntityType = objContact.EntityType;
                    objContactControl.BackColor = objContact.Colour;
                    objContactControl.IsGroup = objContact.IsGroup;

                    objContactControl.Top = intEnemy * objContactControl.Height;
                    panEnemies.Controls.Add(objContactControl);
                }
                if (objContact.EntityType == ContactType.Pet)
                {
                    PetControl objContactControl = new PetControl();
                    // Attach an EventHandler for the DeleteContact and FileNameChanged Events.
                    objContactControl.DeleteContact += objPet_DeleteContact;
                    objContactControl.FileNameChanged += objPet_FileNameChanged;

                    objContactControl.ContactObject = objContact;
                    objContactControl.ContactName = objContact.Name;
                    objContactControl.BackColor = objContact.Colour;

                    panPets.Controls.Add(objContactControl);
                }
            }

            // Populate Armor.
            // Start by populating Locations.
            foreach (string strLocation in _objCharacter.ArmorBundles)
            {
                TreeNode objLocation = new TreeNode();
                objLocation.Tag = strLocation;
                objLocation.Text = strLocation;
                objLocation.ContextMenuStrip = cmsArmorLocation;
                treArmor.Nodes.Add(objLocation);
            }
            foreach (Armor objArmor in _objCharacter.Armor)
            {
                _objFunctions.CreateArmorTreeNode(objArmor, treArmor, cmsArmor, cmsArmorMod, cmsArmorGear);
            }

            // Populate Weapons.
            // Start by populating Locations.
            foreach (string strLocation in _objCharacter.WeaponLocations)
            {
                TreeNode objLocation = new TreeNode();
                objLocation.Tag = strLocation;
                objLocation.Text = strLocation;
                objLocation.ContextMenuStrip = cmsWeaponLocation;
                treWeapons.Nodes.Add(objLocation);
            }
            foreach (Weapon objWeapon in _objCharacter.Weapons)
            {
                _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponMod, cmsWeaponAccessory, cmsWeaponAccessoryGear);
            }

            PopulateCyberwareList();

            // Populate Spell list.
            foreach (Spell objSpell in _objCharacter.Spells)
            {
                treSpells.Add(objSpell, cmsSpell, _objCharacter);
            }

            // Populate Adept Powers.
            i = -1;
            foreach (Power objPower in _objCharacter.Powers)
            {
                i++;
                PowerControl objPowerControl = new PowerControl();
                objPowerControl.PowerObject = objPower;

                // Attach an EventHandler for the PowerRatingChanged Event.
                objPowerControl.PowerRatingChanged += objPower_PowerRatingChanged;
                objPowerControl.DeletePower += objPower_DeletePower;

                objPowerControl.PowerName = objPower.Name;
                objPowerControl.Extra = objPower.Extra;
                objPowerControl.PointsPerLevel = objPower.PointsPerLevel;
                objPowerControl.AdeptWayDiscount = objPower.AdeptWayDiscount;
                objPowerControl.LevelEnabled = objPower.LevelsEnabled;
				if (objPower.MaxLevels > 0)
				{
					if (objPower.Name == "Improved Ability (skill)")
					{
						foreach (Skill objSkill in _objCharacter.Skills)
							if (objPower.Extra == objSkill.Name || (objSkill.ExoticSkill && objPower.Extra == (objSkill.DisplayName + " (" + objSkill.Specialization + ")")))
							{
								int intImprovedAbilityMaximum = objSkill.Rating + (objSkill.Rating / 2);
								if (intImprovedAbilityMaximum == 0)
								{
									intImprovedAbilityMaximum = 1;
								}
								objPower.MaxLevels = intImprovedAbilityMaximum;
							}
							else
							{
								objPowerControl.MaxLevels = objPower.MaxLevels;
							}
					}
					else
					{
						objPowerControl.MaxLevels = objPower.MaxLevels;
					}
				}
                objPowerControl.RefreshMaximum(_objCharacter.MAG.TotalValue);
                if (objPower.Rating < 1)
                    objPower.Rating = 1;
                objPowerControl.PowerLevel = Convert.ToInt32(objPower.Rating);
                if (objPower.DiscountedAdeptWay)
                    objPowerControl.DiscountedByAdeptWay = true;
                if (objPower.DiscountedGeas)
                    objPowerControl.DiscountedByGeas = true;

                objPowerControl.Top = i * objPowerControl.Height;
                panPowers.Controls.Add(objPowerControl);
            }

            // Populate Magician Spirits.
            i = -1;
            foreach (Spirit objSpirit in _objCharacter.Spirits)
            {
                if (objSpirit.EntityType == SpiritType.Spirit)
                {
                    i++;
                    SpiritControl objSpiritControl = new SpiritControl();
                    objSpiritControl.SpiritObject = objSpirit;

                    // Attach an EventHandler for the ServicesOwedChanged Event.
                    objSpiritControl.ServicesOwedChanged += objSpirit_ServicesOwedChanged;
                    objSpiritControl.ForceChanged += objSpirit_ForceChanged;
                    objSpiritControl.BoundChanged += objSpirit_BoundChanged;
                    objSpiritControl.DeleteSpirit += objSpirit_DeleteSpirit;
                    objSpiritControl.FileNameChanged += objSpirit_FileNameChanged;

                    objSpiritControl.SpiritName = objSpirit.Name;
                    objSpiritControl.ServicesOwed = objSpirit.ServicesOwed;
                    if (_objCharacter.AdeptEnabled && _objCharacter.MagicianEnabled)
                    {
                        if (_objOptions.SpiritForceBasedOnTotalMAG)
                            objSpiritControl.ForceMaximum = _objCharacter.MAG.TotalValue;
                        else
                            objSpiritControl.ForceMaximum = _objCharacter.MAGMagician;
                    }
                    else
                        objSpiritControl.ForceMaximum = _objCharacter.MAG.TotalValue;
                    objSpiritControl.CritterName = objSpirit.CritterName;
                    objSpiritControl.Force = objSpirit.Force;
                    objSpiritControl.Bound = objSpirit.Bound;
                    objSpiritControl.RebuildSpiritList(_objCharacter.MagicTradition);

                    objSpiritControl.Top = i * objSpiritControl.Height;
                    panSpirits.Controls.Add(objSpiritControl);
                }
            }

            // Populate Technomancer Sprites.
            i = -1;
            foreach (Spirit objSpirit in _objCharacter.Spirits)
            {
                if (objSpirit.EntityType == SpiritType.Sprite)
                {
                    i++;
                    SpiritControl objSpiritControl = new SpiritControl();
                    objSpiritControl.SpiritObject = objSpirit;
                    objSpiritControl.EntityType = SpiritType.Sprite;

                    // Attach an EventHandler for the ServicesOwedChanged Event.
                    objSpiritControl.ServicesOwedChanged += objSprite_ServicesOwedChanged;
                    objSpiritControl.ForceChanged += objSprite_ForceChanged;
                    objSpiritControl.BoundChanged += objSprite_BoundChanged;
                    objSpiritControl.DeleteSpirit += objSprite_DeleteSpirit;
                    objSpiritControl.FileNameChanged += objSprite_FileNameChanged;

                    objSpiritControl.SpiritName = objSpirit.Name;
                    objSpiritControl.ServicesOwed = objSpirit.ServicesOwed;
                    objSpiritControl.ForceMaximum = _objCharacter.RES.TotalValue;
                    objSpiritControl.CritterName = objSpiritControl.CritterName;
                    objSpiritControl.Force = objSpirit.Force;
                    objSpiritControl.Bound = objSpirit.Bound;
                    objSpiritControl.RebuildSpiritList(_objCharacter.TechnomancerStream);

                    objSpiritControl.Top = i * objSpiritControl.Height;
                    panSprites.Controls.Add(objSpiritControl);
                }
            }

            // Populate Technomancer Complex Forms/Programs.
            foreach (ComplexForm objProgram in _objCharacter.ComplexForms)
            {
                TreeNode objNode = new TreeNode();
                objNode.Text = objProgram.DisplayName;
                objNode.Tag = objProgram.InternalId;
                if (objProgram.Notes != string.Empty)
                    objNode.ForeColor = Color.SaddleBrown;
                objNode.ToolTipText = CommonFunctions.WordWrap(objProgram.Notes, 100);
                treComplexForms.Nodes[0].Nodes.Add(objNode);
                treComplexForms.Nodes[0].Expand();
            }

            // Populate Martial Arts.
            foreach (MartialArt objMartialArt in _objCharacter.MartialArts)
            {
                TreeNode objMartialArtNode = new TreeNode();
                objMartialArtNode.Text = objMartialArt.DisplayName;
                objMartialArtNode.Tag = objMartialArt.Name;
                objMartialArtNode.ContextMenuStrip = cmsMartialArts;
                if (objMartialArt.Notes != string.Empty)
                    objMartialArtNode.ForeColor = Color.SaddleBrown;
                objMartialArtNode.ToolTipText = CommonFunctions.WordWrap(objMartialArt.Notes, 100);

                foreach (MartialArtAdvantage objAdvantage in objMartialArt.Advantages)
                {
                    TreeNode objAdvantageNode = new TreeNode();
                    objAdvantageNode.Text = objAdvantage.DisplayName;
                    objAdvantageNode.Tag = objAdvantage.InternalId;
                    objAdvantageNode.ContextMenuStrip = cmsTechnique;

                    if (objAdvantage.Notes != string.Empty)
                        objAdvantageNode.ForeColor = Color.SaddleBrown;
                    else
                        objAdvantageNode.ForeColor = SystemColors.WindowText;
                    objAdvantageNode.ToolTipText = CommonFunctions.WordWrap(objAdvantage.Notes, 100);

                    objMartialArtNode.Nodes.Add(objAdvantageNode);
                    objMartialArtNode.Expand();
                }

                if (objMartialArt.IsQuality)
                {
                    treMartialArts.Nodes[1].Nodes.Add(objMartialArtNode);
                    treMartialArts.Nodes[1].Expand();
                }
                else
                {
                    treMartialArts.Nodes[0].Nodes.Add(objMartialArtNode);
                    treMartialArts.Nodes[0].Expand();
                }
            }

            // Populate Limit Modifiers.
            foreach (LimitModifier objLimitModifier in _objCharacter.LimitModifiers)
            {
                TreeNode objLimitModifierNode = new TreeNode();
                objLimitModifierNode.Text = objLimitModifier.DisplayName;
                objLimitModifierNode.Tag = objLimitModifier.Name;
                objLimitModifierNode.ContextMenuStrip = cmsMartialArts;
                if (objLimitModifier.Notes != string.Empty)
                    objLimitModifierNode.ForeColor = Color.SaddleBrown;
                objLimitModifierNode.ToolTipText = CommonFunctions.WordWrap(objLimitModifier.Notes, 100);
                objLimitModifierNode.ContextMenuStrip = cmsLimitModifier;

                switch (objLimitModifier.Limit)
                {
                    case "Physical":
                        treLimit.Nodes[0].Nodes.Add(objLimitModifierNode);
                        treLimit.Nodes[0].Expand();
                        break;
                    case "Mental":
                        treLimit.Nodes[1].Nodes.Add(objLimitModifierNode);
                        treLimit.Nodes[1].Expand();
                        break;
                    case "Social":
                        treLimit.Nodes[2].Nodes.Add(objLimitModifierNode);
                        treLimit.Nodes[2].Expand();
                        break;
                }
            }

            // Populate Lifestyles.
            foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
            {
                TreeNode objLifestyleNode = new TreeNode();
                objLifestyleNode.Text = objLifestyle.DisplayName;
                objLifestyleNode.Tag = objLifestyle.InternalId;
                if (objLifestyle.StyleType.ToString() != "Standard")
                    objLifestyleNode.ContextMenuStrip = cmsAdvancedLifestyle;
                else
                    objLifestyleNode.ContextMenuStrip = cmsLifestyleNotes;
                if (objLifestyle.Notes != string.Empty)
                    objLifestyleNode.ForeColor = Color.SaddleBrown;
                objLifestyleNode.ToolTipText = CommonFunctions.WordWrap(objLifestyle.Notes, 100);
                treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode);
			}
            treLifestyles.Nodes[0].Expand();

            PopulateGearList();

            // Populate Foci.
            _objController.PopulateFocusList(treFoci);

            // Populate Vehicles.
            foreach (Vehicle objVehicle in _objCharacter.Vehicles)
            {
                _objFunctions.CreateVehicleTreeNode(objVehicle, treVehicles, cmsVehicle, cmsVehicleLocation, cmsVehicleWeapon, cmsVehicleWeaponMod, cmsVehicleWeaponAccessory, cmsVehicleWeaponAccessoryGear, cmsVehicleGear);
            }

            // Populate Initiation/Submersion information.
            if (_objCharacter.InitiateGrade > 0 || _objCharacter.SubmersionGrade > 0)
            {
                foreach (Metamagic objMetamagic in _objCharacter.Metamagics)
                {
                    TreeNode objNode = new TreeNode();
                    objNode.Text = objMetamagic.DisplayName;
                    objNode.Tag = objMetamagic.InternalId;
                    objNode.ContextMenuStrip = cmsMetamagic;
                    if (objMetamagic.Notes != string.Empty)
                        objNode.ForeColor = Color.SaddleBrown;
                    objNode.ToolTipText = CommonFunctions.WordWrap(objMetamagic.Notes, 100);
                    treMetamagic.Nodes.Add(objNode);
                }
            }

            // Populate Critter Powers.
            foreach (CritterPower objPower in _objCharacter.CritterPowers)
            {
                TreeNode objNode = new TreeNode();
                objNode.Text = objPower.DisplayName;
                objNode.Tag = objPower.InternalId;
                objNode.ContextMenuStrip = cmsCritterPowers;
                if (objPower.Notes != string.Empty)
                    objNode.ForeColor = Color.SaddleBrown;
                objNode.ToolTipText = CommonFunctions.WordWrap(objPower.Notes, 100);

                if (objPower.Category != "Weakness")
                {
                    treCritterPowers.Nodes[0].Nodes.Add(objNode);
                    treCritterPowers.Nodes[0].Expand();
                }
                else
                {
                    treCritterPowers.Nodes[1].Nodes.Add(objNode);
                    treCritterPowers.Nodes[1].Expand();
                }
            }

            // Load the Cyberware information.
            objXmlDocument = XmlManager.Instance.Load("cyberware.xml");

            // Populate the Grade list.
            List<ListItem> lstCyberwareGrades = new List<ListItem>();
            foreach (Grade objGrade in GlobalOptions.CyberwareGrades)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objGrade.Name;
                objItem.Name = objGrade.DisplayName;
                lstCyberwareGrades.Add(objItem);
            }
            cboCyberwareGrade.ValueMember = "Value";
            cboCyberwareGrade.DisplayMember = "Name";
            cboCyberwareGrade.DataSource = lstCyberwareGrades;

            _blnLoading = false;

            // Select the Magician's Tradition.
            if (_objCharacter.MagicTradition != "")
                cboTradition.SelectedValue = _objCharacter.MagicTradition;

            if (_objCharacter.TraditionName != "")
                txtTraditionName.Text = _objCharacter.TraditionName;

            if (_objCharacter.TraditionDrain != "")
                cboDrain.SelectedValue = _objCharacter.TraditionDrain;

            if (_objCharacter.SpiritCombat != "")
                cboSpiritCombat.SelectedValue = _objCharacter.SpiritCombat;

            if (_objCharacter.SpiritDetection != "")
                cboSpiritDetection.SelectedValue = _objCharacter.SpiritDetection;

            if (_objCharacter.SpiritHealth != "")
                cboSpiritHealth.SelectedValue = _objCharacter.SpiritHealth;

            if (_objCharacter.SpiritIllusion != "")
                cboSpiritIllusion.SelectedValue = _objCharacter.SpiritIllusion;

            if (_objCharacter.SpiritManipulation != "")
                cboSpiritManipulation.SelectedValue = _objCharacter.SpiritManipulation;

            // Clear the Dirty flag which gets set when creating a new Character.
            CalculateBP();
            CalculateNuyen();
            _blnIsDirty = false;
            UpdateWindowTitle();
            if (_objCharacter.AdeptEnabled)
                CalculatePowerPoints();

            treGear.ItemDrag += treGear_ItemDrag;
            treGear.DragEnter += treGear_DragEnter;
            treGear.DragDrop += treGear_DragDrop;

            treLifestyles.ItemDrag += treLifestyles_ItemDrag;
            treLifestyles.DragEnter += treLifestyles_DragEnter;
            treLifestyles.DragDrop += treLifestyles_DragDrop;

            treArmor.ItemDrag += treArmor_ItemDrag;
            treArmor.DragEnter += treArmor_DragEnter;
            treArmor.DragDrop += treArmor_DragDrop;

            treWeapons.ItemDrag += treWeapons_ItemDrag;
            treWeapons.DragEnter += treWeapons_DragEnter;
            treWeapons.DragDrop += treWeapons_DragDrop;

            treVehicles.ItemDrag += treVehicles_ItemDrag;
            treVehicles.DragEnter += treVehicles_DragEnter;
            treVehicles.DragDrop += treVehicles_DragDrop;

            // Merge the ToolStrips.
            ToolStripManager.RevertMerge("toolStrip");
            ToolStripManager.Merge(toolStrip, "toolStrip");

            // If this is a Sprite, re-label the Mental Attribute Labels.
            if (_objCharacter.Metatype.EndsWith("Sprite"))
            {
                lblBODLabel.Enabled = false;
                nudBOD.Enabled = false;
                lblAGILabel.Enabled = false;
                nudAGI.Enabled = false;
                lblREALabel.Enabled = false;
                nudREA.Enabled = false;
                lblSTRLabel.Enabled = false;
                nudSTR.Enabled = false;
                lblCHALabel.Text = LanguageManager.Instance.GetString("String_AttributePilot");
                lblINTLabel.Text = LanguageManager.Instance.GetString("String_AttributeResponse");
                lblLOGLabel.Text = LanguageManager.Instance.GetString("String_AttributeFirewall");
                lblWILLabel.Enabled = false;
                nudWIL.Enabled = false;
            }
            else if (_objCharacter.Metatype.EndsWith("A.I.") || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients")
            {
                lblRatingLabel.Visible = true;
                lblRating.Visible = true;
                lblSystemLabel.Visible = true;
                lblSystem.Visible = true;
                lblFirewallLabel.Visible = true;
                lblFirewall.Visible = true;
                lblResponseLabel.Visible = true;
                nudResponse.Visible = true;
                nudResponse.Enabled = true;
                nudResponse.Value = _objCharacter.Response;
                lblSignalLabel.Visible = true;
                nudSignal.Visible = true;
                nudSignal.Enabled = true;
                nudSignal.Value = _objCharacter.Signal;

                // Disable the Physical Attribute controls.
                lblBODLabel.Enabled = false;
                lblAGILabel.Enabled = false;
                lblREALabel.Enabled = false;
                lblSTRLabel.Enabled = false;
                nudBOD.Enabled = false;
                nudAGI.Enabled = false;
                nudREA.Enabled = false;
                nudSTR.Enabled = false;
            }

            mnuSpecialConvertToFreeSprite.Visible = _objCharacter.IsSprite;

            // Run through all of the Skills and Enable/Disable them as needed.
            foreach (SkillControl objSkillControl in panActiveSkills.Controls)
            {
                if (objSkillControl.Attribute == "MAG")
                    objSkillControl.Enabled = _objCharacter.MAGEnabled;
                if (objSkillControl.Attribute == "RES")
                    objSkillControl.Enabled = _objCharacter.RESEnabled;
            }
            // Run through all of the Skill Groups and Disable them if all of their Skills are currently inaccessible.
            foreach (SkillGroupControl objSkillGroupControl in panSkillGroups.Controls)
            {
                bool blnEnabled = false;
                foreach (Skill objSkill in _objCharacter.Skills)
                {
                    if (objSkill.SkillGroup == objSkillGroupControl.GroupName)
                    {
                        if (objSkill.Attribute == "MAG" || objSkill.Attribute == "RES")
                        {
                            if (objSkill.Attribute == "MAG" && _objCharacter.MAGEnabled)
                                blnEnabled = true;
                            if (objSkill.Attribute == "RES" && _objCharacter.RESEnabled)
                                blnEnabled = true;
                        }
                        else
                            blnEnabled = true;
                    }
                }
                objSkillGroupControl.IsEnabled = blnEnabled;
                if (!blnEnabled)
                    objSkillGroupControl.GroupRating = 0;
            }

            // Populate the Skill Filter DropDown.
            List<ListItem> lstFilter = new List<ListItem>();
            ListItem itmAll = new ListItem();
            itmAll.Value = "0";
            itmAll.Name = LanguageManager.Instance.GetString("String_SkillFilterAll");
            ListItem itmRatingAboveZero = new ListItem();
            itmRatingAboveZero.Value = "1";
            itmRatingAboveZero.Name = LanguageManager.Instance.GetString("String_SkillFilterRatingAboveZero");
            ListItem itmTotalRatingAboveZero = new ListItem();
            itmTotalRatingAboveZero.Value = "2";
            itmTotalRatingAboveZero.Name = LanguageManager.Instance.GetString("String_SkillFilterTotalRatingAboveZero");
            ListItem itmRatingEqualZero = new ListItem();
            itmRatingEqualZero.Value = "3";
            itmRatingEqualZero.Name = LanguageManager.Instance.GetString("String_SkillFilterRatingZero");
            lstFilter.Add(itmAll);
            lstFilter.Add(itmRatingAboveZero);
            lstFilter.Add(itmTotalRatingAboveZero);
            lstFilter.Add(itmRatingEqualZero);

            objXmlDocument = XmlManager.Instance.Load("skills.xml");
            objXmlNodeList = objXmlDocument.SelectNodes("/chummer/categories/category[@type = \"active\"]");
            foreach (XmlNode objNode in objXmlNodeList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objNode.InnerText;
                if (objNode.Attributes["translate"] != null)
                    objItem.Name = LanguageManager.Instance.GetString("Label_Category") + " " + objNode.Attributes["translate"].InnerText;
                else
                    objItem.Name = LanguageManager.Instance.GetString("Label_Category") + " " + objNode.InnerText;
                lstFilter.Add(objItem);
            }

            // Add items for Attributes.
            ListItem itmBOD = new ListItem();
            itmBOD.Value = "BOD";
            itmBOD.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeBODShort");
            ListItem itmAGI = new ListItem();
            itmAGI.Value = "AGI";
            itmAGI.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeAGIShort");
            ListItem itmREA = new ListItem();
            itmREA.Value = "REA";
            itmREA.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeREAShort");
            ListItem itmSTR = new ListItem();
            itmSTR.Value = "STR";
            itmSTR.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeSTRShort");
            ListItem itmCHA = new ListItem();
            itmCHA.Value = "CHA";
            itmCHA.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeCHAShort");
            ListItem itmINT = new ListItem();
            itmINT.Value = "INT";
            itmINT.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeINTShort");
            ListItem itmLOG = new ListItem();
            itmLOG.Value = "LOG";
            itmLOG.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeLOGShort");
            ListItem itmWIL = new ListItem();
            itmWIL.Value = "WIL";
            itmWIL.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeWILShort");
            ListItem itmMAG = new ListItem();
            itmMAG.Value = "MAG";
            itmMAG.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeMAGShort");
            ListItem itmRES = new ListItem();
            itmRES.Value = "RES";
            itmRES.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeRESShort");
            lstFilter.Add(itmBOD);
            lstFilter.Add(itmAGI);
            lstFilter.Add(itmREA);
            lstFilter.Add(itmSTR);
            lstFilter.Add(itmCHA);
            lstFilter.Add(itmINT);
            lstFilter.Add(itmLOG);
            lstFilter.Add(itmWIL);
            lstFilter.Add(itmMAG);
            lstFilter.Add(itmRES);

            // Add Skill Groups to the filter.
            objXmlNodeList = objXmlDocument.SelectNodes("/chummer/categories/category[@type = \"active\"]");
            foreach (SkillGroup objGroup in _objCharacter.SkillGroups)
            {
                ListItem itmGroup = new ListItem();
                itmGroup.Value = "GROUP:" + objGroup.Name;
                itmGroup.Name = LanguageManager.Instance.GetString("String_ExpenseSkillGroup") + ": " + objGroup.DisplayName;
                lstFilter.Add(itmGroup);
            }

            cboSkillFilter.DataSource = lstFilter;
            cboSkillFilter.ValueMember = "Value";
            cboSkillFilter.DisplayMember = "Name";
            cboSkillFilter.SelectedIndex = 0;
            cboSkillFilter_SelectedIndexChanged(null, null);

            if (_objCharacter.MetatypeCategory == "Mundane Critters")
                mnuSpecialMutantCritter.Visible = true;
            if (_objCharacter.MetatypeCategory == "Mutant Critters")
                mnuSpecialToxicCritter.Visible = true;
            if (_objCharacter.MetatypeCategory == "Cyberzombie")
                mnuSpecialCyberzombie.Visible = false;

            treCyberware.SortCustom();
            treSpells.SortCustom();
            treComplexForms.SortCustom();
            treQualities.SortCustom();
            treCritterPowers.SortCustom();
            treMartialArts.SortCustom();
            UpdateMentorSpirits();
            UpdateInitiationGradeTree();
            UpdateCharacterInfo();

            _blnIsDirty = false;
            UpdateWindowTitle(false);
            RefreshPasteStatus();

            // Stupid hack to get the MDI icon to show up properly.
            this.Icon = this.Icon.Clone() as System.Drawing.Icon;
	        Timekeeper.Finish("load_frm_create");
	        Timekeeper.Finish("loading");
	        
        }
예제 #4
0
        private void frmCareer_Load(object sender, EventArgs e)
        {
            _blnLoading = true;

            // Remove the Magician, Adept, and Technomancer tabs since they are not in use until the appropriate Quality is selected.
            if (!_objCharacter.MagicianEnabled)
                tabCharacterTabs.TabPages.Remove(tabMagician);
            if (!_objCharacter.AdeptEnabled)
                tabCharacterTabs.TabPages.Remove(tabAdept);
            if (!_objCharacter.TechnomancerEnabled)
                tabCharacterTabs.TabPages.Remove(tabTechnomancer);
            if (!_objCharacter.CritterEnabled)
                tabCharacterTabs.TabPages.Remove(tabCritter);

            mnuSpecialAddBiowareSuite.Visible = _objCharacter.Options.AllowBiowareSuites;

            // Remove the Improvements Tab.
            //tabCharacterTabs.TabPages.Remove(tabImprovements);

            // Remove the Initiation tab if the character does not have access to MAG or RES.
            if (!_objCharacter.MAGEnabled && !_objCharacter.RESEnabled)
                tabCharacterTabs.TabPages.Remove(tabInitiation);
            else
            {
                if (_objCharacter.MAGEnabled)
                {
                    tabInitiation.Text = LanguageManager.Instance.GetString("Tab_Initiation");
                    tsMetamagicAddMetamagic.Text = LanguageManager.Instance.GetString("Button_AddMetamagic");
                    cmdAddMetamagic.Text = LanguageManager.Instance.GetString("Button_AddInitiateGrade");
                    chkJoinGroup.Text = LanguageManager.Instance.GetString("Checkbox_JoinedGroup");
                    chkJoinGroup.Checked = _objCharacter.GroupMember;
                    txtGroupName.Text = _objCharacter.GroupName;
                    txtGroupNotes.Text = _objCharacter.GroupNotes;
                    string strInitTip = LanguageManager.Instance.GetString("Tip_ImproveInitiateGrade").Replace("{0}", (_objCharacter.InitiateGrade + 1).ToString()).Replace("{1}", (10 + ((_objCharacter.InitiateGrade + 1) * _objOptions.KarmaInitiation)).ToString());
                    tipTooltip.SetToolTip(cmdAddMetamagic, strInitTip);
                }
                else
                {
                    tabInitiation.Text = LanguageManager.Instance.GetString("Tab_Submersion");
                    tsMetamagicAddMetamagic.Text = LanguageManager.Instance.GetString("Button_AddEcho");
                    cmdAddMetamagic.Text = LanguageManager.Instance.GetString("Button_AddSubmersionGrade");
                    chkInitiationGroup.Visible = false;
                    chkInitiationOrdeal.Visible = false;
                    chkInitiationSchooling.Visible = false;
                    tsMetamagicAddArt.Visible = false;
                    tsMetamagicAddEnchantment.Visible = false;
                    tsMetamagicAddEnhancement.Visible = false;
                    tsMetamagicAddRitual.Visible = false;
                    treMetamagic.Top = cmdAddMetamagic.Top + cmdAddMetamagic.Height + 6;
                    cmdAddMetamagic.Left = treMetamagic.Left + treMetamagic.Width - cmdAddMetamagic.Width;
                    txtGroupName.Text = _objCharacter.GroupName;
                    txtGroupNotes.Text = _objCharacter.GroupNotes;
                    string strInitTip = LanguageManager.Instance.GetString("Tip_ImproveSubmersionGrade").Replace("{0}", (_objCharacter.SubmersionGrade + 1).ToString()).Replace("{1}", (10 + ((_objCharacter.SubmersionGrade + 1) * _objOptions.KarmaInitiation)).ToString());
                    tipTooltip.SetToolTip(cmdAddMetamagic, strInitTip);
                }
            }

            // If the character has a mugshot, decode it and put it in the PictureBox.
            if (_objCharacter.Mugshot != "")
            {
                byte[] bytImage = Convert.FromBase64String(_objCharacter.Mugshot);
                MemoryStream objStream = new MemoryStream(bytImage, 0, bytImage.Length);
                objStream.Write(bytImage, 0, bytImage.Length);
                Image imgMugshot = Image.FromStream(objStream, true);
                picMugshot.Image = imgMugshot;
            }

            // Populate character information fields.
            XmlDocument objMetatypeDoc = new XmlDocument();
            XmlNode objMetatypeNode;
            string strMetatype = "";
            string strBook = "";
            string strPage = "";

            foreach (Skill objSkill in _objCharacter.Skills)
            {
                if (objSkill.RatingMaximum == 6)
                    objSkill.RatingMaximum = 12;
                else if (objSkill.RatingMaximum == 7)
                    objSkill.RatingMaximum = 13;
            }
            foreach (SkillGroup objSkillGroup in _objCharacter.SkillGroups)
            {
                if (objSkillGroup.RatingMaximum == 6)
                    objSkillGroup.RatingMaximum = 12;
            }

            objMetatypeDoc = XmlManager.Instance.Load("metatypes.xml");
            {
                objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
                if (objMetatypeNode == null)
                    objMetatypeDoc = XmlManager.Instance.Load("critters.xml");
                objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");

                if (objMetatypeNode["translate"] != null)
                    strMetatype = objMetatypeNode["translate"].InnerText;
                else
                    strMetatype = _objCharacter.Metatype;

                strBook = _objOptions.LanguageBookShort(objMetatypeNode["source"].InnerText);
                if (objMetatypeNode["altpage"] != null)
                    strPage = objMetatypeNode["altpage"].InnerText;
                else
                    strPage = objMetatypeNode["page"].InnerText;

                if (_objCharacter.Metavariant != "")
                {
                    objMetatypeNode = objMetatypeNode.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]");

                    if (objMetatypeNode["translate"] != null)
                        strMetatype += " (" + objMetatypeNode["translate"].InnerText + ")";
                    else
                        strMetatype += " (" + _objCharacter.Metavariant + ")";

                    strBook = _objOptions.LanguageBookShort(objMetatypeNode["source"].InnerText);
                    if (objMetatypeNode["altpage"] != null)
                        strPage = objMetatypeNode["altpage"].InnerText;
                    else
                        strPage = objMetatypeNode["page"].InnerText;
                }
            }
            lblMetatype.Text = strMetatype;
            lblMetatypeSource.Text = strBook + " " + strPage;
            if (_objCharacter.Possessed)
                lblPossessed.Text = LanguageManager.Instance.GetString("String_Possessed");
            else
                lblPossessed.Visible = false;
            tipTooltip.SetToolTip(lblMetatypeSource, _objOptions.LanguageBookLong(objMetatypeNode["source"].InnerText) + " " + LanguageManager.Instance.GetString("String_Page") + " " + strPage);

            txtCharacterName.Text = _objCharacter.Name;
            txtSex.Text = _objCharacter.Sex;
            txtAge.Text = _objCharacter.Age;
            txtEyes.Text = _objCharacter.Eyes;
            txtHeight.Text = _objCharacter.Height;
            txtWeight.Text = _objCharacter.Weight;
            txtSkin.Text = _objCharacter.Skin;
            txtHair.Text = _objCharacter.Hair;
            txtDescription.Text = _objCharacter.Description;
            txtBackground.Text = _objCharacter.Background;
            txtConcept.Text = _objCharacter.Concept;
            txtNotes.Text = _objCharacter.Notes;
            txtAlias.Text = _objCharacter.Alias;
            txtPlayerName.Text = _objCharacter.PlayerName;
            txtGameNotes.Text = _objCharacter.GameNotes;
            nudStreetCred.Value = _objCharacter.StreetCred;
            nudNotoriety.Value = _objCharacter.Notoriety;
            nudPublicAware.Value = _objCharacter.PublicAwareness;

            // Check for Special Attributes.
            lblMAGLabel.Enabled = _objCharacter.MAGEnabled;
            lblMAGAug.Enabled = _objCharacter.MAGEnabled;
            lblMAG.Enabled = _objCharacter.MAGEnabled;
            lblMAGMetatype.Enabled = _objCharacter.MAGEnabled;
            lblFoci.Visible = _objCharacter.MAGEnabled;
            treFoci.Visible = _objCharacter.MAGEnabled;
            cmdCreateStackedFocus.Visible = _objCharacter.MAGEnabled;

            lblRESLabel.Enabled = _objCharacter.RESEnabled;
            lblRESAug.Enabled = _objCharacter.RESEnabled;
            lblRES.Enabled = _objCharacter.RESEnabled;
            lblRESMetatype.Enabled = _objCharacter.RESEnabled;

            // Define the XML objects that will be used.
            XmlDocument objXmlDocument = new XmlDocument();

            if (_objCharacter.BuildMethod == CharacterBuildMethod.LifeModule)
            {
                treQualities.Nodes.Add(new TreeNode("Life Modules"));
            }

            // Populate the Qualities list.
            foreach (Quality objQuality in _objCharacter.Qualities)
            {
                TreeNode objNode = new TreeNode();
                objNode.Text = objQuality.DisplayName;
                objNode.Tag = objQuality.InternalId;
                objNode.ContextMenuStrip = cmsQuality;

                if (objQuality.Notes != string.Empty)
                    objNode.ForeColor = Color.SaddleBrown;
                else
                {
                    if (objQuality.OriginSource == QualitySource.Metatype || objQuality.OriginSource == QualitySource.MetatypeRemovable)
                        objNode.ForeColor = SystemColors.GrayText;
                }
                objNode.ToolTipText = objQuality.Notes;

                if (objQuality.Type == QualityType.Positive)
                {
                    treQualities.Nodes[0].Nodes.Add(objNode);
                    treQualities.Nodes[0].Expand();
                }
                else if (objQuality.Type == QualityType.Negative)
                {
                    treQualities.Nodes[1].Nodes.Add(objNode);
                    treQualities.Nodes[1].Expand();
                }
                else if (objQuality.Type == QualityType.LifeModule)
                {
                    treQualities.Nodes[2].Nodes.Add(objNode);
                    treQualities.Nodes[2].Expand();
                }
            }

            // Populate the Magician Traditions list.
            objXmlDocument = XmlManager.Instance.Load("traditions.xml");
            List<ListItem> lstTraditions = new List<ListItem>();
            ListItem objBlank = new ListItem();
            objBlank.Value = "";
            objBlank.Name = "";
            lstTraditions.Add(objBlank);
            foreach (XmlNode objXmlTradition in objXmlDocument.SelectNodes("/chummer/traditions/tradition[" + _objOptions.BookXPath() + "]"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlTradition["name"].InnerText;
                if (objXmlTradition["translate"] != null)
                    objItem.Name = objXmlTradition["translate"].InnerText;
                else
                    objItem.Name = objXmlTradition["name"].InnerText;
                lstTraditions.Add(objItem);
            }
            SortListItem objSort = new SortListItem();
            lstTraditions.Sort(objSort.Compare);
            cboTradition.ValueMember = "Value";
            cboTradition.DisplayMember = "Name";
            cboTradition.DataSource = lstTraditions;

            // Populate the Magician Custom Drain Options list.
            objXmlDocument = XmlManager.Instance.Load("traditions.xml");
            List<ListItem> lstDrainAttributes = new List<ListItem>();
            ListItem objDrainBlank = new ListItem();
            objDrainBlank.Value = "";
            objDrainBlank.Name = "";
            lstDrainAttributes.Add(objDrainBlank);
            foreach (XmlNode objXmlDrain in objXmlDocument.SelectNodes("/chummer/drainattributes/drainattribute"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlDrain["name"].InnerText;
                if (objXmlDrain["translate"] != null)
                    objItem.Name = objXmlDrain["translate"].InnerText;
                else
                    objItem.Name = objXmlDrain["name"].InnerText;
                lstDrainAttributes.Add(objItem);
            }
            SortListItem objDrainSort = new SortListItem();
            lstDrainAttributes.Sort(objDrainSort.Compare);
            cboDrain.ValueMember = "Value";
            cboDrain.DisplayMember = "Name";
            cboDrain.DataSource = lstDrainAttributes;

            // Populate the Magician Custom Spirits lists - Combat.
            objXmlDocument = XmlManager.Instance.Load("traditions.xml");
            List<ListItem> lstSpirit = new List<ListItem>();
            ListItem objSpiritBlank = new ListItem();
            objSpiritBlank.Value = "";
            objSpiritBlank.Name = "";
            lstSpirit.Add(objSpiritBlank);
            foreach (XmlNode objXmlSpirit in objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSpirit["name"].InnerText;
                if (objXmlSpirit["translate"] != null)
                    objItem.Name = objXmlSpirit["translate"].InnerText;
                else
                    objItem.Name = objXmlSpirit["name"].InnerText;
                lstSpirit.Add(objItem);
            }
            SortListItem objSpiritSort = new SortListItem();
            lstSpirit.Sort(objSpiritSort.Compare);

            cboSpiritCombat.ValueMember = "Value";
            cboSpiritCombat.DisplayMember = "Name";
            cboSpiritCombat.DataSource = lstSpirit;

            // Populate the Magician Custom Spirits lists - Detection.
            lstSpirit = new List<ListItem>();
            objSpiritBlank = new ListItem();
            objSpiritBlank.Value = "";
            objSpiritBlank.Name = "";
            lstSpirit.Add(objSpiritBlank);
            foreach (XmlNode objXmlSpirit in objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSpirit["name"].InnerText;
                if (objXmlSpirit["translate"] != null)
                    objItem.Name = objXmlSpirit["translate"].InnerText;
                else
                    objItem.Name = objXmlSpirit["name"].InnerText;
                lstSpirit.Add(objItem);
            }
            objSpiritSort = new SortListItem();
            lstSpirit.Sort(objSpiritSort.Compare);

            cboSpiritDetection.ValueMember = "Value";
            cboSpiritDetection.DisplayMember = "Name";
            cboSpiritDetection.DataSource = lstSpirit;

            // Populate the Magician Custom Spirits lists - Health.
            lstSpirit = new List<ListItem>();
            objSpiritBlank = new ListItem();
            objSpiritBlank.Value = "";
            objSpiritBlank.Name = "";
            lstSpirit.Add(objSpiritBlank);
            foreach (XmlNode objXmlSpirit in objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSpirit["name"].InnerText;
                if (objXmlSpirit["translate"] != null)
                    objItem.Name = objXmlSpirit["translate"].InnerText;
                else
                    objItem.Name = objXmlSpirit["name"].InnerText;
                lstSpirit.Add(objItem);
            }
            objSpiritSort = new SortListItem();
            lstSpirit.Sort(objSpiritSort.Compare);

            cboSpiritHealth.ValueMember = "Value";
            cboSpiritHealth.DisplayMember = "Name";
            cboSpiritHealth.DataSource = lstSpirit;

            // Populate the Magician Custom Spirits lists - Illusion.
            lstSpirit = new List<ListItem>();
            objSpiritBlank = new ListItem();
            objSpiritBlank.Value = "";
            objSpiritBlank.Name = "";
            lstSpirit.Add(objSpiritBlank);
            foreach (XmlNode objXmlSpirit in objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSpirit["name"].InnerText;
                if (objXmlSpirit["translate"] != null)
                    objItem.Name = objXmlSpirit["translate"].InnerText;
                else
                    objItem.Name = objXmlSpirit["name"].InnerText;
                lstSpirit.Add(objItem);
            }
            objSpiritSort = new SortListItem();
            lstSpirit.Sort(objSpiritSort.Compare);

            cboSpiritIllusion.ValueMember = "Value";
            cboSpiritIllusion.DisplayMember = "Name";
            cboSpiritIllusion.DataSource = lstSpirit;

            // Populate the Magician Custom Spirits lists - Manipulation.
            lstSpirit = new List<ListItem>();
            objSpiritBlank = new ListItem();
            objSpiritBlank.Value = "";
            objSpiritBlank.Name = "";
            lstSpirit.Add(objSpiritBlank);
            foreach (XmlNode objXmlSpirit in objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSpirit["name"].InnerText;
                if (objXmlSpirit["translate"] != null)
                    objItem.Name = objXmlSpirit["translate"].InnerText;
                else
                    objItem.Name = objXmlSpirit["name"].InnerText;
                lstSpirit.Add(objItem);
            }
            objSpiritSort = new SortListItem();
            lstSpirit.Sort(objSpiritSort.Compare);

            cboSpiritManipulation.ValueMember = "Value";
            cboSpiritManipulation.DisplayMember = "Name";
            cboSpiritManipulation.DataSource = lstSpirit;

            // Populate the Technomancer Streams list.
            objXmlDocument = XmlManager.Instance.Load("streams.xml");
            List<ListItem> lstStreams = new List<ListItem>();
            lstStreams.Add(objBlank);
            foreach (XmlNode objXmlTradition in objXmlDocument.SelectNodes("/chummer/traditions/tradition[" + _objOptions.BookXPath() + "]"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlTradition["name"].InnerText;
                if (objXmlTradition["translate"] != null)
                    objItem.Name = objXmlTradition["translate"].InnerText;
                else
                    objItem.Name = objXmlTradition["name"].InnerText;
                lstStreams.Add(objItem);
            }
            lstStreams.Sort(objSort.Compare);
            cboStream.ValueMember = "Value";
            cboStream.DisplayMember = "Name";
            cboStream.DataSource = lstStreams;

            // Load the Metatype information before going anywhere else. Doing this later causes the Attributes to get messed up because of calls
            // to UpdateCharacterInformation();
            MetatypeSelected();

            // If the character is a Mystic Adept, set the values for the Mystic Adept NUD.
            int intCharacterMAG = _objCharacter.MAG.TotalValue;
            if (_objCharacter.AdeptEnabled && _objCharacter.MagicianEnabled)
            {
                lblMysticAdeptMAGAdept.Text = _objCharacter.MAGAdept.ToString();
                intCharacterMAG = _objCharacter.MAGMagician;

                lblMysticAdeptAssignment.Visible = true;
                lblMysticAdeptMAGAdept.Visible = true;
                // cmdIncreasePowerPoints.Visible = true;
            }

            // Load the Skills information.
            objXmlDocument = XmlManager.Instance.Load("skills.xml");

            List<ListItem> lstComplexFormSkills = new List<ListItem>();

            // Populate the Skills Controls.
            XmlNodeList objXmlNodeList = objXmlDocument.SelectNodes("/chummer/skills/skill[" + _objCharacter.Options.BookXPath() + "]");
            // Counter to keep track of the number of Controls that have been added to the Panel so we can determine their vertical positioning.
            int i = -1;
            foreach (Skill objSkill in _objCharacter.Skills)
            {
                if (!objSkill.KnowledgeSkill && !objSkill.ExoticSkill)
                {
                    i++;
                    SkillControl objSkillControl = new SkillControl();
                    objSkillControl.SkillObject = objSkill;

                    // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                    objSkillControl.RatingChanged += objActiveSkill_RatingChanged;
                    objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                    objSkillControl.SpecializationLeave += objSkill_SpecializationLeave;
                    objSkillControl.SkillKarmaClicked += objSkill_KarmaClicked;
                    objSkillControl.DiceRollerClicked += objSkill_DiceRollerClicked;

                    objSkillControl.SkillName = objSkill.Name;
                    objSkillControl.SkillCategory = objSkill.SkillCategory;
                    objSkillControl.SkillGroup = objSkill.SkillGroup;
                    objSkillControl.SkillRatingMaximum = objSkill.RatingMaximum;
                    objSkillControl.SkillRating = objSkill.Rating;
                    objSkillControl.SkillSpec = objSkill.Specialization;

                    XmlNode objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + objSkill.Name + "\"]");
                    // Populate the Skill's Specializations (if any).
                    foreach (XmlNode objXmlSpecialization in objXmlSkill.SelectNodes("specs/spec"))
                    {
                        if (objXmlSpecialization.Attributes["translate"] != null)
                            objSkillControl.AddSpec(objXmlSpecialization.Attributes["translate"].InnerText);
                        else
                            objSkillControl.AddSpec(objXmlSpecialization.InnerText);
                    }

                    // Set the control's vertical position and add it to the Skills Panel.
                    objSkillControl.Width = 510;
                    objSkillControl.AutoScroll = false;
                    panActiveSkills.Controls.Add(objSkillControl);

                    // Determine if this Skill should be added to the list of Skills for Comlex Form Tests.
                    bool blnAddSkill = true;
                    if (objSkill.Attribute == "MAG" || objSkill.SkillCategory == "Magical Active")
                        blnAddSkill = false;

                    if (blnAddSkill)
                    {
                        ListItem objItem = new ListItem();
                        objItem.Value = objSkill.Name;
                        objItem.Name = objSkill.DisplayName;
                        lstComplexFormSkills.Add(objItem);
                    }
                }
            }

            // Exotic Skills.
            foreach (Skill objSkill in _objCharacter.Skills)
            {
                if (objSkill.ExoticSkill)
                {
                    i++;
                    SkillControl objSkillControl = new SkillControl();
                    objSkillControl.SkillObject = objSkill;

                    // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                    objSkillControl.RatingChanged += objActiveSkill_RatingChanged;
                    objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                    objSkillControl.SkillKarmaClicked += objSkill_KarmaClicked;
                    objSkillControl.DiceRollerClicked += objSkill_DiceRollerClicked;

                    objSkillControl.SkillName = objSkill.Name;
                    objSkillControl.SkillCategory = objSkill.SkillCategory;
                    objSkillControl.SkillGroup = objSkill.SkillGroup;
                    objSkillControl.SkillRatingMaximum = objSkill.RatingMaximum;
                    objSkillControl.SkillRating = objSkill.Rating;
                    objSkillControl.SkillSpec = objSkill.Specialization;

                    XmlNode objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + objSkill.Name + "\"]");
                    // Populate the Skill's Specializations (if any).
                    foreach (XmlNode objXmlSpecialization in objXmlSkill.SelectNodes("specs/spec"))
                    {
                        if (objXmlSpecialization.Attributes["translate"] != null)
                            objSkillControl.AddSpec(objXmlSpecialization.Attributes["translate"].InnerText);
                        else
                            objSkillControl.AddSpec(objXmlSpecialization.InnerText);
                    }

                    // Look through the Weapons file and grab the names of items that are part of the appropriate Exotic Category or use the matching Exoctic Skill.
                    XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");
                    XmlNodeList objXmlWeaponList = objXmlWeaponDocument.SelectNodes("/chummer/weapons/weapon[category = \"" + objSkill.Name + "s\" or useskill = \"" + objSkill.Name + "\"]");
                    foreach (XmlNode objXmlWeapon in objXmlWeaponList)
                    {
                        if (objXmlWeapon["translate"] != null)
                            objSkillControl.AddSpec(objXmlWeapon["translate"].InnerText);
                        else
                            objSkillControl.AddSpec(objXmlWeapon["name"].InnerText);
                    }

                    // Set the control's vertical position and add it to the Skills Panel.
                    objSkillControl.Top = i * objSkillControl.Height;
                    objSkillControl.Width = 510;
                    objSkillControl.AutoScroll = false;
                    panActiveSkills.Controls.Add(objSkillControl);
                }
            }

            // Populate the Skill Groups list.
            i = -1;
            foreach (SkillGroup objGroup in _objCharacter.SkillGroups)
            {
                i++;
                SkillGroupControl objGroupControl = new SkillGroupControl(_objCharacter.Options, _objCharacter, true);
                objGroupControl.SkillGroupObject = objGroup;

                // Attach an EventHandler for the GetRatingChanged Event.
                objGroupControl.GroupRatingChanged += objGroup_RatingChanged;
                objGroupControl.GroupKarmaClicked += objGroup_KarmaClicked;

                // Populate the control, set its vertical position and add it to the Skill Groups Panel. A Skill Group cannot start with a Rating higher than 4.
                objGroupControl.GroupName = objGroup.Name;
                if (objGroup.Rating > objGroup.RatingMaximum)
                    objGroup.RatingMaximum = objGroup.Rating;
                objGroupControl.GroupRatingMaximum = objGroup.RatingMaximum;
                objGroupControl.GroupRating = objGroup.Rating;
                objGroupControl.Top = i * objGroupControl.Height;
                objGroupControl.Width = 250;

                if (_objCharacter.Uneducated)
                {
                    objGroupControl.IsEnabled = !objGroup.HasTechnicalSkills;
                }

                if (_objCharacter.Uncouth)
                {
                    objGroupControl.IsEnabled = !objGroup.HasSocialSkills;
                }

                if (_objCharacter.Infirm)
                {
                    objGroupControl.IsEnabled = !objGroup.HasPhysicalSkills;
                }

                panSkillGroups.Controls.Add(objGroupControl);
            }

            // Populate Knowledge Skills.
            i = -1;
            foreach (Skill objSkill in _objCharacter.Skills)
            {
                if (objSkill.KnowledgeSkill)
                {
                    i++;
                    SkillControl objSkillControl = new SkillControl();
                    objSkillControl.SkillObject = objSkill;

                    // Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
                    objSkillControl.RatingChanged += objKnowledgeSkill_RatingChanged;
                    objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
                    objSkillControl.SpecializationLeave += objSkill_SpecializationLeave;
                    objSkillControl.DeleteSkill += objKnowledgeSkill_DeleteSkill;
                    objSkillControl.SkillKarmaClicked += objKnowledgeSkill_KarmaClicked;
                    objSkillControl.DiceRollerClicked += objSkill_DiceRollerClicked;

                    objSkillControl.KnowledgeSkill = true;
                    objSkillControl.SkillCategory = objSkill.SkillCategory;
                    objSkillControl.AllowDelete = true;
                    objSkillControl.SkillRatingMaximum = objSkill.RatingMaximum;
                    objSkillControl.SkillRating = objSkill.Rating;
                    objSkillControl.SkillName = objSkill.Name;
                    objSkillControl.SkillSpec = objSkill.Specialization;
                    objSkillControl.Top = i * objSkillControl.Height;
                    objSkillControl.AutoScroll = false;
                    panKnowledgeSkills.Controls.Add(objSkillControl);
                }
            }

            // Populate Contacts and Enemies.
            int intContact = -1;
            int intEnemy = -1;
            foreach (Contact objContact in _objCharacter.Contacts)
            {
                if (objContact.EntityType == ContactType.Contact)
                {
                    intContact++;
                    ContactControl objContactControl = new ContactControl(_objCharacter);
                    // Attach an EventHandler for the ConnectionRatingChanged, LoyaltyRatingChanged, DeleteContact, and FileNameChanged Events.
                    objContactControl.ConnectionRatingChanged += objContact_ConnectionRatingChanged;
                    objContactControl.LoyaltyRatingChanged += objContact_LoyaltyRatingChanged;
                    objContactControl.DeleteContact += objContact_DeleteContact;
                    objContactControl.FileNameChanged += objContact_FileNameChanged;

                    objContactControl.ContactObject = objContact;
                    objContactControl.ContactName = objContact.Name;
                    objContactControl.ContactLocation = objContact.Location;
                    objContactControl.ContactRole = objContact.Role;
                    objContactControl.ConnectionRating = objContact.Connection;
                    objContactControl.LoyaltyRating = objContact.Loyalty;
                    objContactControl.EntityType = objContact.EntityType;
                    objContactControl.BackColor = objContact.Colour;
                    objContactControl.IsGroup = objContact.IsGroup;
                    if (objContact.MadeMan)
                    {
                        objContactControl.IsGroup = objContact.MadeMan;
                    }

                    objContactControl.Top = intContact * objContactControl.Height;
                    panContacts.Controls.Add(objContactControl);
                }
                if (objContact.EntityType == ContactType.Enemy)
                {
                    intEnemy++;
                    ContactControl objContactControl = new ContactControl(_objCharacter);
                    // Attach an EventHandler for the ConnectioNRatingChanged, LoyaltyRatingChanged, DeleteContact, and FileNameChanged Events.
                    objContactControl.ConnectionRatingChanged += objEnemy_ConnectionRatingChanged;
                    objContactControl.LoyaltyRatingChanged += objEnemy_LoyaltyRatingChanged;
                    objContactControl.DeleteContact += objEnemy_DeleteContact;
                    objContactControl.FileNameChanged += objEnemy_FileNameChanged;

                    objContactControl.IsEnemy = true;
                    objContactControl.ContactObject = objContact;
                    objContactControl.ContactName = objContact.Name;
                    objContactControl.ContactLocation = objContact.Location;
                    objContactControl.ContactRole = objContact.Role;
                    objContactControl.ConnectionRating = objContact.Connection;
                    objContactControl.LoyaltyRating = objContact.Loyalty;
                    objContactControl.EntityType = objContact.EntityType;
                    objContactControl.BackColor = objContact.Colour;
                    objContactControl.IsGroup = objContact.IsGroup;

                    objContactControl.Top = intEnemy * objContactControl.Height;
                    panEnemies.Controls.Add(objContactControl);
                }
                if (objContact.EntityType == ContactType.Pet)
                {
                    PetControl objContactControl = new PetControl();
                    // Attach an EventHandler for the DeleteContact and FileNameChanged Events.
                    objContactControl.DeleteContact += objPet_DeleteContact;
                    objContactControl.FileNameChanged += objPet_FileNameChanged;

                    objContactControl.ContactObject = objContact;
                    objContactControl.ContactName = objContact.Name;
                    objContactControl.BackColor = objContact.Colour;

                    panPets.Controls.Add(objContactControl);
                }
            }

            // Populate Armor.
            // Start by populating Locations.
            foreach (string strLocation in _objCharacter.ArmorBundles)
            {
                TreeNode objLocation = new TreeNode();
                objLocation.Tag = strLocation;
                objLocation.Text = strLocation;
                objLocation.ContextMenuStrip = cmsArmorLocation;
                treArmor.Nodes.Add(objLocation);
            }
            foreach (Armor objArmor in _objCharacter.Armor)
            {
                _objFunctions.CreateArmorTreeNode(objArmor, treArmor, cmsArmor, cmsArmorMod, cmsArmorGear);
            }

            // Populate Weapons.
            // Start by populating Locations.
            foreach (string strLocation in _objCharacter.WeaponLocations)
            {
                TreeNode objLocation = new TreeNode();
                objLocation.Tag = strLocation;
                objLocation.Text = strLocation;
                objLocation.ContextMenuStrip = cmsWeaponLocation;
                treWeapons.Nodes.Add(objLocation);
            }
            foreach (Weapon objWeapon in _objCharacter.Weapons)
            {
                _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponMod, cmsWeaponAccessory, cmsWeaponAccessoryGear);
            }

            PopulateCyberware();

            // Populate Spell list.
            foreach (Spell objSpell in _objCharacter.Spells)
            {
                TreeNode objNode = new TreeNode();
                objNode.Text = objSpell.DisplayName;
                objNode.Tag = objSpell.InternalId;
                objNode.ContextMenuStrip = cmsSpell;
                if (objSpell.Notes != string.Empty)
                    objNode.ForeColor = Color.SaddleBrown;
                objNode.ToolTipText = objSpell.Notes;

                switch (objSpell.Category)
                {
                    case "Combat":
                        treSpells.Nodes[0].Nodes.Add(objNode);
                        treSpells.Nodes[0].Expand();
                        break;
                    case "Detection":
                        treSpells.Nodes[1].Nodes.Add(objNode);
                        treSpells.Nodes[1].Expand();
                        break;
                    case "Health":
                        treSpells.Nodes[2].Nodes.Add(objNode);
                        treSpells.Nodes[2].Expand();
                        break;
                    case "Illusion":
                        treSpells.Nodes[3].Nodes.Add(objNode);
                        treSpells.Nodes[3].Expand();
                        break;
                    case "Manipulation":
                        treSpells.Nodes[4].Nodes.Add(objNode);
                        treSpells.Nodes[4].Expand();
                        break;
                    case "Rituals":
                        int intNode = 5;
                        if (_objCharacter.AdeptEnabled && !_objCharacter.MagicianEnabled)
                            intNode = 0;
                        treSpells.Nodes[intNode].Nodes.Add(objNode);
                        treSpells.Nodes[intNode].Expand();
                        break;
                    case "Enchantments":
                        treSpells.Nodes[6].Nodes.Add(objNode);
                        treSpells.Nodes[6].Expand();
                        break;
                }
            }

            // Populate Adept Powers.
            i = -1;
            foreach (Power objPower in _objCharacter.Powers)
            {
                i++;
                PowerControl objPowerControl = new PowerControl();
                objPowerControl.PowerObject = objPower;

                // Attach an EventHandler for the PowerRatingChanged Event.
                objPowerControl.PowerRatingChanged += objPower_PowerRatingChanged;
                objPowerControl.DeletePower += objPower_DeletePower;

                objPowerControl.PowerName = objPower.Name;
                objPowerControl.Extra = objPower.Extra;
                objPowerControl.PointsPerLevel = objPower.PointsPerLevel;
                objPowerControl.AdeptWayDiscount = objPower.AdeptWayDiscount;
                objPowerControl.LevelEnabled = objPower.LevelsEnabled;
                if (objPower.MaxLevels > 0)
                    objPowerControl.MaxLevels = objPower.MaxLevels;
                objPowerControl.RefreshMaximum(_objCharacter.MAG.TotalValue);
                if (objPower.Rating < 1)
                    objPower.Rating = 1;
                objPowerControl.PowerLevel = Convert.ToInt32(objPower.Rating);
                if (objPower.DiscountedAdeptWay)
                    objPowerControl.DiscountedByAdeptWay = true;
                if (objPower.DiscountedGeas)
                    objPowerControl.DiscountedByGeas = true;

                objPowerControl.Top = i * objPowerControl.Height;
                panPowers.Controls.Add(objPowerControl);
            }

            // Populate Magician Spirits.
            i = -1;
            foreach (Spirit objSpirit in _objCharacter.Spirits)
            {
                if (objSpirit.EntityType == SpiritType.Spirit)
                {
                    i++;
                    SpiritControl objSpiritControl = new SpiritControl(true);
                    objSpiritControl.SpiritObject = objSpirit;

                    // Attach an EventHandler for the ServicesOwedChanged Event.
                    objSpiritControl.ServicesOwedChanged += objSpirit_ServicesOwedChanged;
                    objSpiritControl.ForceChanged += objSpirit_ForceChanged;
                    objSpiritControl.BoundChanged += objSpirit_BoundChanged;
                    objSpiritControl.DeleteSpirit += objSpirit_DeleteSpirit;
                    objSpiritControl.FileNameChanged += objSpirit_FileNameChanged;

                    objSpiritControl.SpiritName = objSpirit.Name;
                    objSpiritControl.ServicesOwed = objSpirit.ServicesOwed;
                    if (_objOptions.SpiritForceBasedOnTotalMAG)
                        objSpiritControl.ForceMaximum = _objCharacter.MAG.TotalValue * 2;
                    else
                        objSpiritControl.ForceMaximum = intCharacterMAG * 2;
                    objSpiritControl.CritterName = objSpirit.CritterName;
                    objSpiritControl.Force = objSpirit.Force;
                    objSpiritControl.Bound = objSpirit.Bound;
                    objSpiritControl.RebuildSpiritList(_objCharacter.MagicTradition);

                    objSpiritControl.Top = i * objSpiritControl.Height;
                    panSpirits.Controls.Add(objSpiritControl);
                }
            }

            // Populate Technomancer Sprites.
            i = -1;
            foreach (Spirit objSpirit in _objCharacter.Spirits)
            {
                if (objSpirit.EntityType == SpiritType.Sprite)
                {
                    i++;
                    SpiritControl objSpiritControl = new SpiritControl(true);
                    objSpiritControl.SpiritObject = objSpirit;
                    objSpiritControl.EntityType = SpiritType.Sprite;

                    // Attach an EventHandler for the ServicesOwedChanged Event.
                    objSpiritControl.ServicesOwedChanged += objSprite_ServicesOwedChanged;
                    objSpiritControl.ForceChanged += objSprite_ForceChanged;
                    objSpiritControl.BoundChanged += objSprite_BoundChanged;
                    objSpiritControl.DeleteSpirit += objSprite_DeleteSpirit;
                    objSpiritControl.FileNameChanged += objSprite_FileNameChanged;

                    objSpiritControl.SpiritName = objSpirit.Name;
                    objSpiritControl.ServicesOwed = objSpirit.ServicesOwed;
                    objSpiritControl.ForceMaximum = _objCharacter.RES.TotalValue * 2;
                    objSpiritControl.CritterName = objSpirit.CritterName;
                    objSpiritControl.Force = objSpirit.Force;
                    objSpiritControl.Bound = objSpirit.Bound;
                    objSpiritControl.RebuildSpiritList(_objCharacter.TechnomancerStream);

                    objSpiritControl.Top = i * objSpiritControl.Height;
                    panSprites.Controls.Add(objSpiritControl);
                }
            }

            // Populate Technomancer Complex Forms/Programs.
            foreach (ComplexForm objProgram in _objCharacter.ComplexForms)
            {
                TreeNode objNode = new TreeNode();
                objNode.Text = objProgram.DisplayName;
                objNode.Tag = objProgram.InternalId;
                if (objProgram.Notes != string.Empty)
                    objNode.ForeColor = Color.SaddleBrown;
                objNode.ToolTipText = objProgram.Notes;
                treComplexForms.Nodes[0].Nodes.Add(objNode);
                treComplexForms.Nodes[0].Expand();
            }

            // Populate Martial Arts.
            foreach (MartialArt objMartialArt in _objCharacter.MartialArts)
            {
                TreeNode objMartialArtNode = new TreeNode();
                objMartialArtNode.Text = objMartialArt.DisplayName;
                objMartialArtNode.Tag = objMartialArt.Name;
                objMartialArtNode.ContextMenuStrip = cmsMartialArts;
                if (objMartialArt.Notes != string.Empty)
                    objMartialArtNode.ForeColor = Color.SaddleBrown;
                objMartialArtNode.ToolTipText = objMartialArt.Notes;

                foreach (MartialArtAdvantage objAdvantage in objMartialArt.Advantages)
                {
                    TreeNode objAdvantageNode = new TreeNode();
                    objAdvantageNode.Text = objAdvantage.DisplayName;
                    objAdvantageNode.Tag = objAdvantage.InternalId;
                    objAdvantageNode.ContextMenuStrip = cmsTechnique;

                    if (objAdvantage.Notes != string.Empty)
                        objAdvantageNode.ForeColor = Color.SaddleBrown;
                    else
                        objAdvantageNode.ForeColor = SystemColors.WindowText;

                    objAdvantageNode.ToolTipText = objAdvantage.Notes;
                    objMartialArtNode.Nodes.Add(objAdvantageNode);
                    objMartialArtNode.Expand();
                }

                treMartialArts.Nodes[0].Nodes.Add(objMartialArtNode);
                treMartialArts.Nodes[0].Expand();
            }

            // Populate Martial Art Maneuvers.
            foreach (MartialArtManeuver objManeuver in _objCharacter.MartialArtManeuvers)
            {
                TreeNode objManeuverNode = new TreeNode();
                objManeuverNode.Text = objManeuver.DisplayName;
                objManeuverNode.Tag = objManeuver.InternalId;
                objManeuverNode.ContextMenuStrip = cmsMartialArtManeuver;
                if (objManeuver.Notes != string.Empty)
                    objManeuverNode.ForeColor = Color.SaddleBrown;
                objManeuverNode.ToolTipText = objManeuver.Notes;

                treMartialArts.Nodes[1].Nodes.Add(objManeuverNode);
                treMartialArts.Nodes[1].Expand();
            }

            // Populate Limit Modifiers.
            foreach (LimitModifier objLimitModifier in _objCharacter.LimitModifiers)
            {
                TreeNode objLimitModifierNode = new TreeNode();
                objLimitModifierNode.Text = objLimitModifier.DisplayName;
                objLimitModifierNode.Tag = objLimitModifier.Name;
                objLimitModifierNode.ContextMenuStrip = cmsMartialArts;
                if (objLimitModifier.Notes != string.Empty)
                    objLimitModifierNode.ForeColor = Color.SaddleBrown;
                objLimitModifierNode.ToolTipText = objLimitModifier.Notes;
                objLimitModifierNode.ContextMenuStrip = cmsLimitModifier;

                switch (objLimitModifier.Limit)
                {
                    case "Physical":
                        treLimit.Nodes[0].Nodes.Add(objLimitModifierNode);
                        treLimit.Nodes[0].Expand();
                        break;
                    case "Mental":
                        treLimit.Nodes[1].Nodes.Add(objLimitModifierNode);
                        treLimit.Nodes[1].Expand();
                        break;
                    case "Social":
                        treLimit.Nodes[2].Nodes.Add(objLimitModifierNode);
                        treLimit.Nodes[2].Expand();
                        break;
                }
            }

            // Populate Lifestyles.
            foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
            {
                TreeNode objLifestyleNode = new TreeNode();
                objLifestyleNode.Text = objLifestyle.DisplayName;
                objLifestyleNode.Tag = objLifestyle.InternalId;
                if (objLifestyle.BaseLifestyle != "")
                    objLifestyleNode.ContextMenuStrip = cmsAdvancedLifestyle;
                else
                    objLifestyleNode.ContextMenuStrip = cmsLifestyleNotes;
                if (objLifestyle.Notes != string.Empty)
                    objLifestyleNode.ForeColor = Color.SaddleBrown;
                objLifestyleNode.ToolTipText = objLifestyle.Notes;
                treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode);
            }
            treLifestyles.Nodes[0].Expand();

            PopulateGearList();

            // Populate Foci.
            _objController.PopulateFocusList(treFoci);

            // Populate Vehicles.
            foreach (Vehicle objVehicle in _objCharacter.Vehicles)
            {
                _objFunctions.CreateVehicleTreeNode(objVehicle, treVehicles, cmsVehicle, cmsVehicleLocation, cmsVehicleWeapon, cmsVehicleWeaponMod, cmsVehicleWeaponAccessory, cmsVehicleWeaponAccessoryGear, cmsVehicleGear);
            }

            UpdateInitiationGradeTree();

            if (_objCharacter.MagicTradition != "")
            {
                objXmlDocument = XmlManager.Instance.Load("traditions.xml");
                XmlNode objXmlTradition = objXmlDocument.SelectSingleNode("/chummer/traditions/tradition[name = \"" + _objCharacter.MagicTradition + "\"]");
                lblDrainAttributes.Text = objXmlTradition["drain"].InnerText;

                // Update the Drain Attribute Value.
                try
                {
                    XPathNavigator nav = objXmlDocument.CreateNavigator();
                    string strDrain = lblDrainAttributes.Text.Replace(LanguageManager.Instance.GetString("String_AttributeBODShort"), _objCharacter.BOD.Value.ToString());
                    strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeAGIShort"), _objCharacter.AGI.Value.ToString());
                    strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeREAShort"), _objCharacter.REA.Value.ToString());
                    strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeSTRShort"),_objCharacter.STR.Value.ToString());
                    strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeCHAShort"), _objCharacter.CHA.Value.ToString());
                    strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeINTShort"), _objCharacter.INT.Value.ToString());
                    strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeLOGShort"), _objCharacter.LOG.Value.ToString());
                    strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeWILShort"), _objCharacter.WIL.Value.ToString());
                    strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeMAGShort"), _objCharacter.MAG.TotalValue.ToString());
                    XPathExpression xprDrain = nav.Compile(strDrain);
                    int intDrain = Convert.ToInt32(nav.Evaluate(xprDrain).ToString());
                    intDrain += _objImprovementManager.ValueOf(Improvement.ImprovementType.DrainResistance);
                    lblDrainAttributesValue.Text = intDrain.ToString();
                }
                catch
                {
                }
            }

            if (_objCharacter.TechnomancerStream != "")
            {
                objXmlDocument = XmlManager.Instance.Load("streams.xml");
                XmlNode objXmlTradition = objXmlDocument.SelectSingleNode("/chummer/traditions/tradition[name = \"" + _objCharacter.TechnomancerStream + "\"]");
                lblFadingAttributes.Text = objXmlTradition["drain"].InnerText;

                // Update the Fading Attribute Value.
                try
                {
                    XPathNavigator nav = objXmlDocument.CreateNavigator();
                    string strFading = lblFadingAttributes.Text.Replace(LanguageManager.Instance.GetString("String_AttributeBODShort"), _objCharacter.BOD.Value.ToString());
                    strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeAGIShort"), _objCharacter.AGI.Value.ToString());
                    strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeREAShort"), _objCharacter.REA.Value.ToString());
                    strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeSTRShort"), _objCharacter.STR.Value.ToString());
                    strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeCHAShort"), _objCharacter.CHA.Value.ToString());
                    strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeINTShort"), _objCharacter.INT.Value.ToString());
                    strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeLOGShort"), _objCharacter.LOG.Value.ToString());
                    strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeWILShort"), _objCharacter.WIL.Value.ToString());
                    strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeRESShort"), _objCharacter.RES.TotalValue.ToString());
                    XPathExpression xprFading = nav.Compile(strFading);
                    int intFading = Convert.ToInt32(nav.Evaluate(xprFading).ToString());
                    intFading += _objImprovementManager.ValueOf(Improvement.ImprovementType.FadingResistance);
                    lblFadingAttributesValue.Text = intFading.ToString();
                }
                catch
                {
                }
            }

            // Populate Critter Powers.
            foreach (CritterPower objPower in _objCharacter.CritterPowers)
            {
                TreeNode objNode = new TreeNode();
                objNode.Text = objPower.DisplayName;
                objNode.Tag = objPower.InternalId;
                objNode.ContextMenuStrip = cmsCritterPowers;
                if (objPower.Notes != string.Empty)
                    objNode.ForeColor = Color.SaddleBrown;
                objNode.ToolTipText = objPower.Notes;

                if (objPower.Category != "Weakness")
                {
                    treCritterPowers.Nodes[0].Nodes.Add(objNode);
                    treCritterPowers.Nodes[0].Expand();
                }
                else
                {
                    treCritterPowers.Nodes[1].Nodes.Add(objNode);
                    treCritterPowers.Nodes[1].Expand();
                }
            }

            _blnLoading = false;

            // Select the Magician's Tradition.
            if (_objCharacter.MagicTradition != "")
                cboTradition.SelectedValue = _objCharacter.MagicTradition;

            if (_objCharacter.TraditionName != "")
                txtTraditionName.Text = _objCharacter.TraditionName;

            if (_objCharacter.TraditionDrain != "")
                cboDrain.SelectedValue = _objCharacter.TraditionDrain;

            if (_objCharacter.SpiritCombat != "")
                cboSpiritCombat.SelectedValue = _objCharacter.SpiritCombat;

            if (_objCharacter.SpiritDetection != "")
                cboSpiritDetection.SelectedValue = _objCharacter.SpiritDetection;

            if (_objCharacter.SpiritHealth != "")
                cboSpiritHealth.SelectedValue = _objCharacter.SpiritHealth;

            if (_objCharacter.SpiritIllusion != "")
                cboSpiritIllusion.SelectedValue = _objCharacter.SpiritIllusion;

            if (_objCharacter.SpiritManipulation != "")
                cboSpiritManipulation.SelectedValue = _objCharacter.SpiritManipulation;

            // Select the Technomancer's Stream.
            if (_objCharacter.TechnomancerStream != "")
                cboStream.SelectedValue = _objCharacter.TechnomancerStream;

            // Clear the Dirty flag which gets set when creating a new Character.
            _blnIsDirty = false;
            UpdateWindowTitle();
            if (_objCharacter.AdeptEnabled)
                CalculatePowerPoints();

            treGear.ItemDrag += treGear_ItemDrag;
            treGear.DragEnter += treGear_DragEnter;
            treGear.DragDrop += treGear_DragDrop;

            treLifestyles.ItemDrag += treLifestyles_ItemDrag;
            treLifestyles.DragEnter += treLifestyles_DragEnter;
            treLifestyles.DragDrop += treLifestyles_DragDrop;

            treArmor.ItemDrag += treArmor_ItemDrag;
            treArmor.DragEnter += treArmor_DragEnter;
            treArmor.DragDrop += treArmor_DragDrop;

            treWeapons.ItemDrag += treWeapons_ItemDrag;
            treWeapons.DragEnter += treWeapons_DragEnter;
            treWeapons.DragDrop += treWeapons_DragDrop;

            treVehicles.ItemDrag += treVehicles_ItemDrag;
            treVehicles.DragEnter += treVehicles_DragEnter;
            treVehicles.DragDrop += treVehicles_DragDrop;

            treImprovements.ItemDrag += treImprovements_ItemDrag;
            treImprovements.DragEnter += treImprovements_DragEnter;
            treImprovements.DragDrop += treImprovements_DragDrop;

            // Merge the ToolStrips.
            ToolStripManager.RevertMerge("toolStrip");
            ToolStripManager.Merge(toolStrip, "toolStrip");

            // If this is a Sprite, re-label the Mental Attribute Labels.
            if (_objCharacter.Metatype.EndsWith("Sprite"))
            {
                lblBODLabel.Enabled = false;
                lblAGILabel.Enabled = false;
                lblREALabel.Enabled = false;
                lblSTRLabel.Enabled = false;
                lblCHALabel.Text = LanguageManager.Instance.GetString("String_AttributePilot");
                lblINTLabel.Text = LanguageManager.Instance.GetString("String_AttributeResponse");
                lblLOGLabel.Text = LanguageManager.Instance.GetString("String_AttributeFirewall");
                lblWILLabel.Enabled = false;
            }
            else if (_objCharacter.Metatype.EndsWith("A.I.") || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients")
            {
                lblRatingLabel.Visible = true;
                lblRating.Visible = true;
                lblSystemLabel.Visible = true;
                lblSystem.Visible = true;
                lblFirewallLabel.Visible = true;
                lblFirewall.Visible = true;
                lblResponseLabel.Visible = true;
                nudResponse.Visible = true;
                nudResponse.Enabled = true;
                nudResponse.Value = _objCharacter.Response;
                lblSignalLabel.Visible = true;
                nudSignal.Visible = true;
                nudSignal.Enabled = true;
                nudSignal.Value = _objCharacter.Signal;
            }

            mnuSpecialConvertToFreeSprite.Visible = _objCharacter.IsSprite;

            // Run through all of the Skills and Enable/Disable them as needed.
            foreach (SkillControl objSkillControl in panActiveSkills.Controls)
            {
                if (objSkillControl.Attribute == "MAG")
                    objSkillControl.Enabled = _objCharacter.MAGEnabled;
                if (objSkillControl.Attribute == "RES")
                    objSkillControl.Enabled = _objCharacter.RESEnabled;
            }
            // Run through all of the Skill Groups and Disable them if all of their Skills are currently inaccessible.
            foreach (SkillGroupControl objSkillGroupControl in panSkillGroups.Controls)
            {
                bool blnEnabled = false;
                foreach (Skill objSkill in _objCharacter.Skills)
                {
                    if (objSkill.SkillGroup == objSkillGroupControl.GroupName)
                    {
                        if (objSkill.Attribute == "MAG" || objSkill.Attribute == "RES")
                        {
                            if (objSkill.Attribute == "MAG" && _objCharacter.MAGEnabled)
                                blnEnabled = true;
                            if (objSkill.Attribute == "RES" && _objCharacter.RESEnabled)
                                blnEnabled = true;
                        }
                        else
                            blnEnabled = true;
                    }
                }
                objSkillGroupControl.IsEnabled = blnEnabled;
                if (!blnEnabled)
                    objSkillGroupControl.GroupRating = 0;
            }

            // Populate the Skill Filter DropDown.
            List<ListItem> lstFilter = new List<ListItem>();
            ListItem itmAll = new ListItem();
            itmAll.Value = "0";
            itmAll.Name = LanguageManager.Instance.GetString("String_SkillFilterAll");
            ListItem itmRatingAboveZero = new ListItem();
            itmRatingAboveZero.Value = "1";
            itmRatingAboveZero.Name = LanguageManager.Instance.GetString("String_SkillFilterRatingAboveZero");
            ListItem itmTotalRatingAboveZero = new ListItem();
            itmTotalRatingAboveZero.Value = "2";
            itmTotalRatingAboveZero.Name = LanguageManager.Instance.GetString("String_SkillFilterTotalRatingAboveZero");
            ListItem itmRatingEqualZero = new ListItem();
            itmRatingEqualZero.Value = "3";
            itmRatingEqualZero.Name = LanguageManager.Instance.GetString("String_SkillFilterRatingZero");
            lstFilter.Add(itmAll);
            lstFilter.Add(itmRatingAboveZero);
            lstFilter.Add(itmTotalRatingAboveZero);
            lstFilter.Add(itmRatingEqualZero);

            objXmlDocument = XmlManager.Instance.Load("skills.xml");
            objXmlNodeList = objXmlDocument.SelectNodes("/chummer/categories/category[@type = \"active\"]");
            foreach (XmlNode objNode in objXmlNodeList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objNode.InnerText;
                if (objNode.Attributes["translate"] != null)
                    objItem.Name = LanguageManager.Instance.GetString("Label_Category") + " " + objNode.Attributes["translate"].InnerText;
                else
                    objItem.Name = LanguageManager.Instance.GetString("Label_Category") + " " + objNode.InnerText;
                lstFilter.Add(objItem);
            }

            // Add items for Attributes.
            ListItem itmBOD = new ListItem();
            itmBOD.Value = "BOD";
            itmBOD.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeBODShort");
            ListItem itmAGI = new ListItem();
            itmAGI.Value = "AGI";
            itmAGI.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeAGIShort");
            ListItem itmREA = new ListItem();
            itmREA.Value = "REA";
            itmREA.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeREAShort");
            ListItem itmSTR = new ListItem();
            itmSTR.Value = "STR";
            itmSTR.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeSTRShort");
            ListItem itmCHA = new ListItem();
            itmCHA.Value = "CHA";
            itmCHA.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeCHAShort");
            ListItem itmINT = new ListItem();
            itmINT.Value = "INT";
            itmINT.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeINTShort");
            ListItem itmLOG = new ListItem();
            itmLOG.Value = "LOG";
            itmLOG.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeLOGShort");
            ListItem itmWIL = new ListItem();
            itmWIL.Value = "WIL";
            itmWIL.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeWILShort");
            ListItem itmMAG = new ListItem();
            itmMAG.Value = "MAG";
            itmMAG.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeMAGShort");
            ListItem itmRES = new ListItem();
            itmRES.Value = "RES";
            itmRES.Name = LanguageManager.Instance.GetString("String_ExpenseAttribute") + ": " + LanguageManager.Instance.GetString("String_AttributeRESShort");
            lstFilter.Add(itmBOD);
            lstFilter.Add(itmAGI);
            lstFilter.Add(itmREA);
            lstFilter.Add(itmSTR);
            lstFilter.Add(itmCHA);
            lstFilter.Add(itmINT);
            lstFilter.Add(itmLOG);
            lstFilter.Add(itmWIL);
            lstFilter.Add(itmMAG);
            lstFilter.Add(itmRES);

            // Add Skill Groups to the filter.
            objXmlNodeList = objXmlDocument.SelectNodes("/chummer/categories/category[@type = \"active\"]");
            foreach (SkillGroup objGroup in _objCharacter.SkillGroups)
            {
                ListItem itmGroup = new ListItem();
                itmGroup.Value = "GROUP:" + objGroup.Name;
                itmGroup.Name = LanguageManager.Instance.GetString("String_ExpenseSkillGroup") + ": " + objGroup.DisplayName;
                lstFilter.Add(itmGroup);
            }

            cboSkillFilter.DataSource = lstFilter;
            cboSkillFilter.ValueMember = "Value";
            cboSkillFilter.DisplayMember = "Name";
            cboSkillFilter.SelectedIndex = 0;
            cboSkillFilter_SelectedIndexChanged(null, null);

            // If the option to re-group Skill Groups is enabled, run through the Skill Groups and see if they can be re-enabled.
            if (_objOptions.AllowSkillRegrouping)
            {
                foreach (SkillGroupControl objSkillGroupControl in panSkillGroups.Controls)
                {
                    bool blnBroken = false;
                    int intRating = -1;
                    if (objSkillGroupControl.Broken)
                    {
                        foreach (SkillControl objControl in panActiveSkills.Controls)
                        {
                            if (objControl.SkillGroup == objSkillGroupControl.GroupName)
                            {
                                if (objControl.SkillRating > 5)
                                    blnBroken = true;
                                if (intRating == -1)
                                    intRating = objControl.SkillRating;
                                if (objControl.SkillRating != intRating)
                                    blnBroken = true;
                                if (objControl.SkillSpec != string.Empty)
                                    blnBroken = true;
                            }
                        }
                        if (!blnBroken)
                        {
                            objSkillGroupControl.Broken = false;
                            objSkillGroupControl.GroupRating = intRating;
                        }
                    }
                }
            }

            if (_objCharacter.MetatypeCategory == "Cyberzombie")
                mnuSpecialCyberzombie.Visible = false;

            // Determine if the Critter should have access to the Possession menu item.
            bool blnAllowPossession = false;
            foreach (CritterPower objCritterPower in _objCharacter.CritterPowers)
            {
                if (objCritterPower.Name == "Inhabitation" || objCritterPower.Name == "Possession")
                {
                    blnAllowPossession = true;
                    break;
                }
            }
            mnuSpecialPossess.Visible = blnAllowPossession;

            // Set the visibility of the Armor Degradation buttons.
            cmdArmorDecrease.Visible = _objOptions.ArmorDegradation;
            cmdArmorIncrease.Visible = _objOptions.ArmorDegradation;

            _objFunctions.SortTree(treCyberware);
            _objFunctions.SortTree(treSpells);
            _objFunctions.SortTree(treComplexForms);
            _objFunctions.SortTree(treQualities);
            _objFunctions.SortTree(treCritterPowers);
            _objFunctions.SortTree(treMartialArts);
            UpdateMentorSpirits();
            UpdateInitiationGradeTree();
            PopulateCalendar();
            RefreshImprovements();

            UpdateCharacterInfo();

            _blnIsDirty = false;
            UpdateWindowTitle(false);
            RefreshPasteStatus();

            // Stupid hack to get the MDI icon to show up properly.
            this.Icon = this.Icon.Clone() as System.Drawing.Icon;
        }