示例#1
0
        private void objCareer_DiceRollerOpened(Object sender)
        {
            SkillControl objControl = (SkillControl)sender;

            if (GlobalOptions.Instance.SingleDiceRoller)
            {
                if (_frmRoller == null)
                {
                    frmDiceRoller frmRoller = new frmDiceRoller(this, objControl.SkillObject.CharacterObject.Qualities, objControl.SkillObject.TotalRating);
                    _frmRoller = frmRoller;
                    frmRoller.Show();
                }
                else
                {
                    _frmRoller.Dice      = objControl.SkillObject.TotalRating;
                    _frmRoller.Qualities = objControl.SkillObject.CharacterObject.Qualities;
                    _frmRoller.Focus();
                }
            }
            else
            {
                frmDiceRoller frmRoller = new frmDiceRoller(this, objControl.SkillObject.CharacterObject.Qualities, objControl.SkillObject.TotalRating);
                frmRoller.Show();
            }
        }
示例#2
0
        private void cmdAddExoticSkill_Click(object sender, EventArgs e)
        {
            frmSelectExoticSkill frmPickExoticSkill = new frmSelectExoticSkill();
            frmPickExoticSkill.ShowDialog(this);

            if (frmPickExoticSkill.DialogResult == DialogResult.Cancel)
                return;

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

            XmlNode nodSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + frmPickExoticSkill.SelectedExoticSkill + "\"]");

            int i = panActiveSkills.Controls.Count;
            Skill objSkill = new Skill(_objCharacter);
            objSkill.Attribute = nodSkill["attribute"].InnerText;
			objSkill.Specialization = frmPickExoticSkill.SelectedExoticSkillSpecialisation;
            if (_objCharacter.MaxSkillRating > 0)
                objSkill.RatingMaximum = _objCharacter.MaxSkillRating;

            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 = frmPickExoticSkill.SelectedExoticSkill;
            objSkillControl.BuyWithKarmaChanged += objActiveSkill_BuyWithKarmaChanged;
			objSkillControl.SkillSpec = frmPickExoticSkill.SelectedExoticSkillSpecialisation;
            objSkillControl.SkillCategory = nodSkill["category"].InnerText;
            if (nodSkill["default"].InnerText == "Yes")
                objSkill.Default = true;
            else
                objSkill.Default = false;

            objSkill.ExoticSkill = true;
            _objCharacter.Skills.Add(objSkill);

			// Populate the Skill's Specializations (if any).
			foreach (XmlNode objXmlSpecialization in nodSkill.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 = \"" + frmPickExoticSkill.SelectedExoticSkill + "s\" or useskill = \"" + frmPickExoticSkill.SelectedExoticSkill + "\"]");
			foreach (XmlNode objXmlWeapon in objXmlWeaponList)
			{
				if (objXmlWeapon["translate"] != null)
					objSkillControl.AddSpec(objXmlWeapon["translate"].InnerText);
				else
					objSkillControl.AddSpec(objXmlWeapon["name"].InnerText);
			}

			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 + panActiveSkills.AutoScrollPosition.Y);
            panActiveSkills.Controls.Add(objSkillControl);

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
示例#3
0
        private void cmdAddKnowledgeSkill_Click(object sender, EventArgs e)
        {
            int i = panKnowledgeSkills.Controls.Count;
            Skill objSkill = new Skill(_objCharacter);
            objSkill.Attribute = "LOG";
            objSkill.SkillCategory = "Academic";
            if (_objCharacter.MaxSkillRating > 0)
                objSkill.RatingMaximum = _objCharacter.MaxSkillRating;

            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.BuyWithKarmaChanged += objKnowledgeSkill_BuyWithKarmaChanged;
			objSkillControl.MergeClicked += knoSkill_MergeClick;
            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);

            _objCharacter.Skills.Add(objSkill);

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
示例#4
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();
        }
示例#5
0
		/// <summary>
		/// Refresh knowledge skills to the ones having an internal Skill
		/// </summary>
	    public void RefreshKnowledgeSkills()
		{
			List<SkillControl> knowledgeSkillControls = new List<SkillControl>();
			foreach (Control control in panKnowledgeSkills.Controls)
			{
				SkillControl sc = (SkillControl) control;
				if(sc != null) knowledgeSkillControls.Add(sc);
			}

			List<Skill> knowledgeSkills = new List<Skill>(
				from skill in _objCharacter.Skills
				where skill.KnowledgeSkill == true
				select skill);
			
			//O(N^2) but with N < 25, won't matter much
			//Find skills that don't exist in skillcontrols
			foreach (Skill skill in knowledgeSkills)
			{
				bool blnFound = false;
				foreach (SkillControl control in knowledgeSkillControls)
				{
					if (control.SkillObject == skill)
					{
						blnFound = true;
						control.SkillBase = skill.Base;
					}
				}

				if (!blnFound)
				{
					SkillControl nControl = new SkillControl(_objCharacter);
					nControl.SkillObject = skill;
					knowledgeSkillControls.Add(nControl);

					nControl.RatingChanged += objKnowledgeSkill_RatingChanged;
					nControl.SpecializationChanged += objSkill_SpecializationChanged;
					nControl.DeleteSkill += objKnowledgeSkill_DeleteSkill;
					nControl.BreakGroupClicked += objSkill_BreakGroupClicked;
					nControl.BuyWithKarmaChanged += objKnowledgeSkill_BuyWithKarmaChanged;
					nControl.MergeClicked += knoSkill_MergeClick;

					nControl.AllowDelete = skill.AllowDelete;
					nControl.SkillRatingMaximum = skill.RatingMaximum;
					nControl.KnowledgeSkill = skill.KnowledgeSkill;
					nControl.SkillBase = skill.Base;
					nControl.SkillKarma = skill.Karma;
					nControl.SkillRating = skill.Rating;
					nControl.SkillName = skill.Name;
					nControl.SkillSpec = skill.Specialization;
					nControl.LockKnowledge = skill.LockKnowledge;
					
					nControl.AutoScroll = false;

					panKnowledgeSkills.Controls.Add(nControl);
				}
			}

			//find skillcontrols that don't exist in skills
			foreach (SkillControl control in knowledgeSkillControls)
			{
				bool blnFound = false;
				foreach (Skill skill in knowledgeSkills)
				{
					if (control.SkillObject == skill)
					{
						blnFound = true;
						break;
					}
				}

				if (!blnFound)
				{
					control.RatingChanged -= objKnowledgeSkill_RatingChanged;
					control.SpecializationChanged -= objSkill_SpecializationChanged;
					control.DeleteSkill -= objKnowledgeSkill_DeleteSkill;
					control.BreakGroupClicked -= objSkill_BreakGroupClicked;
					control.BuyWithKarmaChanged -= objKnowledgeSkill_BuyWithKarmaChanged;
					control.MergeClicked -= knoSkill_MergeClick;
					panKnowledgeSkills.Controls.Remove(control);
				}
            }

			for (int i = 0; i < panKnowledgeSkills.Controls.Count; i++)
			{
				panKnowledgeSkills.Controls[i].Top = i*panKnowledgeSkills.Controls[0].Height;
            }
			

		}
示例#6
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");
	        
        }
示例#7
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;
        }
示例#8
0
        /// <summary>
        /// Update the Character information.
        /// </summary>
        public void UpdateCharacterInfo()
        {
            if (_blnLoading)
                return;

            if (!_blnSkipUpdate)
            {
                string strTip = "";
                _blnSkipUpdate = true;

                // Calculate the character's move.
                string strMovement = "";
                if (_objOptions.CyberlegMovement)
                {
                    int intLegs = 0;
                    int intAGI = 0;
                    foreach (Cyberware objCyber in _objCharacter.Cyberware)
                    {
                        if (objCyber.LimbSlot == "leg")
                        {
                            intLegs++;
                            if (intAGI > 0)
                                intAGI = Math.Min(intAGI, objCyber.TotalAgility);
                            else
                                intAGI = objCyber.TotalAgility;
                        }
                    }
                    if (intLegs == 2)
                        strMovement = String.Format("{0}/{1}", (intAGI * 2), (intAGI * 4));
                    else
                        strMovement = String.Format("{0}/{1}", (_objCharacter.AGI.TotalValue * 2), (_objCharacter.AGI.TotalValue * 4));
                }
                else
                    strMovement = String.Format("{0}/{1}", (_objCharacter.AGI.TotalValue * 2), (_objCharacter.AGI.TotalValue * 4));

                _objCharacter.Movement = strMovement;
                lblMovement.Text = _objCharacter.Movement;

                string strFormat;
                if (_objCharacter.Options.EssenceDecimals == 4)
                    strFormat = "{0:0.0000}";
                else
                    strFormat = "{0:0.00}";
                decimal decESS = _objCharacter.Essence;
                lblESSMax.Text = decESS.ToString();
                tssEssence.Text = string.Format(strFormat, decESS);

                lblCyberwareESS.Text = string.Format(strFormat, _objCharacter.CyberwareEssence);
                lblBiowareESS.Text = string.Format(strFormat, _objCharacter.BiowareEssence);
                lblEssenceHoleESS.Text = string.Format(strFormat, _objCharacter.EssenceHole);

                // Reduce a character's MAG and RES from Essence Loss.
                int intReduction = _objCharacter.ESS.MetatypeMaximum - Convert.ToInt32(Math.Floor(decESS));

                // Remove any Improvements from MAG and RES from Essence Loss.
                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.EssenceLoss, "Essence Loss");

                // Create the Essence Loss Improvements.
                if (intReduction > 0)
                {
                    _objImprovementManager.CreateImprovement("MAG", Improvement.ImprovementSource.EssenceLoss, "Essence Loss", Improvement.ImprovementType.Attribute, "", 0, intReduction * -1, 0, 1, 1, 0);
                    _objImprovementManager.CreateImprovement("RES", Improvement.ImprovementSource.EssenceLoss, "Essence Loss", Improvement.ImprovementType.Attribute, "", 0, intReduction * -1, 0, 1, 1, 0);

                    if (_objCharacter.AdeptEnabled)
                    {
                        CalculatePowerPoints();
                    }
                }

                int intEssenceLoss = 0;
                if (!_objOptions.ESSLossReducesMaximumOnly && !_objCharacter.OverrideSpecialAttributeEssenceLoss)
                    intEssenceLoss = _objCharacter.EssencePenalty;
                else
                {
                    if (_objCharacter.MAGEnabled)
                    {
                        if (_objCharacter.MAG.Value > _objCharacter.MAG.TotalMaximum)
                            intEssenceLoss = _objCharacter.MAG.Value - _objCharacter.MAG.TotalMaximum;
                    }
                    else if (_objCharacter.RESEnabled)
                    {
                        if (_objCharacter.RES.Value > _objCharacter.RES.TotalMaximum)
                            intEssenceLoss = _objCharacter.RES.Value - _objCharacter.RES.TotalMaximum;
                    }
                }

                // Update the Attribute information.
                lblBOD.Text = _objCharacter.BOD.Value.ToString();
                lblAGI.Text = _objCharacter.AGI.Value.ToString();
                lblREA.Text = _objCharacter.REA.Value.ToString();
                lblSTR.Text = _objCharacter.STR.Value.ToString();
                lblCHA.Text = _objCharacter.CHA.Value.ToString();
                lblINT.Text = _objCharacter.INT.Value.ToString();
                lblLOG.Text = _objCharacter.LOG.Value.ToString();
                lblWIL.Text = _objCharacter.WIL.Value.ToString();
                lblEDG.Text = _objCharacter.EDG.Value.ToString();
                if (_objCharacter.MAG.Value - intEssenceLoss < 0)
                    lblMAG.Text = "0";
                else
                    lblMAG.Text = (_objCharacter.MAG.Value - intEssenceLoss).ToString();
                if (_objCharacter.RES.Value - intEssenceLoss < 0)
                    lblRES.Text = "0";
                else
                    lblRES.Text = (_objCharacter.RES.Value - intEssenceLoss).ToString();

                // If the Attribute reaches 0, the character has burned out.
                if (_objCharacter.MAG.Value - intEssenceLoss < 1 && _objCharacter.MAGEnabled)
                {
                    _objCharacter.MAG.Value = 0;
                    _objCharacter.MAG.MetatypeMinimum = 0;
                    _objCharacter.MAG.MetatypeMaximum = 0;
                    _objCharacter.MAG.MetatypeAugmentedMaximum = 0;

                    if (_objCharacter.MAGEnabled)
                    {
                        // Move all MAG-linked Active Skills to Knowledge Skills.
                        List<Skill> lstNewSkills = new List<Skill>();
                        foreach (Skill objSkill in _objCharacter.Skills)
                        {
                            if (objSkill.Attribute == "MAG" && objSkill.Rating > 0)
                            {
                                int i = panKnowledgeSkills.Controls.Count;
                                Skill objKnowledge = new Skill(_objCharacter);

                                SkillControl objSkillControl = new SkillControl();
                                objKnowledge.Name = objSkill.Name;
                                objSkillControl.SkillObject = objKnowledge;

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

                                objSkillControl.KnowledgeSkill = true;
                                objSkillControl.AllowDelete = true;
                                if (objSkill.Rating > 13)
                                    objSkillControl.SkillRatingMaximum = objSkill.Rating;
                                else
                                    objSkillControl.SkillRatingMaximum = 12;
                                objSkillControl.SkillRating = objSkill.Rating;
                                objSkillControl.SkillCategory = "Professional";
                                // 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);

                                lstNewSkills.Add(objKnowledge);
                            }
                        }
                        foreach (Skill objSkill in lstNewSkills)
                            _objCharacter.Skills.Add(objSkill);
                    }

                    _objCharacter.MAGEnabled = false;
                    _objCharacter.MagicianEnabled = false;
                    _objCharacter.AdeptEnabled = false;
                }
                if (_objCharacter.RES.Value - intEssenceLoss < 1 && _objCharacter.RESEnabled)
                {
                    _objCharacter.RES.Value = 0;
                    _objCharacter.RES.MetatypeMinimum = 0;
                    _objCharacter.RES.MetatypeMinimum = 0;
                    _objCharacter.RES.MetatypeAugmentedMaximum = 0;

                    if (_objCharacter.RESEnabled)
                    {
                        // Move all RES-linked Active Skills to Knowledge Skills.
                        List<Skill> lstNewSkills = new List<Skill>();
                        foreach (Skill objSkill in _objCharacter.Skills)
                        {
                            if (objSkill.Attribute == "RES" && objSkill.Rating > 0)
                            {
                                int i = panKnowledgeSkills.Controls.Count;
                                Skill objKnowledge = new Skill(_objCharacter);

                                SkillControl objSkillControl = new SkillControl();
                                objKnowledge.Name = objSkill.Name;
                                objSkillControl.SkillObject = objKnowledge;

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

                                objSkillControl.KnowledgeSkill = true;
                                objSkillControl.AllowDelete = true;
                                if (objSkill.Rating > 13)
                                    objSkillControl.SkillRatingMaximum = objSkill.Rating;
                                else
                                    objSkillControl.SkillRatingMaximum = 12;
                                objSkillControl.SkillRating = objSkill.Rating;
                                objSkillControl.SkillCategory = "Professional";
                                // 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);

                                lstNewSkills.Add(objKnowledge);
                            }
                        }
                        foreach (Skill objSkill in lstNewSkills)
                            _objCharacter.Skills.Add(objSkill);
                    }

                    _objCharacter.RESEnabled = false;
                    _objCharacter.TechnomancerEnabled = false;
                }

                if (_objCharacter.MAGAdept > _objCharacter.MAG.TotalValue)
                    _objCharacter.MAGAdept = _objCharacter.MAG.TotalValue;

                // If the character is an A.I., set the Edge MetatypeMaximum to their Rating.
                if (_objCharacter.Metatype.EndsWith("A.I.") || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients")
                    _objCharacter.EDG.MetatypeMaximum = _objCharacter.Rating;

                // If the character is Cyberzombie, adjust their Attributes based on their Essence.
                if (_objCharacter.MetatypeCategory == "Cyberzombie")
                {
                    int intESSModifier = _objCharacter.EssencePenalty - Convert.ToInt32(_objCharacter.EssenceMaximum);
                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Attributes");
                    _objImprovementManager.CreateImprovement("BOD", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Attributes", Improvement.ImprovementType.Attribute, "", 0, 1, 0, intESSModifier);
                    _objImprovementManager.CreateImprovement("AGI", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Attributes", Improvement.ImprovementType.Attribute, "", 0, 1, 0, intESSModifier);
                    _objImprovementManager.CreateImprovement("REA", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Attributes", Improvement.ImprovementType.Attribute, "", 0, 1, 0, intESSModifier);
                    _objImprovementManager.CreateImprovement("STR", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Attributes", Improvement.ImprovementType.Attribute, "", 0, 1, 0, intESSModifier);
                    _objImprovementManager.CreateImprovement("CHA", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Attributes", Improvement.ImprovementType.Attribute, "", 0, 1, 0, intESSModifier);
                    _objImprovementManager.CreateImprovement("INT", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Attributes", Improvement.ImprovementType.Attribute, "", 0, 1, 0, intESSModifier);
                    _objImprovementManager.CreateImprovement("LOG", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Attributes", Improvement.ImprovementType.Attribute, "", 0, 1, 0, intESSModifier);
                    _objImprovementManager.CreateImprovement("WIL", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Attributes", Improvement.ImprovementType.Attribute, "", 0, 1, 0, intESSModifier);
                }

                // Update the Attribute Improvement Cost ToolTips.
                string strTooltip = "";
                if (!_objOptions.AlternateMetatypeAttributeKarma)
                {
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.BOD.Value + _objCharacter.BOD.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.BOD.Value + _objCharacter.BOD.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveBOD, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.AGI.Value + _objCharacter.AGI.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.AGI.Value + _objCharacter.AGI.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveAGI, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.REA.Value + _objCharacter.REA.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.REA.Value + _objCharacter.REA.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveREA, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.STR.Value + _objCharacter.STR.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.STR.Value + _objCharacter.STR.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveSTR, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.CHA.Value + _objCharacter.CHA.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.CHA.Value + _objCharacter.CHA.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveCHA, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.INT.Value + _objCharacter.INT.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.INT.Value + _objCharacter.INT.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveINT, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.LOG.Value + _objCharacter.LOG.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.LOG.Value + _objCharacter.LOG.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveLOG, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.WIL.Value + _objCharacter.WIL.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.WIL.Value + _objCharacter.WIL.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveWIL, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.EDG.Value + _objCharacter.EDG.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.EDG.Value + _objCharacter.EDG.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveEDG, strTooltip);
                    if (!_objOptions.SpecialKarmaCostBasedOnShownValue)
                    {
                        strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.MAG.Value + _objCharacter.MAG.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.MAG.Value + _objCharacter.MAG.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                        tipTooltip.SetToolTip(cmdImproveMAG, strTooltip);
                        strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.RES.Value + _objCharacter.RES.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.RES.Value + _objCharacter.RES.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                        tipTooltip.SetToolTip(cmdImproveRES, strTooltip);
                    }
                    else
                    {
                        strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.MAG.Value - _objCharacter.EssencePenalty + 1).ToString()).Replace("{1}", ((_objCharacter.MAG.Value + _objCharacter.EssencePenalty + 1) * _objOptions.KarmaAttribute).ToString());
                        tipTooltip.SetToolTip(cmdImproveMAG, strTooltip);
                        strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.RES.Value - _objCharacter.EssencePenalty + 1).ToString()).Replace("{1}", ((_objCharacter.RES.Value + _objCharacter.EssencePenalty + 1) * _objOptions.KarmaAttribute).ToString());
                        tipTooltip.SetToolTip(cmdImproveRES, strTooltip);
                    }
                }
                else
                {
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.BOD.Value + _objCharacter.BOD.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.BOD.Value + _objCharacter.BOD.AttributeValueModifiers - _objCharacter.BOD.MetatypeMinimum + 2) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveBOD, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.AGI.Value + _objCharacter.AGI.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.AGI.Value + _objCharacter.AGI.AttributeValueModifiers - _objCharacter.AGI.MetatypeMinimum + 2) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveAGI, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.REA.Value + _objCharacter.REA.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.REA.Value + _objCharacter.REA.AttributeValueModifiers - _objCharacter.REA.MetatypeMinimum + 2) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveREA, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.STR.Value + _objCharacter.STR.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.STR.Value + _objCharacter.STR.AttributeValueModifiers - _objCharacter.STR.MetatypeMinimum + 2) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveSTR, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.CHA.Value + _objCharacter.CHA.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.CHA.Value + _objCharacter.CHA.AttributeValueModifiers - _objCharacter.CHA.MetatypeMinimum + 2) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveCHA, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.INT.Value + _objCharacter.INT.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.INT.Value + _objCharacter.INT.AttributeValueModifiers - _objCharacter.INT.MetatypeMinimum + 2) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveINT, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.LOG.Value + _objCharacter.LOG.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.LOG.Value + _objCharacter.LOG.AttributeValueModifiers - _objCharacter.LOG.MetatypeMinimum + 2) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveLOG, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.WIL.Value + _objCharacter.WIL.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.WIL.Value + _objCharacter.WIL.AttributeValueModifiers - _objCharacter.WIL.MetatypeMinimum + 2) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveWIL, strTooltip);
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.EDG.Value + _objCharacter.EDG.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.EDG.Value + _objCharacter.EDG.AttributeValueModifiers - _objCharacter.EDG.MetatypeMinimum + 2) * _objOptions.KarmaAttribute).ToString());
                    tipTooltip.SetToolTip(cmdImproveEDG, strTooltip);
                    if (!_objOptions.SpecialKarmaCostBasedOnShownValue)
                    {
                        strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.MAG.Value + _objCharacter.MAG.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.MAG.Value + _objCharacter.MAG.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                        tipTooltip.SetToolTip(cmdImproveMAG, strTooltip);
                        strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.RES.Value + _objCharacter.RES.AttributeValueModifiers + 1).ToString()).Replace("{1}", ((_objCharacter.RES.Value + _objCharacter.RES.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute).ToString());
                        tipTooltip.SetToolTip(cmdImproveRES, strTooltip);
                    }
                    else
                    {
                        strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.MAG.Value - _objCharacter.EssencePenalty + 1).ToString()).Replace("{1}", ((_objCharacter.MAG.Value - _objCharacter.EssencePenalty + 1) * _objOptions.KarmaAttribute).ToString());
                        tipTooltip.SetToolTip(cmdImproveMAG, strTooltip);
                        strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", (_objCharacter.RES.Value - _objCharacter.EssencePenalty + 1).ToString()).Replace("{1}", ((_objCharacter.RES.Value - _objCharacter.EssencePenalty + 1) * _objOptions.KarmaAttribute).ToString());
                        tipTooltip.SetToolTip(cmdImproveRES, strTooltip);
                    }
                }

                // Disable any Attribute Karma buttons that have reached their Total Metatype Maximum.
                cmdImproveBOD.Enabled = !(_objCharacter.BOD.Value == _objCharacter.BOD.TotalMaximum);
                cmdImproveAGI.Enabled = !(_objCharacter.AGI.Value == _objCharacter.AGI.TotalMaximum);
                cmdImproveREA.Enabled = !(_objCharacter.REA.Value == _objCharacter.REA.TotalMaximum);
                cmdImproveSTR.Enabled = !(_objCharacter.STR.Value == _objCharacter.STR.TotalMaximum);
                cmdImproveCHA.Enabled = !(_objCharacter.CHA.Value == _objCharacter.CHA.TotalMaximum);
                cmdImproveINT.Enabled = !(_objCharacter.INT.Value == _objCharacter.INT.TotalMaximum);
                cmdImproveLOG.Enabled = !(_objCharacter.LOG.Value == _objCharacter.LOG.TotalMaximum);
                cmdImproveWIL.Enabled = !(_objCharacter.WIL.Value == _objCharacter.WIL.TotalMaximum);
                cmdImproveEDG.Enabled = !(_objCharacter.EDG.Value == _objCharacter.EDG.TotalMaximum);

                // Disable the Magic or Resonance Karma buttons if they have reached their current limits.
                if (_objCharacter.MAGEnabled)
                    cmdImproveMAG.Enabled = !(_objCharacter.MAG.Value - intEssenceLoss >= _objCharacter.MAG.TotalMaximum);
                else
                    cmdImproveMAG.Enabled = false;

                if (_objCharacter.RESEnabled)
                    cmdImproveRES.Enabled = !(_objCharacter.RES.Value - intEssenceLoss >= _objCharacter.RES.TotalMaximum);
                else
                    cmdImproveRES.Enabled = false;

                // Condition Monitor.
                double dblBOD = _objCharacter.BOD.TotalValue;
                double dblWIL = _objCharacter.WIL.TotalValue;
                int intCMPhysical = _objCharacter.PhysicalCM;
                int intCMStun = _objCharacter.StunCM;
                int intCMOverflow = _objCharacter.CMOverflow;

                // Update the Condition Monitor labels.
                lblCMPhysical.Text = intCMPhysical.ToString();
                lblCMStun.Text = intCMStun.ToString();
                string strCM = "8 + (BOD/2)(" + ((int)Math.Ceiling(dblBOD / 2)).ToString() + ")";
                if (_objImprovementManager.ValueOf(Improvement.ImprovementType.PhysicalCM) != 0)
                    strCM += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + _objImprovementManager.ValueOf(Improvement.ImprovementType.PhysicalCM).ToString() + ")";
                tipTooltip.SetToolTip(lblCMPhysical, strCM);
                strCM = "8 + (WIL/2)(" + ((int)Math.Ceiling(dblWIL / 2)).ToString() + ")";
                if (_objImprovementManager.ValueOf(Improvement.ImprovementType.StunCM) != 0)
                    strCM += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + _objImprovementManager.ValueOf(Improvement.ImprovementType.StunCM).ToString() + ")";
                tipTooltip.SetToolTip(lblCMStun, strCM);

                int intCMThreshold = _objCharacter.CMThreshold;
                int intPhysicalCMPenalty = 0;
                int intStunCMPenalty = 0;
                int intCMPenalty = 0;

                // Hide any unused Physical CM boxes.
                foreach (CheckBox objPhysicalCM in panPhysicalCM.Controls.OfType<CheckBox>())
                {
                    if (Convert.ToInt32(objPhysicalCM.Tag.ToString()) <= intCMPhysical + intCMOverflow)
                    {
                        if (Convert.ToInt32(objPhysicalCM.Tag.ToString()) <= _objCharacter.PhysicalCMFilled)
                            objPhysicalCM.Checked = true;

                        objPhysicalCM.Visible = true;

                        if (Convert.ToInt32(objPhysicalCM.Tag.ToString()) <= intCMPhysical)
                        {
                            // If this is within the Physical CM limits, act normally.
                            objPhysicalCM.BackColor = SystemColors.Control;
                            objPhysicalCM.UseVisualStyleBackColor = true;
                            if ((Convert.ToInt32(objPhysicalCM.Tag.ToString()) - _objImprovementManager.ValueOf(Improvement.ImprovementType.CMThresholdOffset)) % intCMThreshold == 0 && Convert.ToInt32(objPhysicalCM.Tag.ToString()) > _objImprovementManager.ValueOf(Improvement.ImprovementType.CMThresholdOffset))
                            {
                                int intModifiers = ((Convert.ToInt32(objPhysicalCM.Tag.ToString()) - _objImprovementManager.ValueOf(Improvement.ImprovementType.CMThresholdOffset)) / intCMThreshold) * -1;
                                objPhysicalCM.Text = intModifiers.ToString();
                                if (objPhysicalCM.Checked)
                                {
                                    if (intModifiers < intPhysicalCMPenalty)
                                        intPhysicalCMPenalty = intModifiers;
                                }
                            }
                            else
                                objPhysicalCM.Text = "";
                        }
                        else if (Convert.ToInt32(objPhysicalCM.Tag.ToString()) > intCMPhysical)
                        {
                            objPhysicalCM.BackColor = SystemColors.ControlDark;
                            if (Convert.ToInt32(objPhysicalCM.Tag.ToString()) == intCMPhysical + intCMOverflow)
                                objPhysicalCM.Text = "D";
                            else
                                objPhysicalCM.Text = "";
                        }
                    }
                    else
                    {
                        objPhysicalCM.Visible = false;
                        objPhysicalCM.Text = "";
                    }
                }

                // Hide any unused Stun CM boxes.
                foreach (CheckBox objStunCM in panStunCM.Controls.OfType<CheckBox>())
                {
                    if (Convert.ToInt32(objStunCM.Tag.ToString()) <= intCMStun)
                    {
                        if (Convert.ToInt32(objStunCM.Tag.ToString()) <= _objCharacter.StunCMFilled)
                            objStunCM.Checked = true;

                        objStunCM.Visible = true;
                        if ((Convert.ToInt32(objStunCM.Tag.ToString()) - _objImprovementManager.ValueOf(Improvement.ImprovementType.CMThresholdOffset)) % intCMThreshold == 0 && Convert.ToInt32(objStunCM.Tag.ToString()) > _objImprovementManager.ValueOf(Improvement.ImprovementType.CMThresholdOffset))
                        {
                            int intModifiers = ((Convert.ToInt32(objStunCM.Tag.ToString()) - _objImprovementManager.ValueOf(Improvement.ImprovementType.CMThresholdOffset)) / intCMThreshold) * -1;
                            objStunCM.Text = intModifiers.ToString();
                            if (objStunCM.Checked)
                            {
                                if (intModifiers < intStunCMPenalty)
                                    intStunCMPenalty = intModifiers;
                            }
                        }
                        else
                            objStunCM.Text = "";
                    }
                    else
                    {
                        objStunCM.Visible = false;
                        objStunCM.Text = "";
                    }
                }

                // Reduce the CM Penalties to 0 if the character has Improvements to ignore them.
                if (_objCharacter.HasImprovement(Improvement.ImprovementType.IgnoreCMPenaltyStun, true))
                    intStunCMPenalty = 0;
                if (_objCharacter.HasImprovement(Improvement.ImprovementType.IgnoreCMPenaltyPhysical, true))
                    intPhysicalCMPenalty = 0;

                intCMPenalty = intPhysicalCMPenalty + intStunCMPenalty;
                lblCMPenalty.Text = intCMPenalty.ToString();

                // Discard any old Condition Monitor penalties.
                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ConditionMonitor, "");

                // Create the new Condition Monitor penalties.
                if (intCMPenalty < 0)
                    _objImprovementManager.CreateImprovement("", Improvement.ImprovementSource.ConditionMonitor, "", Improvement.ImprovementType.ConditionMonitor, "", intCMPenalty);

                // Update the character's Skill information.
                foreach (SkillControl objSkillControl in panActiveSkills.Controls)
                {
                    objSkillControl.SkillRatingMaximum = objSkillControl.SkillObject.RatingMaximum;
                    objSkillControl.RefreshControl();
                }

                // Update the character's Knowledge Skill information.
                foreach (SkillControl objSkillControl in panKnowledgeSkills.Controls)
                {
                    objSkillControl.SkillRatingMaximum = objSkillControl.SkillObject.RatingMaximum;
                    objSkillControl.RefreshControl();
                }

                // Armor Ratings.
                lblArmor.Text = _objCharacter.TotalArmorRating.ToString();
                lblCMArmor.Text = lblArmor.Text;
                string strArmorToolTip = "";
                strArmorToolTip = LanguageManager.Instance.GetString("Tip_Armor") + " (" + _objCharacter.ArmorRating.ToString() + ")";
                if (_objCharacter.ArmorRating != _objCharacter.TotalArmorRating)
                    strArmorToolTip += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + (_objCharacter.TotalArmorRating - _objCharacter.ArmorRating).ToString() + ")";
                tipTooltip.SetToolTip(lblArmor, strArmorToolTip);

                // Remove any Improvements from Armor Encumbrance.
                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorEncumbrance, "Armor Encumbrance");
                // Create the Armor Encumbrance Improvements.
                if (_objCharacter.ArmorEncumbrance < 0)
                {
                    _objImprovementManager.CreateImprovement("AGI", Improvement.ImprovementSource.ArmorEncumbrance, "Armor Encumbrance", Improvement.ImprovementType.Attribute, "", 0, 1, 0, 0, _objCharacter.ArmorEncumbrance);
                    _objImprovementManager.CreateImprovement("REA", Improvement.ImprovementSource.ArmorEncumbrance, "Armor Encumbrance", Improvement.ImprovementType.Attribute, "", 0, 1, 0, 0, _objCharacter.ArmorEncumbrance);
                }

                // Update the Attribute information.
                // Attribute: Body.
                lblBODMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.BOD.TotalMinimum, _objCharacter.BOD.TotalMaximum, _objCharacter.BOD.TotalAugmentedMaximum);
                if (_objCharacter.BOD.HasModifiers)
                {
                    lblBODAug.Text = string.Format("({0})", _objCharacter.BOD.TotalValue);
                    tipTooltip.SetToolTip(lblBODAug, _objCharacter.BOD.ToolTip());
                }
                else
                {
                    lblBODAug.Text = "";
                    tipTooltip.SetToolTip(lblBODAug, "");
                }

                // Attribute: Agility.
                lblAGIMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.AGI.TotalMinimum, _objCharacter.AGI.TotalMaximum, _objCharacter.AGI.TotalAugmentedMaximum);
                if (_objCharacter.AGI.HasModifiers)
                {
                    lblAGIAug.Text = string.Format("({0})", _objCharacter.AGI.TotalValue);
                    tipTooltip.SetToolTip(lblAGIAug, _objCharacter.AGI.ToolTip());
                }
                else
                {
                    lblAGIAug.Text = "";
                    tipTooltip.SetToolTip(lblAGIAug, "");
                }

                // Attribute: Reaction.
                lblREAMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.REA.TotalMinimum, _objCharacter.REA.TotalMaximum, _objCharacter.REA.TotalAugmentedMaximum);
                if (_objCharacter.REA.HasModifiers)
                {
                    lblREAAug.Text = string.Format("({0})", _objCharacter.REA.TotalValue);
                    tipTooltip.SetToolTip(lblREAAug, _objCharacter.REA.ToolTip());
                }
                else
                {
                    lblREAAug.Text = "";
                    tipTooltip.SetToolTip(lblREAAug, "");
                }

                // Attribute: Strength.
                lblSTRMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.STR.TotalMinimum, _objCharacter.STR.TotalMaximum, _objCharacter.STR.TotalAugmentedMaximum);
                if (_objCharacter.STR.HasModifiers)
                {
                    lblSTRAug.Text = string.Format("({0})", _objCharacter.STR.TotalValue);
                    tipTooltip.SetToolTip(lblSTRAug, _objCharacter.STR.ToolTip());
                }
                else
                {
                    lblSTRAug.Text = "";
                    tipTooltip.SetToolTip(lblSTRAug, "");
                }

                // Attribute: Charisma.
                lblCHAMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.CHA.TotalMinimum, _objCharacter.CHA.TotalMaximum, _objCharacter.CHA.TotalAugmentedMaximum);
                if (_objCharacter.CHA.HasModifiers)
                {
                    lblCHAAug.Text = string.Format("({0})", _objCharacter.CHA.TotalValue);
                    tipTooltip.SetToolTip(lblCHAAug, _objCharacter.CHA.ToolTip());
                }
                else
                {
                    lblCHAAug.Text = "";
                    tipTooltip.SetToolTip(lblCHAAug, "");
                }

                // Attribute: Intuition.
                lblINTMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.INT.TotalMinimum, _objCharacter.INT.TotalMaximum, _objCharacter.INT.TotalAugmentedMaximum);
                if (_objCharacter.INT.HasModifiers)
                {
                    lblINTAug.Text = string.Format("({0})", _objCharacter.INT.TotalValue);
                    tipTooltip.SetToolTip(lblINTAug, _objCharacter.INT.ToolTip());
                }
                else
                {
                    lblINTAug.Text = "";
                    tipTooltip.SetToolTip(lblINTAug, "");
                }

                // Attribute: Logic.
                lblLOGMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.LOG.TotalMinimum, _objCharacter.LOG.TotalMaximum, _objCharacter.LOG.TotalAugmentedMaximum);
                if (_objCharacter.LOG.HasModifiers)
                {
                    lblLOGAug.Text = string.Format("({0})", _objCharacter.LOG.TotalValue);
                    tipTooltip.SetToolTip(lblLOGAug, _objCharacter.LOG.ToolTip());
                }
                else
                {
                    lblLOGAug.Text = "";
                    tipTooltip.SetToolTip(lblLOGAug, "");
                }

                // Attribute: Willpower.
                lblWILMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.WIL.TotalMinimum, _objCharacter.WIL.TotalMaximum, _objCharacter.WIL.TotalAugmentedMaximum);
                if (_objCharacter.WIL.HasModifiers)
                {
                    lblWILAug.Text = string.Format("({0})", _objCharacter.WIL.TotalValue);
                    tipTooltip.SetToolTip(lblWILAug, _objCharacter.WIL.ToolTip());
                }
                else
                {
                    lblWILAug.Text = "";
                    tipTooltip.SetToolTip(lblWILAug, "");
                }

                // Attribute: Edge.
                lblEDGMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.EDG.TotalMinimum, _objCharacter.EDG.TotalMaximum, _objCharacter.EDG.TotalAugmentedMaximum);
                if (_objCharacter.EDG.HasModifiers)
                {
                    lblEDGAug.Text = string.Format("({0})", _objCharacter.EDG.TotalValue);
                    tipTooltip.SetToolTip(lblEDGAug, _objCharacter.EDG.ToolTip());
                }
                else
                {
                    lblEDGAug.Text = "";
                    tipTooltip.SetToolTip(lblEDGAug, "");
                }

                // Attribute: Magic.
                lblMAGMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.MAG.TotalMinimum, _objCharacter.MAG.TotalMaximum, _objCharacter.MAG.TotalAugmentedMaximum);
                if (_objCharacter.MAG.HasModifiers)
                {
                    lblMAGAug.Text = string.Format("({0})", _objCharacter.MAG.TotalValue);
                    tipTooltip.SetToolTip(lblMAGAug, _objCharacter.MAG.ToolTip());
                }
                else
                {
                    lblMAGAug.Text = "";
                    tipTooltip.SetToolTip(lblMAGAug, "");
                }

                // Attribute: Resonance.
                lblRESMetatype.Text = string.Format("{0} / {1} ({2})", _objCharacter.RES.TotalMinimum, _objCharacter.RES.TotalMaximum, _objCharacter.RES.TotalAugmentedMaximum);
                if (_objCharacter.RES.HasModifiers)
                {
                    lblRESAug.Text = string.Format("({0})", _objCharacter.RES.TotalValue);
                    tipTooltip.SetToolTip(lblRESAug, _objCharacter.RES.ToolTip());
                }
                else
                {
                    lblRESAug.Text = "";
                    tipTooltip.SetToolTip(lblRESAug, "");
                }

                // Update the MAG pseudo-Attributes if applicable.
                int intCharacterMAG = _objCharacter.MAG.TotalValue;
                if (_objCharacter.AdeptEnabled && _objCharacter.MagicianEnabled)
                {
                    lblMysticAdeptMAGAdept.Text = _objCharacter.MAGAdept.ToString();
                    intCharacterMAG = _objCharacter.MAGMagician;
                }

                // Update the maximum Force for all Spirits.
                foreach (SpiritControl objSpiritControl in panSpirits.Controls)
                {
                    if (_objOptions.SpiritForceBasedOnTotalMAG)
                        objSpiritControl.ForceMaximum = _objCharacter.MAG.TotalValue * 2;
                    else
                    {
                        int intLocalMAG = intCharacterMAG;
                        if (intLocalMAG == 0)
                            intLocalMAG = 1;

                        objSpiritControl.ForceMaximum = intLocalMAG * 2;
                    }
                    objSpiritControl.RebuildSpiritList(_objCharacter.MagicTradition);
                }

                // Update Adept Powers.
                int intMAG = _objCharacter.MAG.TotalValue;
                foreach (PowerControl objPowerControl in panPowers.Controls)
                {
                    // Maximum Power Level for Mystic Adepts is based on their total MAG.
                    objPowerControl.RefreshMaximum(_objCharacter.MAG.TotalValue);
                    objPowerControl.RefreshTooltip();
                }

                // Update the Drain Attribute Value.
                if (_objCharacter.MAGEnabled && lblDrainAttributes.Text != "")
                {
                    try
                    {
                        XmlDocument objXmlDocument = new XmlDocument();
                        XPathNavigator nav = objXmlDocument.CreateNavigator();
                        string strDrain = lblDrainAttributes.Text.Replace(LanguageManager.Instance.GetString("String_AttributeBODShort"), _objCharacter.BOD.TotalValue.ToString());
                        strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeAGIShort"), _objCharacter.AGI.TotalValue.ToString());
                        strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeREAShort"), _objCharacter.REA.TotalValue.ToString());
                        strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeSTRShort"), _objCharacter.STR.TotalValue.ToString());
                        strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeCHAShort"), _objCharacter.CHA.TotalValue.ToString());
                        strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeINTShort"), _objCharacter.INT.TotalValue.ToString());
                        strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeLOGShort"), _objCharacter.LOG.TotalValue.ToString());
                        strDrain = strDrain.Replace(LanguageManager.Instance.GetString("String_AttributeWILShort"), _objCharacter.WIL.TotalValue.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
                    {
                    }
                }

                // Update the maximum Force for all Sprites.
                foreach (SpiritControl objSpiritControl in panSprites.Controls)
                {
                    objSpiritControl.ForceMaximum = _objCharacter.RES.TotalValue * 2;
                    objSpiritControl.RebuildSpiritList(_objCharacter.TechnomancerStream);
                }

                // Update the Fading Attribute Value.
                if (_objCharacter.RESEnabled && lblFadingAttributes.Text != "")
                {
                    try
                    {
                        XmlDocument objXmlDocument = new XmlDocument();
                        XPathNavigator nav = objXmlDocument.CreateNavigator();
                        string strFading = lblFadingAttributes.Text.Replace(LanguageManager.Instance.GetString("String_AttributeBODShort"), _objCharacter.BOD.TotalValue.ToString());
                        strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeAGIShort"), _objCharacter.AGI.TotalValue.ToString());
                        strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeREAShort"), _objCharacter.REA.TotalValue.ToString());
                        strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeSTRShort"), _objCharacter.STR.TotalValue.ToString());
                        strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeCHAShort"), _objCharacter.CHA.TotalValue.ToString());
                        strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeINTShort"), _objCharacter.INT.TotalValue.ToString());
                        strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeLOGShort"), _objCharacter.LOG.TotalValue.ToString());
                        strFading = strFading.Replace(LanguageManager.Instance.GetString("String_AttributeWILShort"), _objCharacter.WIL.TotalValue.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();

                        strTip = lblFadingAttributes.Text.Replace(LanguageManager.Instance.GetString("String_AttributeBODShort"), LanguageManager.Instance.GetString("String_AttributeBODShort") + " (" + _objCharacter.BOD.TotalValue.ToString() + ")");
                        strTip = strTip.Replace(LanguageManager.Instance.GetString("String_AttributeAGIShort"), LanguageManager.Instance.GetString("String_AttributeAGIShort") + " (" + _objCharacter.AGI.TotalValue.ToString() + ")");
                        strTip = strTip.Replace(LanguageManager.Instance.GetString("String_AttributeREAShort"), LanguageManager.Instance.GetString("String_AttributeREAShort") + " (" + _objCharacter.REA.TotalValue.ToString() + ")");
                        strTip = strTip.Replace(LanguageManager.Instance.GetString("String_AttributeSTRShort"), LanguageManager.Instance.GetString("String_AttributeSTRShort") + " (" + _objCharacter.STR.TotalValue.ToString() + ")");
                        strTip = strTip.Replace(LanguageManager.Instance.GetString("String_AttributeCHAShort"), LanguageManager.Instance.GetString("String_AttributeCHAShort") + " (" + _objCharacter.CHA.TotalValue.ToString() + ")");
                        strTip = strTip.Replace(LanguageManager.Instance.GetString("String_AttributeINTShort"), LanguageManager.Instance.GetString("String_AttributeINTShort") + " (" + _objCharacter.INT.TotalValue.ToString() + ")");
                        strTip = strTip.Replace(LanguageManager.Instance.GetString("String_AttributeLOGShort"), LanguageManager.Instance.GetString("String_AttributeLOGShort") + " (" + _objCharacter.LOG.TotalValue.ToString() + ")");
                        strTip = strTip.Replace(LanguageManager.Instance.GetString("String_AttributeWILShort"), LanguageManager.Instance.GetString("String_AttributeWILShort") + " (" + _objCharacter.WIL.TotalValue.ToString() + ")");
                        strTip = strTip.Replace(LanguageManager.Instance.GetString("String_AttributeRESShort"), LanguageManager.Instance.GetString("String_AttributeRESShort") + " (" + _objCharacter.RES.TotalValue.ToString() + ")");
                        tipTooltip.SetToolTip(lblFadingAttributesValue, strTip);
                    }
                    catch
                    {
                    }
                }

                // Update Living Persona values.
                if (_objCharacter.RESEnabled)
                {
                    string strPersonaTip = "";
                    int intFirewall = _objCharacter.WIL.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.LivingPersonaFirewall);
                    int intResponse = _objCharacter.INT.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.LivingPersonaResponse);
                    int intSignal = Convert.ToInt32(Math.Ceiling((Convert.ToDecimal(_objCharacter.RES.TotalValue, GlobalOptions.Instance.CultureInfo) / 2))) + _objImprovementManager.ValueOf(Improvement.ImprovementType.LivingPersonaSignal);
                    int intSystem = _objCharacter.LOG.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.LivingPersonaSystem);
                    int intBiofeedback = _objCharacter.CHA.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.LivingPersonaBiofeedback);

                    // If this is a Technocritter, their Matrix Attributes always equal their RES.
                    if (_objCharacter.MetatypeCategory == "Technocritters")
                    {
                        intFirewall = _objCharacter.RES.TotalValue;
                        intSystem = _objCharacter.RES.TotalValue;
                        intResponse = _objCharacter.RES.TotalValue;
                        intSignal = _objCharacter.RES.TotalValue;
                        intBiofeedback = _objCharacter.RES.TotalValue;
                    }

                    // Make sure none of the Attributes exceed the Technomancer's RES.
                    intFirewall = Math.Min(intFirewall, _objCharacter.RES.TotalValue);
                    intResponse = Math.Min(intResponse, _objCharacter.RES.TotalValue);
                    intSignal = Math.Min(intSignal, _objCharacter.RES.TotalValue);
                    intSystem = Math.Min(intSystem, _objCharacter.RES.TotalValue);

                    lblLivingPersonaDeviceRating.Text = _objCharacter.RES.TotalValue.ToString();
                    strPersonaTip = "RES (" + _objCharacter.RES.TotalValue.ToString() + ")";
                    tipTooltip.SetToolTip(lblLivingPersonaDeviceRating, strPersonaTip);

                    lblLivingPersonaAttack.Text = _objCharacter.CHA.TotalValue.ToString();
                    strPersonaTip = "CHA (" + _objCharacter.CHA.TotalValue.ToString() + ")";
                    tipTooltip.SetToolTip(lblLivingPersonaAttack, strPersonaTip);

                    lblLivingPersonaSleaze.Text = _objCharacter.INT.TotalValue.ToString();
                    strPersonaTip = "INT (" + _objCharacter.INT.TotalValue.ToString() + ")";
                    tipTooltip.SetToolTip(lblLivingPersonaSleaze, strPersonaTip);

                    lblLivingPersonaDataProcessing.Text = _objCharacter.LOG.TotalValue.ToString();
                    strPersonaTip = "LOG (" + _objCharacter.LOG.TotalValue.ToString() + ")";
                    tipTooltip.SetToolTip(lblLivingPersonaDataProcessing, strPersonaTip);

                    lblLivingPersonaFirewall.Text = _objCharacter.WIL.TotalValue.ToString();
                    strPersonaTip = "WIL (" + _objCharacter.WIL.TotalValue.ToString() + ")";
                    tipTooltip.SetToolTip(lblLivingPersonaFirewall, strPersonaTip);
                }

                // Skill Limits
                lblPhysical.Text = _objCharacter.LimitPhysical.ToString();
                string strPhysical = "(STR [" + _objCharacter.STR.TotalValue.ToString() + "] * 2) + BOD [" + _objCharacter.BOD.TotalValue.ToString() + "] + REA [" + _objCharacter.REA.TotalValue.ToString() + "] / 3";
                tipTooltip.SetToolTip(lblPhysical, strPhysical);

                lblMental.Text = _objCharacter.LimitMental.ToString();
                string strMental = "(LOG [" + _objCharacter.LOG.TotalValue.ToString() + "] * 2) + INT [" + _objCharacter.INT.TotalValue.ToString() + "] + WIL [" + _objCharacter.WIL.TotalValue.ToString() + "] / 3";
                tipTooltip.SetToolTip(lblMental, strMental);

                lblSocial.Text = _objCharacter.LimitSocial.ToString();
                string strSocial = "(CHA [" + _objCharacter.CHA.TotalValue.ToString() + "] * 2) + WIL [" + _objCharacter.WIL.TotalValue.ToString() + "] + ESS [" + _objCharacter.Essence.ToString() + "] / 3";
                tipTooltip.SetToolTip(lblSocial, strSocial);

                lblAstral.Text = _objCharacter.LimitAstral.ToString();

                // Initiative.
                lblINI.Text = _objCharacter.Initiative;
                string strInit = "REA (" + _objCharacter.REA.Value.ToString() + ") + INT (" + _objCharacter.INT.Value.ToString() + ")";
                if (_objCharacter.INI.AttributeModifiers > 0 || _objImprovementManager.ValueOf(Improvement.ImprovementType.Initiative) > 0 || _objCharacter.INT.AttributeModifiers > 0 || _objCharacter.REA.AttributeModifiers > 0)
                    strInit += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + (_objCharacter.INI.AttributeModifiers + _objImprovementManager.ValueOf(Improvement.ImprovementType.Initiative) + _objCharacter.INT.AttributeModifiers + _objCharacter.REA.AttributeModifiers).ToString() + ")";
                strInit += " + (" + _objCharacter.InitiativePasses.ToString() + "d6)";
                tipTooltip.SetToolTip(lblINI, strInit);

                // Astral Initiative.
                if (_objCharacter.MAGEnabled)
                {
                    lblAstralINI.Text = _objCharacter.AstralInitiative;
                    strInit = "INT (" + _objCharacter.INT.TotalValue.ToString() + ") x 2";
                    if (_objCharacter.INT.AttributeModifiers > 0)
                        strInit += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + (_objCharacter.INT.AttributeModifiers).ToString() + ")";
                    strInit += " + 2d6";
                    tipTooltip.SetToolTip(lblAstralINI, strInit);
                }

                // Matrix Initiative (AR).
                lblMatrixINI.Text = _objCharacter.MatrixInitiative;
                strInit = "REA (" + _objCharacter.REA.Value.ToString() + ") + INT (" + _objCharacter.INT.Value.ToString() + ")";
                if (_objCharacter.INT.AttributeModifiers > 0 || _objCharacter.REA.AttributeModifiers > 0)
                    strInit += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + (_objCharacter.REA.AttributeModifiers + _objCharacter.INT.AttributeModifiers).ToString() + ")";
                strInit += " + 1d6";
                tipTooltip.SetToolTip(lblMatrixINI, strInit);

                // Matrix Initiative (Cold).
                lblMatrixINICold.Text = _objCharacter.MatrixInitiativeCold;
                strInit = "Data Processing + INT (" + _objCharacter.INT.TotalValue.ToString() + ")";
                if (_objCharacter.INT.AttributeModifiers > 0)
                    strInit += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + (_objCharacter.INT.AttributeModifiers).ToString() + ")";
                strInit += " + 3d6";
                tipTooltip.SetToolTip(lblMatrixINICold, strInit);

                // Matrix Initiative (Hot).
                lblMatrixINIHot.Text = _objCharacter.MatrixInitiativeHot;
                strInit = "Data Processing + INT (" + _objCharacter.INT.TotalValue.ToString() + ")";
                if (_objCharacter.INT.AttributeModifiers > 0)
                    strInit += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + (_objCharacter.INT.AttributeModifiers).ToString() + ")";
                strInit += " + 4d6";
                tipTooltip.SetToolTip(lblMatrixINIHot, strInit);

                // Rigger Initiative.
                lblRiggingINI.Text = _objCharacter.RiggerInitiative;
                strInit = "REA (" + _objCharacter.REA.Value.ToString() + ") + INT (" + _objCharacter.INT.Value.ToString() + ")";
                if (_objCharacter.INT.AttributeModifiers > 0 || _objCharacter.REA.AttributeModifiers > 0)
                    strInit += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + (_objCharacter.REA.AttributeModifiers + _objCharacter.INT.AttributeModifiers).ToString() + ")";
                strInit += " + 1d6";
                tipTooltip.SetToolTip(lblRiggingINI, strInit);

                if (_objCharacter.AdeptEnabled)
                    CalculatePowerPoints();
                if ((_objCharacter.Metatype == "Free Spirit" && !_objCharacter.IsCritter) || _objCharacter.MetatypeCategory.EndsWith("Spirits"))
                {
                    lblCritterPowerPointsLabel.Visible = true;
                    lblCritterPowerPoints.Visible = true;
                    lblCritterPowerPoints.Text = _objController.CalculateFreeSpiritPowerPoints();
                }
                if (_objCharacter.IsFreeSprite)
                {
                    lblCritterPowerPointsLabel.Visible = true;
                    lblCritterPowerPoints.Visible = true;
                    lblCritterPowerPoints.Text = _objController.CalculateFreeSpritePowerPoints();
                }

                // Update the Nuyen and Karma for the character.
                tssNuyen.Text = String.Format("{0:###,###,##0¥}", _objCharacter.Nuyen);
                lblRemainingNuyen.Text = String.Format("{0:###,###,##0¥}", _objCharacter.Nuyen);
                tssKarma.Text = _objCharacter.Karma.ToString();

                PopulateExpenseList();

                // Movement.
                lblMovement.Text = _objCharacter.Movement;
                lblSwim.Text = _objCharacter.Swim;
                lblFly.Text = _objCharacter.Fly;

                // Special Attribute-Only Test.
                lblComposure.Text = _objCharacter.Composure.ToString();
                strTip = "WIL (" + _objCharacter.WIL.TotalValue.ToString() + ") + CHA (" + _objCharacter.CHA.TotalValue.ToString() + ")";
                tipTooltip.SetToolTip(lblComposure, strTip);
                lblJudgeIntentions.Text = _objCharacter.JudgeIntentions.ToString();
                strTip = "INT (" + _objCharacter.INT.TotalValue.ToString() + ") + CHA (" + _objCharacter.CHA.TotalValue.ToString() + ")";
                if (_objImprovementManager.ValueOf(Improvement.ImprovementType.JudgeIntentions) != 0)
                    strTip += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + _objImprovementManager.ValueOf(Improvement.ImprovementType.JudgeIntentions).ToString() + ")";
                tipTooltip.SetToolTip(lblJudgeIntentions, strTip);
                lblLiftCarry.Text = _objCharacter.LiftAndCarry.ToString();
                strTip = "STR (" + _objCharacter.STR.TotalValue.ToString() + ") + BOD (" + _objCharacter.BOD.TotalValue.ToString() + ")";
                if (_objImprovementManager.ValueOf(Improvement.ImprovementType.LiftAndCarry) != 0)
                    strTip += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + _objImprovementManager.ValueOf(Improvement.ImprovementType.LiftAndCarry).ToString() + ")";
                strTip += "\n" + LanguageManager.Instance.GetString("Tip_LiftAndCarry").Replace("{0}", (_objCharacter.STR.TotalValue * 15).ToString()).Replace("{1}", (_objCharacter.STR.TotalValue * 10).ToString());
                tipTooltip.SetToolTip(lblLiftCarry, strTip);
                lblMemory.Text = _objCharacter.Memory.ToString();
                strTip = "LOG (" + _objCharacter.LOG.TotalValue.ToString() + ") + WIL (" + _objCharacter.WIL.TotalValue.ToString() + ")";
                if (_objImprovementManager.ValueOf(Improvement.ImprovementType.Memory) != 0)
                    strTip += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" + _objImprovementManager.ValueOf(Improvement.ImprovementType.Memory).ToString() + ")";
                tipTooltip.SetToolTip(lblMemory, strTip);

                // Career Karma.
                lblCareerKarma.Text = String.Format("{0:###,###,##0}", _objCharacter.CareerKarma);

                // Career Nuyen.
                lblCareerNuyen.Text = String.Format("{0:###,###,##0¥}", _objCharacter.CareerNuyen);

                // Update A.I. Attributes.
                if (_objCharacter.Metatype.EndsWith("A.I.") || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients")
                {
                    lblRating.Text = _objCharacter.Rating.ToString();
                    lblSystem.Text = _objCharacter.System.ToString();
                    lblFirewall.Text = _objCharacter.Firewall.ToString();
                }

                // Update Damage Resistance Pool.
                lblCMDamageResistancePool.Text = (_objCharacter.BOD.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.DamageResistance)).ToString();

                // Update EDG Remaining Info on the Condition Monitor tab.
                string strEDG = _objCharacter.EDG.TotalValue.ToString() + " " + LanguageManager.Instance.GetString("String_Of") + " " + _objCharacter.EDG.Value.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining");
                lblEDGInfo.Text = strEDG;

                foreach (SkillControl objSkillControl in panActiveSkills.Controls.OfType<SkillControl>())
                    objSkillControl.RefreshControl();

                foreach (SkillControl objSkillControl in panKnowledgeSkills.Controls.OfType<SkillControl>())
                    objSkillControl.RefreshControl();

                _blnSkipUpdate = false;

                _objImprovementManager.Commit();

                // If the Viewer window is open for this character, call its RefreshView method which updates it asynchronously
                if (_objCharacter.PrintWindow != null)
                    _objCharacter.PrintWindow.RefreshView();

                cmdQuickenSpell.Visible = _objCharacter.HasImprovement(Improvement.ImprovementType.QuickeningMetamagic, true);
            }
            RefreshLimitModifiers();
            RefreshImprovements();
            UpdateReputation();
        }
示例#9
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;
        }
示例#10
0
        /// <summary>
        /// Open the Select Cyberware window and handle adding to the Tree and Character.
        /// </summary>
        private bool PickCyberware(Improvement.ImprovementSource objSource = Improvement.ImprovementSource.Cyberware)
        {
            // Determine the lowest whole number for the character's current Essence.
            decimal decStartingESS = Math.Floor(_objCharacter.Essence);

            Cyberware objSelectedCyberware = new Cyberware(_objCharacter);
            int intNode = 0;
            if (objSource == Improvement.ImprovementSource.Bioware)
                intNode = 1;

            // Attempt to locate the selected piece of Cyberware.
            try
            {
                if (treCyberware.SelectedNode.Level > 0)
                    objSelectedCyberware = (Cyberware)_objFunctions.FindEquipment(treCyberware.SelectedNode.Tag.ToString(), _objCharacter.Cyberware, typeof(Cyberware));
            }
            catch
            {
            }

            frmSelectCyberware frmPickCyberware = new frmSelectCyberware(_objCharacter, true);
            double dblMultiplier = 1;
            // Apply the character's Cyberware Essence cost multiplier if applicable.
            if (_objImprovementManager.ValueOf(Improvement.ImprovementType.CyberwareEssCost) != 0 && objSource == Improvement.ImprovementSource.Cyberware)
            {
                foreach (Improvement objImprovement in _objCharacter.Improvements)
                {
                    if (objImprovement.ImproveType == Improvement.ImprovementType.CyberwareEssCost && objImprovement.Enabled)
                        dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
                }
                frmPickCyberware.CharacterESSMultiplier = dblMultiplier;
            }

            // Apply the character's Bioware Essence cost multiplier if applicable.
            if (_objImprovementManager.ValueOf(Improvement.ImprovementType.BiowareEssCost) != 0 && objSource == Improvement.ImprovementSource.Bioware)
            {
                foreach (Improvement objImprovement in _objCharacter.Improvements)
                {
                    if (objImprovement.ImproveType == Improvement.ImprovementType.BiowareEssCost && objImprovement.Enabled)
                        dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
                }
                frmPickCyberware.CharacterESSMultiplier = dblMultiplier;
            }

            // Apply the character's Basic Bioware Essence cost multiplier if applicable.
            if (_objImprovementManager.ValueOf(Improvement.ImprovementType.BasicBiowareEssCost) != 0 && objSource == Improvement.ImprovementSource.Bioware)
            {
                double dblBasicMultiplier = 1;
                foreach (Improvement objImprovement in _objCharacter.Improvements)
                {
                    if (objImprovement.ImproveType == Improvement.ImprovementType.BasicBiowareEssCost && objImprovement.Enabled)
                        dblBasicMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
                }
                frmPickCyberware.BasicBiowareESSMultiplier = dblBasicMultiplier;
            }

            // Genetech Cost multiplier.
            if (_objImprovementManager.ValueOf(Improvement.ImprovementType.GenetechCostMultiplier) != 0 && objSource == Improvement.ImprovementSource.Bioware)
            {
                dblMultiplier = 1;
                foreach (Improvement objImprovement in _objCharacter.Improvements)
                {
                    if (objImprovement.ImproveType == Improvement.ImprovementType.GenetechCostMultiplier && objImprovement.Enabled)
                        dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
                }
                frmPickCyberware.GenetechCostMultiplier = dblMultiplier;
            }

            // Transgenics Cost multiplier.
            if (_objImprovementManager.ValueOf(Improvement.ImprovementType.TransgenicsBiowareCost) != 0 && objSource == Improvement.ImprovementSource.Bioware)
            {
                dblMultiplier = 1;
                foreach (Improvement objImprovement in _objCharacter.Improvements)
                {
                    if (objImprovement.ImproveType == Improvement.ImprovementType.TransgenicsBiowareCost && objImprovement.Enabled)
                        dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
                }
                frmPickCyberware.TransgenicsBiowareCostMultiplier = dblMultiplier;
            }

            try
            {
                if (treCyberware.SelectedNode.Level > 0)
                {
                    frmPickCyberware.SetGrade = lblCyberwareGrade.Text;
                    frmPickCyberware.LockGrade();
                    // If the Cyberware has a Capacity with no brackets (meaning it grants Capacity), show only Subsystems (those that conume Capacity).
                    if (!objSelectedCyberware.Capacity.Contains('['))
                    {
                        frmPickCyberware.ShowOnlySubsystems = true;
                        frmPickCyberware.Subsystems = objSelectedCyberware.Subsytems;
                        frmPickCyberware.MaximumCapacity = objSelectedCyberware.CapacityRemaining;

                        // Do not allow the user to add a new piece of Cyberware if its Capacity has been reached.
                        if (_objOptions.EnforceCapacity && objSelectedCyberware.CapacityRemaining < 0)
                        {
                            MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return false;
                        }
                    }
                }
            }
            catch
            {
            }

            if (objSource == Improvement.ImprovementSource.Bioware)
                frmPickCyberware.WindowMode = frmSelectCyberware.Mode.Bioware;

            frmPickCyberware.AllowModularPlugins = objSelectedCyberware.AllowModularPlugins;

            frmPickCyberware.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickCyberware.DialogResult == DialogResult.Cancel)
                return false;

            // Open the Cyberware XML file and locate the selected piece.
            XmlDocument objXmlDocument = new XmlDocument();
            if (objSource == Improvement.ImprovementSource.Bioware)
                objXmlDocument = XmlManager.Instance.Load("bioware.xml");
            else
                objXmlDocument = XmlManager.Instance.Load("cyberware.xml");

            XmlNode objXmlCyberware;
            if (objSource == Improvement.ImprovementSource.Bioware)
                objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/biowares/bioware[id = \"" + frmPickCyberware.SelectedCyberware + "\"]");
            else
                objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/cyberwares/cyberware[id = \"" + frmPickCyberware.SelectedCyberware + "\"]");

            // Create the Cyberware object.
            Cyberware objCyberware = new Cyberware(_objCharacter);
            List<Weapon> objWeapons = new List<Weapon>();
            TreeNode objNode = new TreeNode();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            objCyberware.Create(objXmlCyberware, _objCharacter, frmPickCyberware.SelectedGrade, objSource, frmPickCyberware.SelectedRating, objNode, objWeapons, objWeaponNodes);
            if (objCyberware.InternalId == Guid.Empty.ToString())
                return false;

            // Force the item to be Transgenic if selected.
            if (frmPickCyberware.ForceTransgenic)
                objCyberware.Category = "Genetech: Transgenics";

            int intCost = objCyberware.TotalCost;

            // Check the item's Cost and make sure the character can afford it.
            if (!frmPickCyberware.FreeCost)
            {
                if (intCost > _objCharacter.Nuyen)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    // Remove any Improvements created by the Cyberware.
                    _objImprovementManager.RemoveImprovements(objCyberware.SourceType, objCyberware.InternalId);
                    return frmPickCyberware.AddAgain;
                }
                else
                {
                    // Create the Expense Log Entry.
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    string strEntry = "";
                    if (objCyberware.SourceType == Improvement.ImprovementSource.Cyberware)
                        strEntry = LanguageManager.Instance.GetString("String_ExpensePurchaseCyberware");
                    else
                        strEntry = LanguageManager.Instance.GetString("String_ExpensePurchaseBioware");
                    objExpense.Create(intCost * -1, strEntry + " " + objCyberware.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen -= intCost;

                    ExpenseUndo objUndo = new ExpenseUndo();
                    objUndo.CreateNuyen(NuyenExpenseType.AddCyberware, objCyberware.InternalId);
                    objExpense.Undo = objUndo;
                }
            }

            try
            {
                if (treCyberware.SelectedNode.Level > 0)
                {
                    treCyberware.SelectedNode.Nodes.Add(objNode);
                    treCyberware.SelectedNode.Expand();
                    objSelectedCyberware.Cyberwares.Add(objCyberware);
                    objCyberware.Parent = objSelectedCyberware;
                }
                else
                {
                    treCyberware.Nodes[intNode].Nodes.Add(objNode);
                    treCyberware.Nodes[intNode].Expand();
                    _objCharacter.Cyberware.Add(objCyberware);
                }
            }
            catch
            {
                treCyberware.Nodes[intNode].Nodes.Add(objNode);
                treCyberware.Nodes[intNode].Expand();
                _objCharacter.Cyberware.Add(objCyberware);
            }

            // Select the node that was just added.
            if (objSource == Improvement.ImprovementSource.Cyberware)
                objNode.ContextMenuStrip = cmsCyberware;
            else if (objSource == Improvement.ImprovementSource.Bioware)
                objNode.ContextMenuStrip = cmsBioware;

            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();
            }

            // Determine the lowest whole number for the character's Essence after adding the 'Ware.
            decimal decEndingESS = Math.Floor(_objCharacter.Essence);
            decimal decDifferent = decStartingESS - decEndingESS;

            if (decDifferent > 0.0m)
            {
                // Permanently reduce the character's MAG/RES Attributes.
                _objCharacter.MAG.Value -= Convert.ToInt32(decDifferent);
                _objCharacter.RES.Value -= Convert.ToInt32(decDifferent);

                // If the Attribute reaches 0, the character has burned out.
                if (_objCharacter.MAG.Value < 1)
                {
                    _objCharacter.MAG.Value = 0;
                    _objCharacter.MAG.MetatypeMinimum = 0;
                    _objCharacter.MAG.MetatypeMaximum = 0;
                    _objCharacter.MAG.MetatypeAugmentedMaximum = 0;

                    if (_objCharacter.MAGEnabled)
                    {
                        // Move all MAG-linked Active Skills to Knowledge Skills.
                        List<Skill> lstNewSkills = new List<Skill>();
                        foreach (Skill objSkill in _objCharacter.Skills)
                        {
                            if (objSkill.Attribute == "MAG" && objSkill.Rating > 0)
                            {
                                int i = panKnowledgeSkills.Controls.Count;
                                Skill objKnowledge = new Skill(_objCharacter);

                                SkillControl objSkillControl = new SkillControl();
                                objKnowledge.Name = objSkill.Name;
                                objSkillControl.SkillObject = objKnowledge;

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

                                objSkillControl.KnowledgeSkill = true;
                                objSkillControl.AllowDelete = true;
                                if (objSkill.Rating > 7)
                                    objSkillControl.SkillRatingMaximum = objSkill.Rating;
                                else
                                    objSkillControl.SkillRatingMaximum = 6;
                                objSkillControl.SkillRating = objSkill.Rating;
                                objSkillControl.SkillCategory = "Professional";
                                // 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);

                                lstNewSkills.Add(objKnowledge);
                            }
                        }
                        foreach (Skill objSkill in lstNewSkills)
                            _objCharacter.Skills.Add(objSkill);
                    }

                    _objCharacter.MAGEnabled = false;
                    _objCharacter.MagicianEnabled = false;
                    _objCharacter.AdeptEnabled = false;
                }
                if (_objCharacter.RES.Value < 1)
                {
                    _objCharacter.RES.Value = 0;
                    _objCharacter.RES.MetatypeMinimum = 0;
                    _objCharacter.RES.MetatypeMinimum = 0;
                    _objCharacter.RES.MetatypeAugmentedMaximum = 0;

                    if (_objCharacter.RESEnabled)
                    {
                        // Move all RES-linked Active Skills to Knowledge Skills.
                        List<Skill> lstNewSkills = new List<Skill>();
                        foreach (Skill objSkill in _objCharacter.Skills)
                        {
                            if (objSkill.Attribute == "RES" && objSkill.Rating > 0)
                            {
                                int i = panKnowledgeSkills.Controls.Count;
                                Skill objKnowledge = new Skill(_objCharacter);

                                SkillControl objSkillControl = new SkillControl();
                                objKnowledge.Name = objSkill.Name;
                                objSkillControl.SkillObject = objKnowledge;

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

                                objSkillControl.KnowledgeSkill = true;
                                objSkillControl.AllowDelete = true;
                                if (objSkill.Rating > 7)
                                    objSkillControl.SkillRatingMaximum = objSkill.Rating;
                                else
                                    objSkillControl.SkillRatingMaximum = 6;
                                objSkillControl.SkillRating = objSkill.Rating;
                                objSkillControl.SkillCategory = "Professional";
                                // 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);

                                lstNewSkills.Add(objKnowledge);
                            }
                        }
                        foreach (Skill objSkill in lstNewSkills)
                            _objCharacter.Skills.Add(objSkill);
                    }

                    _objCharacter.RESEnabled = false;
                    _objCharacter.TechnomancerEnabled = false;
                }
            }

            _objFunctions.SortTree(treCyberware);
            treCyberware.SelectedNode = objNode;
            UpdateCharacterInfo();
            RefreshSelectedCyberware();
            PopulateGearList();

            if (frmPickCyberware.DialogResult != DialogResult.Cancel)
            {
                _blnIsDirty = true;
                UpdateWindowTitle();
            }

            return frmPickCyberware.AddAgain;
        }
示例#11
0
		private void cmdAddExoticSkill_Click(object sender, EventArgs e)
		{
			frmSelectExoticSkill frmPickExoticSkill = new frmSelectExoticSkill();
			frmPickExoticSkill.ShowDialog(this);

			if (frmPickExoticSkill.DialogResult == DialogResult.Cancel)
				return;

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

			XmlNode nodSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + frmPickExoticSkill.SelectedExoticSkill + "\"]");

			int i = panActiveSkills.Controls.Count;
			Skill objSkill = new Skill(_objCharacter);
			SkillSpecialization objSkillSpec = new SkillSpecialization(frmPickExoticSkill.SelectedExoticSkillSpecialisation);
			objSkill.Attribute = nodSkill["attribute"].InnerText;
			objSkill.Specializations.Add(objSkillSpec);
			if (_objCharacter.MaxSkillRating > 0)
				objSkill.RatingMaximum = _objCharacter.MaxSkillRating;

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

			// Attach an EventHandler for the RatingChanged and SpecializationChanged Events.
			objSkillControl.RatingChanged += objActiveSkill_RatingChanged;
			objSkillControl.SpecializationChanged += objSkill_SpecializationChanged;
			objSkillControl.SkillKarmaClicked += objSkill_KarmaClicked;
			objSkillControl.SkillName = frmPickExoticSkill.SelectedExoticSkill;
			objSkillControl.DiceRollerClicked += objSkill_DiceRollerClicked;
			objSkillControl.DeleteSkill += objSkill_DeleteExoticSkill;
			objSkillControl.SkillCategory = nodSkill["category"].InnerText;
			if (nodSkill["default"].InnerText == "Yes")
				objSkill.Default = true;
			else
				objSkill.Default = false;

			objSkill.ExoticSkill = true;
			_objCharacter.Skills.Add(objSkill);

			objSkillControl.SkillRatingMaximum = 12;
			// 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);

			_blnIsDirty = true;
			UpdateWindowTitle();
		}