private void frmSelectMartialArtManeuver_Load(object sender, EventArgs e)
		{
			foreach (Label objLabel in this.Controls.OfType<Label>())
			{
				if (objLabel.Text.StartsWith("["))
					objLabel.Text = "";
			}

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

			// Load the Martial Art information.
			_objXmlDocument = XmlManager.Instance.Load("martialarts.xml");

			// Populate the Martial Art Maneuver list.
			XmlNodeList objManeuverList = _objXmlDocument.SelectNodes("/chummer/maneuvers/maneuver[" + _objCharacter.Options.BookXPath() + "]");
			foreach (XmlNode objXmlManeuver in objManeuverList)
			{
				ListItem objItem = new ListItem();
				objItem.Value = objXmlManeuver["name"].InnerText;
				if (objXmlManeuver["translate"] != null)
					objItem.Name = objXmlManeuver["translate"].InnerText;
				else
					objItem.Name = objXmlManeuver["name"].InnerText;
				lstManeuver.Add(objItem);
			}
			SortListItem objSort = new SortListItem();
			lstManeuver.Sort(objSort.Compare);
			lstManeuvers.DataSource = null;
			lstManeuvers.ValueMember = "Value";
			lstManeuvers.DisplayMember = "Name";
			lstManeuvers.DataSource = lstManeuver;
		}
        private void frmSelectExoticSkill_Load(object sender, EventArgs e)
        {
            XmlDocument objXmlDocument = new XmlDocument();
            objXmlDocument = XmlManager.Instance.Load("skills.xml");

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

            // Build the list of Exotic Active Skills from the Skills file.
            XmlNodeList objXmlSkillList = objXmlDocument.SelectNodes("/chummer/skills/skill[exotic = \"Yes\"]");
            foreach (XmlNode objXmlSkill in objXmlSkillList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSkill["name"].InnerText;
                if (objXmlSkill.Attributes != null)
                {
                    if (objXmlSkill["translate"] != null)
                        objItem.Name = objXmlSkill["translate"].InnerText;
                    else
                        objItem.Name = objXmlSkill["name"].InnerText;
                }
                else
                    objItem.Name = objXmlSkill["name"].InnerXml;
                lstSkills.Add(objItem);
            }
            SortListItem objSort = new SortListItem();
            lstSkills.Sort(objSort.Compare);
            cboCategory.ValueMember = "Value";
            cboCategory.DisplayMember = "Name";
            cboCategory.DataSource = lstSkills;

            // Select the first Skill in the list.
            cboCategory.SelectedIndex = 0;
        }
Esempio n. 3
0
        private void frmSelectVehicleMod_Load(object sender, EventArgs e)
        {
            chkHideOverAvailLimit.Text = chkHideOverAvailLimit.Text.Replace("{0}",
                                                                            _objCharacter.MaximumAvailability.ToString());
            chkHideOverAvailLimit.Checked = _objCharacter.Options.HideItemsOverAvailLimit;
            // Load the Mod information.
            _objXmlDocument = XmlManager.Instance.Load(_strInputFile + ".xml");

            string[] strValues = _strLimitToCategories.Split(',');

            // Populate the Category list.
            XmlNodeList objXmlNodeList = _objXmlDocument.SelectNodes("/chummer/modcategories/category");

            foreach (XmlNode objXmlCategory in objXmlNodeList)
            {
                if (_strLimitToCategories != "" && strValues.All(value => value != objXmlCategory.InnerText))
                {
                    continue;
                }
                ListItem objItem = new ListItem();
                objItem.Value = objXmlCategory.InnerText;
                objItem.Name  = objXmlCategory.Attributes?["translate"]?.InnerText ?? objXmlCategory.InnerText;
                _lstCategory.Add(objItem);
            }
            SortListItem objSort = new SortListItem();

            _lstCategory.Sort(objSort.Compare);
            if (_lstCategory.Count > 0)
            {
                ListItem objItem = new ListItem();
                objItem.Value = "Show All";
                objItem.Name  = LanguageManager.Instance.GetString("String_ShowAll");
                _lstCategory.Insert(0, objItem);
            }
            cboCategory.BeginUpdate();
            cboCategory.ValueMember   = "Value";
            cboCategory.DisplayMember = "Name";
            cboCategory.DataSource    = _lstCategory;

            // Select the first Category in the list.
            if (string.IsNullOrEmpty(_strSelectCategory))
            {
                cboCategory.SelectedIndex = 0;
            }
            else
            {
                cboCategory.SelectedValue = _strSelectCategory;
            }

            cboCategory.EndUpdate();

            chkBlackMarketDiscount.Visible = _objCharacter.BlackMarketDiscount;

            if (_strInputFile == "weapons")
            {
                Text = LanguageManager.Instance.GetString("Title_SelectVehicleMod_Weapon");
            }
            _blnSkipUpdate = false;
            UpdateGearInfo();
        }
Esempio n. 4
0
        private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Update the list of Vehicles based on the selected Category.
            List <ListItem> lstVehicles = new List <ListItem>();

            // Retrieve the list of Vehicles for the selected Category.
            XmlNodeList objXmlVehicleList = _objXmlDocument.SelectNodes("/chummer/vehicles/vehicle[category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ")]");

            foreach (XmlNode objXmlVehicle in objXmlVehicleList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlVehicle["name"].InnerText;
                if (objXmlVehicle["translate"] != null)
                {
                    objItem.Name = objXmlVehicle["translate"].InnerText;
                }
                else
                {
                    objItem.Name = objXmlVehicle["name"].InnerText;
                }
                lstVehicles.Add(objItem);
            }
            SortListItem objSort = new SortListItem();

            lstVehicles.Sort(objSort.Compare);
            lstVehicle.DataSource    = null;
            lstVehicle.ValueMember   = "Value";
            lstVehicle.DisplayMember = "Name";
            lstVehicle.DataSource    = lstVehicles;
        }
        private void frmSelectMartialArtManeuver_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith("["))
                {
                    objLabel.Text = string.Empty;
                }
            }

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

            // Load the Martial Art information.
            _objXmlDocument = XmlManager.Instance.Load("martialarts.xml");

            // Populate the Martial Art Maneuver list.
            XmlNodeList objManeuverList = _objXmlDocument.SelectNodes("/chummer/maneuvers/maneuver[" + _objCharacter.Options.BookXPath() + "]");

            foreach (XmlNode objXmlManeuver in objManeuverList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlManeuver["name"].InnerText;
                objItem.Name  = objXmlManeuver["translate"]?.InnerText ?? objXmlManeuver["name"].InnerText;
                lstManeuver.Add(objItem);
            }
            SortListItem objSort = new SortListItem();

            lstManeuver.Sort(objSort.Compare);
            lstManeuvers.BeginUpdate();
            lstManeuvers.DataSource    = null;
            lstManeuvers.ValueMember   = "Value";
            lstManeuvers.DisplayMember = "Name";
            lstManeuvers.DataSource    = lstManeuver;
            lstManeuvers.EndUpdate();
        }
Esempio n. 6
0
        private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Update the list of Vehicles based on the selected Category.
            List <ListItem> lstVehicles = new List <ListItem>();

            // Retrieve the list of Vehicles for the selected Category.
            XmlNodeList objXmlVehicleList = _objXmlDocument.SelectNodes("/chummer/vehicles/vehicle[category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ")]");

            foreach (XmlNode objXmlVehicle in objXmlVehicleList)
            {
                if (Backend.Shared_Methods.SelectionShared.CheckAvailRestriction(objXmlVehicle, _objCharacter))
                {
                    if (objXmlVehicle["hidden"] != null)
                    {
                        continue;
                    }
                    ListItem objItem = new ListItem {
                        Value = objXmlVehicle["name"]?.InnerText
                    };
                    objItem.Name = objXmlVehicle["translate"]?.InnerText ?? objItem.Value;
                    lstVehicles.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();

            lstVehicles.Sort(objSort.Compare);
            lstVehicle.BeginUpdate();
            lstVehicle.DataSource    = null;
            lstVehicle.ValueMember   = "Value";
            lstVehicle.DisplayMember = "Name";
            lstVehicle.DataSource    = lstVehicles;
            lstVehicle.EndUpdate();
        }
Esempio n. 7
0
        private void frmSelectSetting_Load(object sender, EventArgs e)
        {
            // Build the list of XML files found in the settings directory.
            List<ListItem> lstSettings = new List<ListItem>();
            string settingsDirectoryPath = Path.Combine(Environment.CurrentDirectory, "settings");
            foreach (string strFileName in Directory.GetFiles(settingsDirectoryPath, "*.xml"))
            {
                // Load the file so we can get the Setting name.
                XmlDocument objXmlDocument = new XmlDocument();
                objXmlDocument.Load(strFileName);
                string strSettingsName = objXmlDocument.SelectSingleNode("/settings/name").InnerText;

                ListItem objItem = new ListItem();
                objItem.Value = Path.GetFileName(strFileName);
                objItem.Name = strSettingsName;

                lstSettings.Add(objItem);
            }
            SortListItem objSort = new SortListItem();
            lstSettings.Sort(objSort.Compare);
            cboSetting.DataSource = lstSettings;
            cboSetting.ValueMember = "Value";
            cboSetting.DisplayMember = "Name";

            // Attempt to make default.xml the default one. If it could not be found in the list, select the first item instead.
            cboSetting.SelectedIndex = cboSetting.FindStringExact("Default Settings");
            if (cboSetting.SelectedIndex == -1)
                cboSetting.SelectedIndex = 0;
        }
Esempio n. 8
0
        private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <ListItem> lstWeapons = new List <ListItem>();

            // Populate the Weapon list.
            XmlNodeList objXmlWeaponList = _objXmlDocument.SelectNodes("/chummer/weapons/weapon[category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ")]");

            foreach (XmlNode objXmlWeapon in objXmlWeaponList)
            {
                bool blnHide = objXmlWeapon["cyberware"]?.InnerText == "yes";
                blnHide = objXmlWeapon["hide"]?.InnerText == "yes";
                if (!blnHide)
                {
                    ListItem objItem = new ListItem
                    {
                        Value = objXmlWeapon["id"].InnerText,
                        Name  = objXmlWeapon["translate"]?.InnerText ?? objXmlWeapon["name"].InnerText
                    };
                    lstWeapons.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();

            lstWeapons.Sort(objSort.Compare);
            lstWeapon.DataSource    = null;
            lstWeapon.ValueMember   = "Value";
            lstWeapon.DisplayMember = "Name";
            lstWeapon.DataSource    = lstWeapons;

            if (chkBrowse.Checked)
            {
                LoadGrid();
            }
        }
Esempio n. 9
0
        private void frmSelectVehicle_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith('['))
                {
                    objLabel.Text = string.Empty;
                }
            }
            if (_objCharacter.Created)
            {
                chkHideOverAvailLimit.Visible = false;
                chkHideOverAvailLimit.Checked = false;
            }
            else
            {
                chkHideOverAvailLimit.Text    = chkHideOverAvailLimit.Text.Replace("{0}", _objCharacter.MaximumAvailability.ToString());
                chkHideOverAvailLimit.Checked = _objCharacter.Options.HideItemsOverAvailLimit;
            }

            // Populate the Vehicle Category list.
            XmlNodeList objXmlCategoryList = _objXmlDocument.SelectNodes("/chummer/categories/category");

            foreach (XmlNode objXmlCategory in objXmlCategoryList)
            {
                string strInnerText = objXmlCategory.InnerText;
                _lstCategory.Add(new ListItem(strInnerText, objXmlCategory.Attributes?["translate"]?.InnerText ?? strInnerText));
            }
            SortListItem objSort = new SortListItem();

            _lstCategory.Sort(objSort.Compare);

            if (_lstCategory.Count > 0)
            {
                _lstCategory.Insert(0, new ListItem("Show All", LanguageManager.GetString("String_ShowAll")));
            }

            cboCategory.BeginUpdate();
            cboCategory.ValueMember   = "Value";
            cboCategory.DisplayMember = "Name";
            cboCategory.DataSource    = _lstCategory;

            // Select the first Category in the list.
            if (string.IsNullOrEmpty(s_StrSelectCategory))
            {
                cboCategory.SelectedIndex = 0;
            }
            else
            {
                cboCategory.SelectedValue = s_StrSelectCategory;
            }

            if (cboCategory.SelectedIndex == -1)
            {
                cboCategory.SelectedIndex = 0;
            }
            cboCategory.EndUpdate();

            chkBlackMarketDiscount.Visible = _objCharacter.BlackMarketDiscount;
        }
Esempio n. 10
0
        private void frmSelectSetting_Load(object sender, EventArgs e)
        {
            // Build the list of XML files found in the settings directory.
            List <ListItem> lstSettings           = new List <ListItem>();
            string          settingsDirectoryPath = Path.Combine(Environment.CurrentDirectory, "settings");

            foreach (string strFileName in Directory.GetFiles(settingsDirectoryPath, "*.xml"))
            {
                // Load the file so we can get the Setting name.
                XmlDocument objXmlDocument = new XmlDocument();
                objXmlDocument.Load(strFileName);
                string strSettingsName = objXmlDocument.SelectSingleNode("/settings/name").InnerText;

                ListItem objItem = new ListItem();
                objItem.Value = Path.GetFileName(strFileName);
                objItem.Name  = strSettingsName;

                lstSettings.Add(objItem);
            }
            SortListItem objSort = new SortListItem();

            lstSettings.Sort(objSort.Compare);
            cboSetting.DataSource    = lstSettings;
            cboSetting.ValueMember   = "Value";
            cboSetting.DisplayMember = "Name";

            // Attempt to make default.xml the default one. If it could not be found in the list, select the first item instead.
            cboSetting.SelectedIndex = cboSetting.FindStringExact("Default Settings");
            if (cboSetting.SelectedIndex == -1)
            {
                cboSetting.SelectedIndex = 0;
            }
        }
Esempio n. 11
0
		private void frmSelectMentorSpirit_Load(object sender, EventArgs e)
		{
			if (_strXmlFile == "paragons.xml")
				this.Text = LanguageManager.Instance.GetString("Title_SelectMentorSpirit_Paragon");

			foreach (Label objLabel in this.Controls.OfType<Label>())
			{
				if (objLabel.Text.StartsWith("["))
					objLabel.Text = "";
			}

			// Load the Mentor information.
			_objXmlDocument = XmlManager.Instance.Load(_strXmlFile);

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

            // Populate the Mentor list.
            XmlNodeList objXmlMentorList = _objXmlDocument.SelectNodes("/chummer/mentors/mentor[(" + _objCharacter.Options.BookXPath() + ")]");
            foreach (XmlNode objXmlMentor in objXmlMentorList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlMentor["name"].InnerText;
                if (objXmlMentor["translate"] != null)
                    objItem.Name = objXmlMentor["translate"].InnerText;
                else
                    objItem.Name = objXmlMentor["name"].InnerText;
                lstMentors.Add(objItem);
            }
            SortListItem objSort = new SortListItem();
            lstMentors.Sort(objSort.Compare);
            lstMentor.DataSource = null;
            lstMentor.ValueMember = "Value";
            lstMentor.DisplayMember = "Name";
            lstMentor.DataSource = lstMentors;
        }
Esempio n. 12
0
        private void frmSelectExoticSkill_Load(object sender, EventArgs e)
        {
            XmlDocument objXmlDocument = new XmlDocument();

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

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


            // Build the list of Exotic Active Skills from the Skills file.
            XmlNodeList objXmlSkillList = objXmlDocument.SelectNodes("/chummer/skills/skill[exotic = \"Yes\"]");

            foreach (XmlNode objXmlSkill in objXmlSkillList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlSkill["name"].InnerText;
                objItem.Name  = objXmlSkill["translate"]?.InnerText ?? objXmlSkill["name"].InnerText;
                lstSkills.Add(objItem);
            }
            SortListItem objSort = new SortListItem();

            lstSkills.Sort(objSort.Compare);
            cboCategory.BeginUpdate();
            cboCategory.ValueMember   = "Value";
            cboCategory.DisplayMember = "Name";
            cboCategory.DataSource    = lstSkills;

            // Select the first Skill in the list.
            cboCategory.SelectedIndex = 0;

            cboCategory.EndUpdate();

            BuildList();
        }
Esempio n. 13
0
        private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <ListItem> lstWeapons = new List <ListItem>();

            // Populate the Weapon list.
            XmlNodeList objXmlWeaponList = _objXmlDocument.SelectNodes("/chummer/weapons/weapon[category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ")]");

            foreach (XmlNode objXmlWeapon in objXmlWeaponList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlWeapon["id"].InnerText;
                if (objXmlWeapon["translate"] != null)
                {
                    objItem.Name = objXmlWeapon["translate"].InnerText;
                }
                else
                {
                    objItem.Name = objXmlWeapon["name"].InnerText;
                }
                lstWeapons.Add(objItem);
            }
            SortListItem objSort = new SortListItem();

            lstWeapons.Sort(objSort.Compare);
            lstWeapon.DataSource    = null;
            lstWeapon.ValueMember   = "Value";
            lstWeapon.DisplayMember = "Name";
            lstWeapon.DataSource    = lstWeapons;
        }
Esempio n. 14
0
        private void frmSelectSetting_Load(object sender, EventArgs e)
        {
            // Build the list of XML files found in the settings directory.
            List<ListItem> lstSettings = new List<ListItem>();
            foreach (string strFileName in Directory.GetFiles(Path.Combine(GlobalOptions.ApplicationPath(), "settings"), "*.xml"))
            {
                // Remove the path from the file name.
                string strSettingsFile = strFileName;
                strSettingsFile = strSettingsFile.Replace(Path.Combine(GlobalOptions.ApplicationPath(), "settings"), string.Empty);
                strSettingsFile = strSettingsFile.Replace(Path.DirectorySeparatorChar, ' ').Trim();

                // Load the file so we can get the Setting name.
                XmlDocument objXmlDocument = new XmlDocument();
                objXmlDocument.Load(strFileName);
                string strSettingsName = objXmlDocument.SelectSingleNode("/settings/name").InnerText;

                ListItem objItem = new ListItem();
                objItem.Value = strSettingsFile;
                objItem.Name = strSettingsName;

                lstSettings.Add(objItem);
            }
            SortListItem objSort = new SortListItem();
            lstSettings.Sort(objSort.Compare);
            cboSetting.DataSource = lstSettings;
            cboSetting.ValueMember = "Value";
            cboSetting.DisplayMember = "Name";

            // Attempt to make default.xml the default one. If it could not be found in the list, select the first item instead.
            cboSetting.SelectedIndex = cboSetting.FindStringExact("Default Settings");
            if (cboSetting.SelectedIndex == -1)
                cboSetting.SelectedIndex = 0;
        }
Esempio n. 15
0
        private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <ListItem> lstArmors = new List <ListItem>();

            // Populate the Armor list.
            XmlNodeList objXmlArmorList = _objXmlDocument.SelectNodes("/chummer/armors/armor[category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ")]");

            foreach (XmlNode objXmlArmor in objXmlArmorList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlArmor["name"].InnerText;
                if (objXmlArmor["translate"] != null)
                {
                    objItem.Name = objXmlArmor["translate"].InnerText;
                }
                else
                {
                    objItem.Name = objXmlArmor["name"].InnerText;
                }
                lstArmors.Add(objItem);
            }
            SortListItem objSort = new SortListItem();

            lstArmors.Sort(objSort.Compare);
            lstArmor.DataSource    = null;
            lstArmor.ValueMember   = "Value";
            lstArmor.DisplayMember = "Name";
            lstArmor.DataSource    = lstArmors;

            if (chkBrowse.Checked)
            {
                LoadGrid();
            }
        }
Esempio n. 16
0
        private void frmSelectProgram_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith("["))
                {
                    objLabel.Text = string.Empty;
                }
            }

            // Load the Programs information.
            _objXmlDocument = XmlManager.Instance.Load("programs.xml");

            // Populate the Category list.
            XmlNodeList objXmlNodeList = _objXmlDocument.SelectNodes("/chummer/categories/category");

            foreach (XmlNode objXmlCategory in objXmlNodeList)
            {
                if (_blnInherentProgram && objXmlCategory.InnerText != "Common Programs" && objXmlCategory.InnerText != "Hacking Programs")
                {
                    continue;
                }
                if (!_blnAdvancedProgramAllowed && objXmlCategory.InnerText == "Advanced Programs")
                {
                    continue;
                }
                bool blnAddItem = true;
                // Make sure it is not already in the Category list.
                foreach (ListItem objItem in _lstCategory)
                {
                    if (objItem.Value == objXmlCategory.InnerText)
                    {
                        blnAddItem = false;
                        break;
                    }
                }
                if (blnAddItem)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlCategory.InnerText;
                    objItem.Name  = objXmlCategory.Attributes?["translate"]?.InnerText ?? objXmlCategory.InnerText;
                    _lstCategory.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();

            _lstCategory.Sort(objSort.Compare);
            cboCategory.BeginUpdate();
            cboCategory.DataSource    = null;
            cboCategory.ValueMember   = "Value";
            cboCategory.DisplayMember = "Name";
            cboCategory.DataSource    = _lstCategory;
            cboCategory.EndUpdate();

            // Select the first Category in the list.
            cboCategory.SelectedIndex = 0;

            txtSearch.Text = string.Empty;
        }
Esempio n. 17
0
        private void frmSelectMartialArtAdvantage_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in this.Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith("["))
                {
                    objLabel.Text = "";
                }
            }

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

            // Load the Martial Art information.
            _objXmlDocument = XmlManager.Instance.Load("martialarts.xml");

            // Populate the Martial Art Advantage list.
            XmlNodeList objXmlAdvantageList = _objXmlDocument.SelectNodes("/chummer/martialarts/martialart[(" + _objCharacter.Options.BookXPath() + ") and name = \"" + _strMartialArt + "\"]/techniques/technique");

            foreach (XmlNode objXmlAdvantage in objXmlAdvantageList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlAdvantage["name"].InnerText;
                if (objXmlAdvantage.Attributes["translate"] != null)
                {
                    objItem.Name = objXmlAdvantage.Attributes["translate"].InnerText;
                }
                else
                {
                    objItem.Name = objXmlAdvantage["name"].InnerText;
                }

                bool blnIsNew = true;
                foreach (MartialArt objMartialArt in _objCharacter.MartialArts)
                {
                    if (objMartialArt.Name == _strMartialArt)
                    {
                        foreach (MartialArtAdvantage objMartialArtAdvantage in objMartialArt.Advantages)
                        {
                            if (objMartialArtAdvantage.Name == objItem.Value)
                            {
                                blnIsNew = false;
                            }
                        }
                    }
                }

                if (blnIsNew)
                {
                    lstAdvantage.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();

            lstAdvantage.Sort(objSort.Compare);
            lstAdvantages.DataSource    = null;
            lstAdvantages.ValueMember   = "Value";
            lstAdvantages.DisplayMember = "Name";
            lstAdvantages.DataSource    = lstAdvantage;
        }
Esempio n. 18
0
        private void frmSelectArmorMod_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith("["))
                {
                    objLabel.Text = string.Empty;
                }
            }

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

            // Load the Armor information.
            _objXmlDocument = XmlManager.Instance.Load("armor.xml");

            // Populate the Mods list.
            string[] strAllowed = _strAllowedCategories.Split(',');
            string   strMount   = string.Empty;

            for (int i = 0; i < strAllowed.Length; i++)
            {
                if (!string.IsNullOrEmpty(strAllowed[i]))
                {
                    strMount += "category = \"" + strAllowed[i] + "\"";
                }
                if (i < strAllowed.Length - 1 || !_blnExcludeGeneralCategory)
                {
                    strMount += " or ";
                }
            }
            if (!_blnExcludeGeneralCategory)
            {
                strMount += "category = \"General\"";
            }
            XmlNodeList objXmlModList = _objXmlDocument.SelectNodes("/chummer/mods/mod[" + strMount + " and (" + _objCharacter.Options.BookXPath() + ")]");

            foreach (XmlNode objXmlMod in objXmlModList)
            {
                bool blnHide = (objXmlMod["hide"] != null);
                if (!blnHide)
                {
                    ListItem objItem = new ListItem
                    {
                        Value = objXmlMod["name"].InnerText,
                        Name  = objXmlMod["translate"]?.InnerText ?? objXmlMod["name"].InnerText
                    };
                    lstMods.Add(objItem);
                }
            }
            chkBlackMarketDiscount.Visible = _objCharacter.BlackMarketDiscount;
            SortListItem objSort = new SortListItem();

            lstMods.Sort(objSort.Compare);
            lstMod.BeginUpdate();
            lstMod.ValueMember   = "Value";
            lstMod.DisplayMember = "Name";
            lstMod.DataSource    = lstMods;
            lstMod.EndUpdate();
        }
Esempio n. 19
0
        private void frmSelectPower_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith("["))
                {
                    objLabel.Text = string.Empty;
                }
            }

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

            // Load the Powers information.
            _objXmlDocument = XmlManager.Instance.Load("powers.xml");

            // Populate the Powers list.
            XmlNodeList objXmlPowerList;

            if (!string.IsNullOrEmpty(_strLimitToPowers))
            {
                string   strFilter = "(";
                string[] strValue  = _strLimitToPowers.Split(',');
                foreach (string strPower in strValue)
                {
                    strFilter += "name = \"" + strPower.Trim() + "\" or ";
                }
                // Remove the trailing " or ".
                strFilter       = strFilter.Substring(0, strFilter.Length - 4);
                strFilter      += ")";
                objXmlPowerList = _objXmlDocument.SelectNodes("chummer/powers/power[" + strFilter + "]");
            }
            else
            {
                objXmlPowerList = _objXmlDocument.SelectNodes("/chummer/powers/power[" + _objCharacter.Options.BookXPath() + "]");
            }
            foreach (XmlNode objXmlPower in objXmlPowerList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlPower["name"].InnerText;
                if (objXmlPower["translate"] != null)
                {
                    objItem.Name = objXmlPower["translate"].InnerText;
                }
                else
                {
                    objItem.Name = objXmlPower["name"].InnerText;
                }
                lstPower.Add(objItem);
            }
            SortListItem objSort = new SortListItem();

            lstPower.Sort(objSort.Compare);
            lstPowers.BeginUpdate();
            lstPowers.DataSource    = null;
            lstPowers.ValueMember   = "Value";
            lstPowers.DisplayMember = "Name";
            lstPowers.DataSource    = lstPower;
            lstPowers.EndUpdate();
        }
Esempio n. 20
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            if (txtSearch.Text == "")
            {
                cboCategory_SelectedIndexChanged(sender, e);
                return;
            }

            string strCategoryFilter = "";

            foreach (object objListItem in cboCategory.Items)
            {
                ListItem objItem = (ListItem)objListItem;
                if (objItem.Value != "")
                {
                    strCategoryFilter += "category = \"" + objItem.Value + "\" or ";
                }
            }

            // Treat everything as being uppercase so the search is case-insensitive.
            string strSearch = "/chummer/armors/armor[(" + _objCharacter.Options.BookXPath() + ") and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))";

            if (strCategoryFilter != "")
            {
                strSearch += " and (" + strCategoryFilter + ")";
            }
            // Remove the trailing " or )";
            if (strSearch.EndsWith(" or )"))
            {
                strSearch = strSearch.Substring(0, strSearch.Length - 4) + ")";
            }
            strSearch += "]";

            XmlNodeList     objXmlArmorList = _objXmlDocument.SelectNodes(strSearch);
            List <ListItem> lstArmors       = new List <ListItem>();

            foreach (XmlNode objXmlArmor in objXmlArmorList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlArmor["name"].InnerText;
                objItem.Name  = objXmlArmor["translate"]?.InnerText ?? objXmlArmor["name"].InnerText;

                try
                {
                    objItem.Name += " [" + _lstCategory.Find(objFind => objFind.Value == objXmlArmor["category"].InnerText).Name + "]";
                    lstArmors.Add(objItem);
                }
                catch
                {
                }
            }
            SortListItem objSort = new SortListItem();

            lstArmors.Sort(objSort.Compare);
            lstArmor.DataSource    = null;
            lstArmor.ValueMember   = "Value";
            lstArmor.DisplayMember = "Name";
            lstArmor.DataSource    = lstArmors;
        }
Esempio n. 21
0
        private void frmSelectMartialArt_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith("["))
                {
                    objLabel.Text = string.Empty;
                }
            }

            XmlNodeList     objArtList;
            List <ListItem> lstMartialArt = new List <ListItem>();

            // Load the Martial Arts information.
            _objXmlDocument = XmlManager.Instance.Load("martialarts.xml");

            // Populate the Martial Arts list.
            if (string.IsNullOrEmpty(_strForcedValue))
            {
                objArtList = _objXmlDocument.SelectNodes("/chummer/martialarts/martialart[" + _objCharacter.Options.BookXPath() + "]");
            }
            else
            {
                objArtList = _objXmlDocument.SelectNodes("/chummer/martialarts/martialart[name = \"" + _strForcedValue + "\"]");
            }
            foreach (XmlNode objXmlArt in objArtList)
            {
                XmlNode objXmlQuality = objXmlArt["quality"];
                if ((_blnShowQualities && objXmlQuality != null) || (!_blnShowQualities && objXmlQuality == null))
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlArt["name"].InnerText;
                    if (objXmlArt["translate"] != null)
                    {
                        objItem.Name = objXmlArt["translate"].InnerText;
                    }
                    else
                    {
                        objItem.Name = objXmlArt["name"].InnerText;
                    }
                    lstMartialArt.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();

            lstMartialArt.Sort(objSort.Compare);
            lstMartialArts.BeginUpdate();
            lstMartialArts.DataSource    = null;
            lstMartialArts.ValueMember   = "Value";
            lstMartialArts.DisplayMember = "Name";
            lstMartialArts.DataSource    = lstMartialArt;

            if (lstMartialArts.Items.Count == 1)
            {
                lstMartialArts.SelectedIndex = 0;
                AcceptForm();
            }
            lstMartialArts.EndUpdate();
        }
Esempio n. 22
0
        /// <summary>
        /// Build the list of Metamagics.
        /// </summary>
        private void BuildMetamagicList()
        {
            XmlNodeList     objXmlMetamagicList;
            List <ListItem> lstMetamagics = new List <ListItem>();

            // If the character has MAG enabled, filter the list based on Adept/Magician availability.
            if (_objCharacter.MAGEnabled)
            {
                if (_objCharacter.MagicianEnabled && !_objCharacter.AdeptEnabled)
                {
                    objXmlMetamagicList = _objXmlDocument.SelectNodes("/chummer/" + _strRoot + "/" + _strNode + "[magician = 'yes' and (" + _objCharacter.Options.BookXPath() + ")]");
                }
                else if (!_objCharacter.MagicianEnabled && _objCharacter.AdeptEnabled)
                {
                    objXmlMetamagicList = _objXmlDocument.SelectNodes("/chummer/" + _strRoot + "/" + _strNode + "[adept = 'yes' and (" + _objCharacter.Options.BookXPath() + ")]");
                }
                else
                {
                    objXmlMetamagicList = _objXmlDocument.SelectNodes("/chummer/" + _strRoot + "/" + _strNode + "[" + _objCharacter.Options.BookXPath() + "]");
                }
            }
            else
            {
                objXmlMetamagicList = _objXmlDocument.SelectNodes("/chummer/" + _strRoot + "/" + _strNode + "[" + _objCharacter.Options.BookXPath() + "]");
            }
            string s = LanguageManager.GetString(_strNode == "echo" ? "String_Echo" : "String_Metamagic");

            if (objXmlMetamagicList != null)
            {
                foreach (XmlNode objXmlMetamagic in objXmlMetamagicList)
                {
                    bool add = !chkLimitList.Checked ||
                               (chkLimitList.Checked &&
                                Backend.Shared_Methods.SelectionShared.RequirementsMet(objXmlMetamagic, false, _objCharacter,
                                                                                       _objMetatypeDocument, _objCritterDocument, _objQualityDocument, string.Empty, s));
                    if (!add)
                    {
                        continue;
                    }
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlMetamagic["name"]?.InnerText;
                    objItem.Name  = objXmlMetamagic["translate"]?.InnerText ?? objItem.Value;
                    lstMetamagics.Add(objItem);
                }
            }
            else
            {
                Utils.BreakIfDebug();
            }
            SortListItem objSort = new SortListItem();

            lstMetamagics.Sort(objSort.Compare);
            lstMetamagic.BeginUpdate();
            lstMetamagic.DataSource    = null;
            lstMetamagic.ValueMember   = "Value";
            lstMetamagic.DisplayMember = "Name";
            lstMetamagic.DataSource    = lstMetamagics;
            lstMetamagic.EndUpdate();
        }
Esempio n. 23
0
        private void frmSelectSkillGroup_Load(object sender, EventArgs e)
        {
            List <ListItem> lstGroups = new List <ListItem>();

            if (string.IsNullOrEmpty(_strForceValue))
            {
                // Build the list of Skill Groups found in the Skills file.
                XmlNodeList objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skillgroups/name");
                foreach (XmlNode objXmlSkill in objXmlSkillList)
                {
                    bool blnAdd = true;
                    if (!string.IsNullOrEmpty(_strExcludeCategory))
                    {
                        blnAdd = false;
                        string[] strExcludes = _strExcludeCategory.Split(',');
                        string   strExclude  = string.Empty;
                        for (int i = 0; i <= strExcludes.Length - 1; i++)
                        {
                            strExclude += "category != \"" + strExcludes[i].Trim() + "\" and ";
                        }
                        // Remove the trailing " and ";
                        strExclude = strExclude.Substring(0, strExclude.Length - 5);

                        XmlNodeList objXmlNodeList = _objXmlDocument.SelectNodes("/chummer/skills/skill[" + strExclude + " and skillgroup = \"" + objXmlSkill.InnerText + "\"]");
                        if (objXmlNodeList != null)
                        {
                            blnAdd = objXmlNodeList.Count > 0;
                        }
                    }

                    if (blnAdd)
                    {
                        string strInnerText = objXmlSkill.InnerText;
                        lstGroups.Add(new ListItem(strInnerText, objXmlSkill.Attributes?["translate"]?.InnerText ?? strInnerText));
                    }
                }
            }
            else
            {
                lstGroups.Add(new ListItem(_strForceValue, _strForceValue));
            }
            SortListItem objSort = new SortListItem();

            lstGroups.Sort(objSort.Compare);
            cboSkillGroup.BeginUpdate();
            cboSkillGroup.ValueMember   = "Value";
            cboSkillGroup.DisplayMember = "Name";
            cboSkillGroup.DataSource    = lstGroups;
            cboSkillGroup.EndUpdate();

            // Select the first Skill in the list.
            cboSkillGroup.SelectedIndex = 0;

            if (cboSkillGroup.Items.Count == 1)
            {
                cmdOK_Click(sender, e);
            }
        }
Esempio n. 24
0
        private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtSearch.Text))
            {
                txtSearch_TextChanged(sender, e);
                return;
            }
            // Update the list of Vehicles based on the selected Category.
            List <ListItem> lstVehicles = new List <ListItem>();

            string strSelectedCategoryPath = string.Empty;

            // If category selected is "Show All", we show all items regardless of category, otherwise we set the category string to filter for the selected category
            if (cboCategory.SelectedValue?.ToString() != "Show All")
            {
                strSelectedCategoryPath = "category = \"" + cboCategory.SelectedValue + "\" and ";
            }
            else
            {
                foreach (object objListItem in cboCategory.Items)
                {
                    ListItem objItem = (ListItem)objListItem;
                    if (!string.IsNullOrEmpty(objItem.Value))
                    {
                        strSelectedCategoryPath += "category = \"" + objItem.Value + "\" or ";
                    }
                }
                if (!string.IsNullOrEmpty(strSelectedCategoryPath))
                {
                    // Cut off the trailing " or " and replace it with a trailing "and"
                    strSelectedCategoryPath = "(" + strSelectedCategoryPath.Substring(0, strSelectedCategoryPath.Length - 4) + ") and ";
                }
            }
            // Retrieve the list of Vehicles for the selected Category.
            XmlNodeList objXmlVehicleList = _objXmlDocument.SelectNodes("/chummer/vehicles/vehicle[" + strSelectedCategoryPath + "(" + _objCharacter.Options.BookXPath() + ")]");

            foreach (XmlNode objXmlVehicle in objXmlVehicleList)
            {
                if (Backend.Shared_Methods.SelectionShared.CheckAvailRestriction(objXmlVehicle, _objCharacter, chkHideOverAvailLimit.Checked))
                {
                    ListItem objItem = new ListItem {
                        Value = objXmlVehicle["name"]?.InnerText
                    };
                    objItem.Name = objXmlVehicle["translate"]?.InnerText ?? objItem.Value;
                    lstVehicles.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();

            lstVehicles.Sort(objSort.Compare);
            lstVehicle.BeginUpdate();
            lstVehicle.DataSource    = null;
            lstVehicle.ValueMember   = "Value";
            lstVehicle.DisplayMember = "Name";
            lstVehicle.DataSource    = lstVehicles;
            lstVehicle.EndUpdate();
        }
Esempio n. 25
0
        /// <summary>
        /// Build the list of Metamagics.
        /// </summary>
        private void BuildList()
        {
            XmlNodeList     objXmlMetamagicList;
            List <ListItem> lstArts = new List <ListItem>();

            // Load the Metamagic information.
            switch (_objMode)
            {
            case Mode.Art:
                _objXmlDocument     = XmlManager.Instance.Load("metamagic.xml");
                objXmlMetamagicList = _objXmlDocument.SelectNodes("/chummer/" + _strRoot + "/" + _strNode + "[" + _objCharacter.Options.BookXPath() + "]");
                break;

            case Mode.Enhancement:
                _objXmlDocument     = XmlManager.Instance.Load("powers.xml");
                objXmlMetamagicList = _objXmlDocument.SelectNodes("/chummer/" + _strRoot + "/" + _strNode + "[" + _objCharacter.Options.BookXPath() + "]");
                break;

            case Mode.Enchantment:
            case Mode.Ritual:
                _objXmlDocument     = XmlManager.Instance.Load("spells.xml");
                objXmlMetamagicList = _objXmlDocument.SelectNodes("/chummer/" + _strRoot + "/" + _strNode + "[category = '" + _strCategory + "' and (" + _objCharacter.Options.BookXPath() + ")]");
                break;

            default:
                _objXmlDocument     = XmlManager.Instance.Load("spells.xml");
                objXmlMetamagicList = _objXmlDocument.SelectNodes("/chummer/" + _strRoot + "/" + _strNode + "[category = '" + _strCategory + "' and (" + _objCharacter.Options.BookXPath() + ")]");
                break;
            }

            foreach (XmlNode objXmlMetamagic in objXmlMetamagicList)
            {
                bool add = (!chkLimitList.Checked ||
                            (chkLimitList.Checked &&
                             Backend.Shared_Methods.SelectionShared.RequirementsMet(objXmlMetamagic, false,
                                                                                    _objCharacter, null,
                                                                                    null, _objQualityDocument, "", _strLocalName)));
                if (!add)
                {
                    continue;
                }
                ListItem objItem = new ListItem();
                objItem.Value = objXmlMetamagic["name"].InnerText;
                objItem.Name  = objXmlMetamagic["translate"]?.InnerText ?? objXmlMetamagic["name"].InnerText;
                lstArts.Add(objItem);
            }
            SortListItem objSort = new SortListItem();

            lstArts.Sort(objSort.Compare);
            lstArt.BeginUpdate();
            lstArt.DataSource    = null;
            lstArt.ValueMember   = "Value";
            lstArt.DisplayMember = "Name";
            lstArt.DataSource    = lstArts;
            lstArt.EndUpdate();
        }
Esempio n. 26
0
        private void frmSelectArmorMod_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in this.Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith("["))
                {
                    objLabel.Text = "";
                }
            }

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

            // Load the Armor information.
            _objXmlDocument = XmlManager.Instance.Load("armor.xml");

            // Populate the Mods list.
            string[] strAllowed = _strAllowedCategories.Split(',');
            string   strMount   = "";

            foreach (string strAllowedMount in strAllowed)
            {
                if (strAllowedMount != "")
                {
                    strMount += "category = \"" + strAllowedMount + "\" or ";
                }
            }
            strMount += "category = \"General\"";
            XmlNodeList objXmlModList = _objXmlDocument.SelectNodes("/chummer/mods/mod[" + strMount + " and (" + _objCharacter.Options.BookXPath() + ")]");

            foreach (XmlNode objXmlMod in objXmlModList)
            {
                bool blnHide = (objXmlMod["hide"] != null);
                if (!blnHide)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlMod["name"].InnerText;
                    if (objXmlMod["translate"] != null)
                    {
                        objItem.Name = objXmlMod["translate"].InnerText;
                    }
                    else
                    {
                        objItem.Name = objXmlMod["name"].InnerText;
                    }
                    lstMods.Add(objItem);
                }
            }
            chkBlackMarketDiscount.Visible = _objCharacter.BlackMarketDiscount;
            SortListItem objSort = new SortListItem();

            lstMods.Sort(objSort.Compare);
            lstMod.ValueMember   = "Value";
            lstMod.DisplayMember = "Name";
            lstMod.DataSource    = lstMods;
        }
Esempio n. 27
0
        private void frmSelectWeaponAccessory_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in this.Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith("["))
                {
                    objLabel.Text = "";
                }
            }

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

            // Load the Weapon information.
            _objXmlDocument = XmlManager.Instance.Load("weapons.xml");

            // Populate the Accessory list.
            string[] strAllowed = _strAllowedMounts.Split('/');
            string   strMount   = "";

            foreach (string strAllowedMount in strAllowed)
            {
                if (strAllowedMount != "")
                {
                    strMount += "contains(mount, \"" + strAllowedMount + "\") or ";
                }
            }
            strMount += "contains(mount, \"Internal\") or contains(mount, \"None\") or ";
            strMount += "mount = \"\"";
            XmlNodeList objXmlAccessoryList = _objXmlDocument.SelectNodes("/chummer/accessories/accessory[(" + strMount + ") and (" + _objCharacter.Options.BookXPath() + ")]");

            foreach (XmlNode objXmlAccessory in objXmlAccessoryList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlAccessory["name"].InnerText;
                if (objXmlAccessory["translate"] != null)
                {
                    objItem.Name = objXmlAccessory["translate"].InnerText;
                }
                else
                {
                    objItem.Name = objXmlAccessory["name"].InnerText;
                }
                lstAccessories.Add(objItem);
            }

            chkBlackMarketDiscount.Visible = _objCharacter.BlackMarketDiscount;

            SortListItem objSort = new SortListItem();

            lstAccessories.Sort(objSort.Compare);
            lstAccessory.ValueMember   = "Value";
            lstAccessory.DisplayMember = "Name";
            lstAccessory.DataSource    = lstAccessories;
        }
Esempio n. 28
0
        private void PopulateLanguageList()
        {
            List <ListItem> lstLanguages          = new List <ListItem>();
            string          languageDirectoryPath = Path.Combine(Application.StartupPath, "lang");

            string[] languageFilePaths = Directory.GetFiles(languageDirectoryPath, "*.xml");

            foreach (string filePath in languageFilePaths)
            {
                XmlDocument xmlDocument = new XmlDocument();

                try
                {
                    xmlDocument.Load(filePath);
                }
                catch (XmlException)
                {
                    continue;
                }

                XmlNode node = xmlDocument.SelectSingleNode("/chummer/name");

                if (node == null)
                {
                    continue;
                }

                string languageName = node.InnerText;

                if (GetXslFilesFromLocalDirectory(Path.GetFileNameWithoutExtension(filePath).ToString()).Count > 0)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = Path.GetFileNameWithoutExtension(filePath);
                    objItem.Name  = languageName;

                    lstLanguages.Add(objItem);
                }
            }

            SortListItem objSort = new SortListItem();

            lstLanguages.Sort(objSort.Compare);

            cboLanguage.BeginUpdate();
            cboLanguage.ValueMember   = "Value";
            cboLanguage.DisplayMember = "Name";
            cboLanguage.DataSource    = lstLanguages;
            cboLanguage.SelectedValue = GlobalOptions.Language;
            if (cboLanguage.SelectedIndex == -1)
            {
                cboLanguage.SelectedValue = GlobalOptions.DefaultLanguage;
            }
            cboLanguage.EndUpdate();
        }
Esempio n. 29
0
        /// <summary>
        ///
        /// </summary>
        private void BuildModList()
        {
            List <ListItem> lstMods = new List <ListItem>();

            // Load the Armor information.
            _objXmlDocument = XmlManager.Instance.Load("armor.xml");

            // Populate the Mods list.
            string[] strAllowed = _strAllowedCategories.Split(',');
            string   strMount   = string.Empty;

            for (int i = 0; i < strAllowed.Length; i++)
            {
                if (!string.IsNullOrEmpty(strAllowed[i]))
                {
                    strMount += "category = \"" + strAllowed[i] + "\"";
                }
                if (i < strAllowed.Length - 1 || !_blnExcludeGeneralCategory)
                {
                    strMount += " or ";
                }
            }
            if (!_blnExcludeGeneralCategory)
            {
                strMount += "category = \"General\"";
            }
            XmlNodeList objXmlModList = _objXmlDocument.SelectNodes("/chummer/mods/mod[" + strMount + " and (" + _objCharacter.Options.BookXPath() + ")]");

            foreach (XmlNode objXmlMod in objXmlModList)
            {
                bool blnHide = (objXmlMod["hide"] != null);
                if (!blnHide)
                {
                    if (Backend.Shared_Methods.SelectionShared.CheckAvailRestriction(objXmlMod, _objCharacter,
                                                                                     chkHideOverAvailLimit.Checked, Convert.ToInt32(nudRating.Value)))
                    {
                        ListItem objItem = new ListItem
                        {
                            Value = objXmlMod["name"].InnerText,
                            Name  = objXmlMod["translate"]?.InnerText ?? objXmlMod["name"].InnerText
                        };
                        lstMods.Add(objItem);
                    }
                }
            }
            SortListItem objSort = new SortListItem();

            lstMods.Sort(objSort.Compare);
            lstMod.BeginUpdate();
            lstMod.ValueMember   = "Value";
            lstMod.DisplayMember = "Name";
            lstMod.DataSource    = lstMods;
            lstMod.EndUpdate();
        }
Esempio n. 30
0
        private void frmSelectMartialArt_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith('['))
                {
                    objLabel.Text = string.Empty;
                }
            }

            XmlNodeList     objArtList    = null;
            List <ListItem> lstMartialArt = new List <ListItem>();

            // Populate the Martial Arts list.
            if (!string.IsNullOrEmpty(_strForcedValue))
            {
                objArtList = _objXmlDocument.SelectNodes("/chummer/martialarts/martialart[name = \"" + _strForcedValue + "\"]");
            }
            if (objArtList == null || objArtList.Count == 0)
            {
                objArtList = _objXmlDocument.SelectNodes("/chummer/martialarts/martialart[" + _objCharacter.Options.BookXPath() + "]");
            }
            foreach (XmlNode objXmlArt in objArtList)
            {
                XmlNode objXmlQuality = objXmlArt["quality"];
                if (_blnShowQualities != (objXmlQuality != null))
                {
                    continue;
                }
                if (Backend.Shared_Methods.SelectionShared.RequirementsMet(objXmlArt, false, _objCharacter))
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlArt["name"].InnerText;
                    objItem.Name  = objXmlArt["translate"]?.InnerText ?? objXmlArt["name"].InnerText;
                    lstMartialArt.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();

            lstMartialArt.Sort(objSort.Compare);
            lstMartialArts.BeginUpdate();
            lstMartialArts.DataSource    = null;
            lstMartialArts.ValueMember   = "Value";
            lstMartialArts.DisplayMember = "Name";
            lstMartialArts.DataSource    = lstMartialArt;

            if (lstMartialArts.Items.Count == 1)
            {
                lstMartialArts.SelectedIndex = 0;
                AcceptForm();
            }
            lstMartialArts.EndUpdate();
        }
Esempio n. 31
0
        private void frmCreateImprovement_Load(object sender, EventArgs e)
        {
            List <ListItem> lstTypes = new List <ListItem>();

            _objDocument = XmlManager.Instance.Load("improvements.xml");

            // Populate the Improvement Type list.
            XmlNodeList objXmlImprovementList = _objDocument.SelectNodes("/chummer/improvements/improvement");

            if (objXmlImprovementList != null)
            {
                lstTypes.AddRange(from XmlNode objXmlImprovement in objXmlImprovementList
                                  select new ListItem
                {
                    Value = objXmlImprovement["id"]?.InnerText, Name = objXmlImprovement["translate"]?.InnerText ?? objXmlImprovement["name"]?.InnerText
                });
            }

            SortListItem objSort = new SortListItem();

            lstTypes.Sort(objSort.Compare);
            cboImprovemetType.BeginUpdate();
            cboImprovemetType.ValueMember   = "Value";
            cboImprovemetType.DisplayMember = "Name";
            cboImprovemetType.DataSource    = lstTypes;

            // Load the information from the passed Improvement if one has been given.
            if (_objEditImprovement != null)
            {
                cboImprovemetType.SelectedValue = _objEditImprovement.CustomId;
                txtName.Text = _objEditImprovement.CustomName;
                if (nudMax.Visible)
                {
                    nudMax.Value = _objEditImprovement.Maximum;
                }
                if (nudMin.Visible)
                {
                    nudMin.Value = _objEditImprovement.Minimum;
                }
                if (nudVal.Visible)
                {
                    // specificattribute stores the Value in Augmented instead.
                    nudVal.Value = _objEditImprovement.CustomId == "specificattribute" ? _objEditImprovement.Augmented : _objEditImprovement.Value;
                }
                chkApplyToRating.Checked = chkApplyToRating.Visible && _objEditImprovement.AddToRating;
                if (txtSelect.Visible)
                {
                    txtSelect.Text = _objEditImprovement.ImprovedName;
                }
            }
            cboImprovemetType.EndUpdate();
        }
        private void frmSelectMartialArtAdvantage_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith('['))
                {
                    objLabel.Text = string.Empty;
                }
            }

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

            // Populate the Martial Art Advantage list.
            XmlNode objMartialArtNode = _objXmlDocument.SelectSingleNode("/chummer/martialarts/martialart[(" + _objCharacter.Options.BookXPath() + ") and name = \"" + _strMartialArt + "\"]");

            if (objMartialArtNode["alltechniques"] != null)
            {
                objMartialArtNode = _objXmlDocument.SelectSingleNode("/chummer");
            }
            XmlNodeList objXmlAdvantageList = objMartialArtNode.SelectNodes("techniques/technique");

            foreach (XmlNode objXmlAdvantage in objXmlAdvantageList)
            {
                string strAdvantageName = objXmlAdvantage["name"].InnerText;
                foreach (MartialArt objMartialArt in _objCharacter.MartialArts.Where(objMartialArt => objMartialArt.Name == _strMartialArt))
                {
                    if (objMartialArt.Advantages.Any(advantage => advantage.Name == strAdvantageName))
                    {
                        goto NotNewAdvantage;
                    }
                }

                if (Backend.Shared_Methods.SelectionShared.RequirementsMet(objXmlAdvantage, false, _objCharacter))
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = strAdvantageName;
                    objItem.Name  = objXmlAdvantage.Attributes?["translate"]?.InnerText ?? strAdvantageName;
                    lstAdvantage.Add(objItem);
                }
                NotNewAdvantage :;
            }
            SortListItem objSort = new SortListItem();

            lstAdvantage.Sort(objSort.Compare);
            lstAdvantages.BeginUpdate();
            lstAdvantages.DataSource    = null;
            lstAdvantages.ValueMember   = "Value";
            lstAdvantages.DisplayMember = "Name";
            lstAdvantages.DataSource    = lstAdvantage;
            lstAdvantages.EndUpdate();
        }
Esempio n. 33
0
        private void frmSelectProgram_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith('['))
                {
                    objLabel.Text = string.Empty;
                }
            }

            // Populate the Category list.
            XmlNodeList objXmlNodeList = _objXmlDocument.SelectNodes("/chummer/categories/category");

            foreach (XmlNode objXmlCategory in objXmlNodeList)
            {
                string strInnerText = objXmlCategory.InnerText;
                if (_blnInherentProgram && strInnerText != "Common Programs" && strInnerText != "Hacking Programs")
                {
                    continue;
                }
                if (!_blnAdvancedProgramAllowed && strInnerText == "Advanced Programs")
                {
                    continue;
                }
                // Make sure it is not already in the Category list.
                if (!_lstCategory.Any(objItem => objItem.Value == strInnerText))
                {
                    _lstCategory.Add(new ListItem(strInnerText, objXmlCategory.Attributes?["translate"]?.InnerText ?? strInnerText));
                }
            }
            SortListItem objSort = new SortListItem();

            _lstCategory.Sort(objSort.Compare);

            if (_lstCategory.Count > 0)
            {
                _lstCategory.Insert(0, new ListItem("Show All", LanguageManager.GetString("String_ShowAll")));
            }

            cboCategory.BeginUpdate();
            cboCategory.DataSource    = null;
            cboCategory.ValueMember   = "Value";
            cboCategory.DisplayMember = "Name";
            cboCategory.DataSource    = _lstCategory;
            cboCategory.EndUpdate();

            // Select the first Category in the list.
            cboCategory.SelectedIndex = 0;

            txtSearch.Text = string.Empty;
        }
        private void frmSelectProgramOption_Load(object sender, EventArgs e)
        {
            List <ListItem> lstOption = new List <ListItem>();

            // Load the Programs information.
            _objXmlDocument = XmlManager.Instance.Load("complexforms.xml");

            // Populate the Program list.
            XmlNodeList objXmlOptionList = _objXmlDocument.SelectNodes("/chummer/options/option[" + _objCharacter.Options.BookXPath() + "]");

            foreach (XmlNode objXmlOption in objXmlOptionList)
            {
                bool blnAdd = true;
                // If the Option has Category requirements, make sure they are met before adding the item to the list.
                if (objXmlOption["programtypes"] != null)
                {
                    blnAdd = false;
                    foreach (XmlNode objXmlCategory in objXmlOption.SelectNodes("programtypes/programtype"))
                    {
                        if (objXmlCategory.InnerText == _strProgramCategory)
                        {
                            blnAdd = true;
                        }
                    }
                }

                if (blnAdd)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlOption["name"].InnerText;
                    if (objXmlOption["translate"] != null)
                    {
                        objItem.Name = objXmlOption["translate"].InnerText;
                    }
                    else
                    {
                        objItem.Name = objXmlOption["name"].InnerText;
                    }
                    lstOption.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();

            lstOption.Sort(objSort.Compare);
            lstOptions.BeginUpdate();
            lstOptions.ValueMember   = "Value";
            lstOptions.DisplayMember = "Name";
            lstOptions.DataSource    = lstOption;
            lstOptions.EndUpdate();
        }
Esempio n. 35
0
		private void frmCreateImprovement_Load(object sender, EventArgs e)
		{
			List<ListItem> lstTypes = new List<ListItem>();
			_objDocument = XmlManager.Instance.Load("improvements.xml");

			// Populate the Improvement Type list.
			XmlNodeList objXmlImprovementList = _objDocument.SelectNodes("/chummer/improvements/improvement");
			foreach (XmlNode objXmlImprovement in objXmlImprovementList)
			{
				ListItem objItem = new ListItem();
				objItem.Value = objXmlImprovement["id"].InnerText;
				if (objXmlImprovement["translate"] != null)
					objItem.Name = objXmlImprovement["translate"].InnerText;
				else
					objItem.Name = objXmlImprovement["name"].InnerText;
				lstTypes.Add(objItem);
			}

			SortListItem objSort = new SortListItem();
			lstTypes.Sort(objSort.Compare);
			cboImprovemetType.ValueMember = "Value";
			cboImprovemetType.DisplayMember = "Name";
			cboImprovemetType.DataSource = lstTypes;

			// Load the information from the passed Improvement if one has been given.
			if (_objEditImprovement != null)
			{
				cboImprovemetType.SelectedValue = _objEditImprovement.CustomId;
				txtName.Text = _objEditImprovement.CustomName;
				if (nudMax.Visible)
					nudMax.Value = _objEditImprovement.Maximum;
				if (nudMin.Visible)
					nudMin.Value = _objEditImprovement.Minimum;
				if (nudVal.Visible)
				{
					// specificattribute stores the Value in Augmented instead.
					if (_objEditImprovement.CustomId == "specificattribute")
						nudVal.Value = _objEditImprovement.Augmented;
					else
						nudVal.Value = _objEditImprovement.Value;
				}
				if (chkApplyToRating.Visible)
					chkApplyToRating.Checked = _objEditImprovement.AddToRating;
				else
					chkApplyToRating.Checked = false;
				if (txtSelect.Visible)
					txtSelect.Text = _objEditImprovement.ImprovedName;
			}
		}
		private void frmSelectMartialArtAdvantage_Load(object sender, EventArgs e)
		{
			foreach (Label objLabel in this.Controls.OfType<Label>())
			{
				if (objLabel.Text.StartsWith("["))
					objLabel.Text = "";
			}

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

			// Load the Martial Art information.
			_objXmlDocument = XmlManager.Instance.Load("martialarts.xml");

			// Populate the Martial Art Advantage list.
			XmlNodeList objXmlAdvantageList = _objXmlDocument.SelectNodes("/chummer/martialarts/martialart[(" + _objCharacter.Options.BookXPath() + ") and name = \"" + _strMartialArt + "\"]/techniques/technique");
			foreach (XmlNode objXmlAdvantage in objXmlAdvantageList)
			{
				ListItem objItem = new ListItem();
				objItem.Value = objXmlAdvantage["name"].InnerText;
				if (objXmlAdvantage.Attributes["translate"] != null)
					objItem.Name = objXmlAdvantage.Attributes["translate"].InnerText;
				else
					objItem.Name = objXmlAdvantage["name"].InnerText;

                bool blnIsNew = true;
                foreach (MartialArt objMartialArt in _objCharacter.MartialArts)
                {
                    if (objMartialArt.Name == _strMartialArt)
                    {
                        foreach (MartialArtAdvantage objMartialArtAdvantage in objMartialArt.Advantages)
                        {
                            if (objMartialArtAdvantage.Name == objItem.Value)
                            {
                                blnIsNew = false;
                            }
                        }
                    }
                }

                if (blnIsNew)
				    lstAdvantage.Add(objItem);
            }
			SortListItem objSort = new SortListItem();
			lstAdvantage.Sort(objSort.Compare);
			lstAdvantages.DataSource = null;
			lstAdvantages.ValueMember = "Value";
			lstAdvantages.DisplayMember = "Name";
			lstAdvantages.DataSource = lstAdvantage;
		}
Esempio n. 37
0
        private void frmSelectPower_Load(object sender, EventArgs e)
        {
			foreach (Label objLabel in this.Controls.OfType<Label>())
			{
				if (objLabel.Text.StartsWith("["))
					objLabel.Text = "";
			}

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

            // Load the Powers information.
			_objXmlDocument = XmlManager.Instance.Load("powers.xml");

			// Populate the Powers list.
			XmlNodeList objXmlPowerList;
			
				if (_strLimitToPowers != "")
				{
					string strFilter = "(";
					string[] strValue = _strLimitToPowers.Split(',');
					foreach (string strPower in strValue)
						strFilter += "name = \"" + strPower.Trim() + "\" or ";
					// Remove the trailing " or ".
					strFilter = strFilter.Substring(0, strFilter.Length - 4);
					strFilter += ")";
					objXmlPowerList = _objXmlDocument.SelectNodes("chummer/powers/power[" + strFilter + "]");
				}
				else
				{
					objXmlPowerList = _objXmlDocument.SelectNodes("/chummer/powers/power[" + _objCharacter.Options.BookXPath() + "]");
				}
			foreach (XmlNode objXmlPower in objXmlPowerList)
			{
				ListItem objItem = new ListItem();
				objItem.Value = objXmlPower["name"].InnerText;
				if (objXmlPower["translate"] != null)
					objItem.Name = objXmlPower["translate"].InnerText;
				else
					objItem.Name = objXmlPower["name"].InnerText;
				lstPower.Add(objItem);
			}
			SortListItem objSort = new SortListItem();
			lstPower.Sort(objSort.Compare);
			lstPowers.DataSource = null;
			lstPowers.ValueMember = "Value";
			lstPowers.DisplayMember = "Name";
			lstPowers.DataSource = lstPower;
        }
Esempio n. 38
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSearch.Text))
            {
                cboCategory_SelectedIndexChanged(sender, e);
                return;
            }

            // Treat everything as being uppercase so the search is case-insensitive.
            string strSearch = "/chummer/vehicles/vehicle[(" + _objCharacter.Options.BookXPath() + ") and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))]";

            XmlNodeList     objXmlVehicleList = _objXmlDocument.SelectNodes(strSearch);
            List <ListItem> lstVehicles       = new List <ListItem>();

            foreach (XmlNode objXmlVehicle in objXmlVehicleList)
            {
                if (objXmlVehicle["hidden"] != null)
                {
                    continue;
                }
                if (Backend.Shared_Methods.SelectionShared.CheckAvailRestriction(objXmlVehicle, _objCharacter))
                {
                    ListItem objItem = new ListItem {
                        Value = objXmlVehicle["name"]?.InnerText
                    };
                    objItem.Name = objXmlVehicle["translate"]?.InnerText ?? objItem.Value;

                    if (objXmlVehicle["category"] != null)
                    {
                        ListItem objFoundItem = _lstCategory.Find(objFind => objFind.Value == objXmlVehicle["category"].InnerText);
                        if (objFoundItem != null)
                        {
                            objItem.Name += " [" + objFoundItem.Name + "]";
                        }
                    }
                    lstVehicles.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();

            lstVehicles.Sort(objSort.Compare);
            lstVehicle.BeginUpdate();
            lstVehicle.DataSource    = null;
            lstVehicle.ValueMember   = "Value";
            lstVehicle.DisplayMember = "Name";
            lstVehicle.DataSource    = lstVehicles;
            lstVehicle.EndUpdate();
        }
Esempio n. 39
0
		private void frmSelectMartialArt_Load(object sender, EventArgs e)
		{
			foreach (Label objLabel in this.Controls.OfType<Label>())
			{
				if (objLabel.Text.StartsWith("["))
					objLabel.Text = "";
			}

			XmlNodeList objArtList;
			List<ListItem> lstMartialArt = new List<ListItem>();

			// Load the Martial Arts information.
			_objXmlDocument = XmlManager.Instance.Load("martialarts.xml");

			// Populate the Martial Arts list.
			if (_strForcedValue == "")
				objArtList = _objXmlDocument.SelectNodes("/chummer/martialarts/martialart[" + _objCharacter.Options.BookXPath() + "]");
			else
				objArtList = _objXmlDocument.SelectNodes("/chummer/martialarts/martialart[name = \"" + _strForcedValue + "\"]");
			foreach (XmlNode objXmlArt in objArtList)
			{
                XmlNode objXmlQuality = objXmlArt["quality"];
                if ((_blnShowQualities && objXmlQuality != null) || (!_blnShowQualities && objXmlQuality == null))
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlArt["name"].InnerText;
                    if (objXmlArt["translate"] != null)
                        objItem.Name = objXmlArt["translate"].InnerText;
                    else
                        objItem.Name = objXmlArt["name"].InnerText;
                    lstMartialArt.Add(objItem);
                }
			}
			SortListItem objSort = new SortListItem();
			lstMartialArt.Sort(objSort.Compare);
			lstMartialArts.DataSource = null;
			lstMartialArts.ValueMember = "Value";
			lstMartialArts.DisplayMember = "Name";
			lstMartialArts.DataSource = lstMartialArt;

			if (lstMartialArts.Items.Count == 1)
			{
				lstMartialArts.SelectedIndex = 0;
				AcceptForm();
			}
		}
		private void frmSelectArmorMod_Load(object sender, EventArgs e)
		{
			foreach (Label objLabel in this.Controls.OfType<Label>())
			{
				if (objLabel.Text.StartsWith("["))
					objLabel.Text = "";
			}

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

			// Load the Armor information.
			_objXmlDocument = XmlManager.Instance.Load("armor.xml");

			// Populate the Mods list.
			string[] strAllowed = _strAllowedCategories.Split(',');
			string strMount = "";
			foreach (string strAllowedMount in strAllowed)
			{
				if (strAllowedMount != "")
					strMount += "category = \"" + strAllowedMount + "\" or ";
			}
			strMount += "category = \"General\"";
			XmlNodeList objXmlModList = _objXmlDocument.SelectNodes("/chummer/mods/mod[" + strMount + " and (" + _objCharacter.Options.BookXPath() + ")]");

			foreach (XmlNode objXmlMod in objXmlModList)
			{
                bool blnHide = (objXmlMod["hide"] != null);
                if (!blnHide)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlMod["name"].InnerText;
                    if (objXmlMod["translate"] != null)
                        objItem.Name = objXmlMod["translate"].InnerText;
                    else
                        objItem.Name = objXmlMod["name"].InnerText;
                    lstMods.Add(objItem);
                }
			}
			chkBlackMarketDiscount.Visible = _objCharacter.BlackMarketDiscount;
			SortListItem objSort = new SortListItem();
			lstMods.Sort(objSort.Compare);
			lstMod.ValueMember = "Value";
			lstMod.DisplayMember = "Name";
			lstMod.DataSource = lstMods;
		}
		private void frmSelectWeaponAccessory_Load(object sender, EventArgs e)
		{
            foreach (Label objLabel in this.Controls.OfType<Label>())
			{
				if (objLabel.Text.StartsWith("["))
					objLabel.Text = "";
			}

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

			// Load the Weapon information.
			_objXmlDocument = XmlManager.Instance.Load("weapons.xml");

			// Populate the Accessory list.
			string[] strAllowed = _strAllowedMounts.Split('/');
			string strMount = "";
			foreach (string strAllowedMount in strAllowed)
			{
				if (strAllowedMount != "")
					strMount += "contains(mount, \"" + strAllowedMount + "\") or ";
			}
			strMount += "contains(mount, \"Internal\") or contains(mount, \"None\") or ";
			strMount += "mount = \"\"";
			XmlNodeList objXmlAccessoryList = _objXmlDocument.SelectNodes("/chummer/accessories/accessory[(" + strMount + ") and (" + _objCharacter.Options.BookXPath() + ")]");
			foreach (XmlNode objXmlAccessory in objXmlAccessoryList)
			{
				ListItem objItem = new ListItem();
				objItem.Value = objXmlAccessory["name"].InnerText;
				if (objXmlAccessory["translate"] != null)
					objItem.Name = objXmlAccessory["translate"].InnerText;
				else
					objItem.Name = objXmlAccessory["name"].InnerText;
				lstAccessories.Add(objItem);
			}

			chkBlackMarketDiscount.Visible = _objCharacter.BlackMarketDiscount;

			SortListItem objSort = new SortListItem();
			lstAccessories.Sort(objSort.Compare);
			lstAccessory.ValueMember = "Value";
			lstAccessory.DisplayMember = "Name";
			lstAccessory.DataSource = lstAccessories;
		}
Esempio n. 42
0
		private void frmSelectProgramOption_Load(object sender, EventArgs e)
		{
			List<ListItem> lstOption = new List<ListItem>();

			// Load the Programs information.
            _objXmlDocument = XmlManager.Instance.Load("complexforms.xml");

			// Populate the Program list.
			XmlNodeList objXmlOptionList = _objXmlDocument.SelectNodes("/chummer/options/option[" + _objCharacter.Options.BookXPath() + "]");

			foreach (XmlNode objXmlOption in objXmlOptionList)
			{
				bool blnAdd = true;
				// If the Option has Category requirements, make sure they are met before adding the item to the list.
				if (objXmlOption["programtypes"] != null)
				{
					blnAdd = false;
					foreach (XmlNode objXmlCategory in objXmlOption.SelectNodes("programtypes/programtype"))
					{
						if (objXmlCategory.InnerText == _strProgramCategory)
							blnAdd = true;
					}
				}

				if (blnAdd)
				{
					ListItem objItem = new ListItem();
					objItem.Value = objXmlOption["name"].InnerText;
					if (objXmlOption["translate"] != null)
						objItem.Name = objXmlOption["translate"].InnerText;
					else
						objItem.Name = objXmlOption["name"].InnerText;
					lstOption.Add(objItem);
				}
			}
			SortListItem objSort = new SortListItem();
			lstOption.Sort(objSort.Compare);
			lstOptions.ValueMember = "Value";
			lstOptions.DisplayMember = "Name";
			lstOptions.DataSource = lstOption;
		}
Esempio n. 43
0
        private void tmrSearch_Tick(object sender, EventArgs e)
        {
            tmrSearch.Stop();
            tmrSearch.Enabled = false;

            if (txtSearch.Text == "")
            {
                cboCategory_SelectedIndexChanged(sender, e);
                return;
            }

            string strCategoryFilter = "";

            foreach (object objListItem in cboCategory.Items)
            {
                ListItem objItem = (ListItem)objListItem;
                if (objItem.Value != "")
                    strCategoryFilter += "category = \"" + objItem.Value + "\" or ";
            }

            // Treat everything as being uppercase so the search is case-insensitive.
            string strSearch = "/chummer/armors/armor[(" + _objCharacter.Options.BookXPath() + ") and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))";
            if (strCategoryFilter != "")
                strSearch += " and (" + strCategoryFilter + ")";
            // Remove the trailing " or )";
            if (strSearch.EndsWith(" or )"))
            {
                strSearch = strSearch.Substring(0, strSearch.Length - 4) + ")";
            }
            strSearch += "]";

            XmlNodeList objXmlArmorList = _objXmlDocument.SelectNodes(strSearch);

            if (dgvArmor.Visible)
            {
                DataTable tabArmor = new DataTable("armor");
                tabArmor.Columns.Add("ArmorName");
                tabArmor.Columns.Add("Armor");
                tabArmor.Columns["Armor"].DataType = typeof(Int32);
                tabArmor.Columns.Add("Capacity");
                tabArmor.Columns["Capacity"].DataType = typeof(Int32);
                tabArmor.Columns.Add("Avail");
                tabArmor.Columns.Add("Special");
                tabArmor.Columns.Add("Source");
                tabArmor.Columns.Add("Cost");
                tabArmor.Columns["Cost"].DataType = typeof(Int32);

                // Populate the Weapon list.
                foreach (XmlNode objXmlArmor in objXmlArmorList)
                {
                    TreeNode objNode = new TreeNode();
                    Armor objArmor = new Armor(_objCharacter);
                    objArmor.Create(objXmlArmor, objNode, null, 0, true, true);

                    string strWeaponName = objArmor.Name;
                    int intArmor = objArmor.TotalArmor;
                    int intCapacity = Convert.ToInt32(objArmor.CalculatedCapacity);
                    string strAvail = objArmor.Avail;
                    string strAccessories = "";
                    foreach (ArmorMod objMod in objArmor.ArmorMods)
                    {
                        if (strAccessories.Length > 0)
                            strAccessories += "\n";
                        strAccessories += objMod.Name;
                    }
                    foreach (Gear objGear in objArmor.Gear)
                    {
                        if (strAccessories.Length > 0)
                            strAccessories += "\n";
                        strAccessories += objGear.Name;
                    }
                    string strSource = objArmor.Source + " " + objArmor.Page;
                    int intCost = objArmor.Cost;

                    tabArmor.Rows.Add(strWeaponName, intArmor, intCapacity, strAvail, strAccessories, strSource, intCost);
                }

                DataSet set = new DataSet("armor");
                set.Tables.Add(tabArmor);

                dgvArmor.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                dgvArmor.DataSource = set;
                dgvArmor.DataMember = "armor";
            }
            else
            {
                List<ListItem> lstArmors = new List<ListItem>();
                foreach (XmlNode objXmlArmor in objXmlArmorList)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlArmor["name"].InnerText;
                    if (objXmlArmor["translate"] != null)
                        objItem.Name = objXmlArmor["translate"].InnerText;
                    else
                        objItem.Name = objXmlArmor["name"].InnerText;

                    try
                    {
                        objItem.Name += " [" + _lstCategory.Find(objFind => objFind.Value == objXmlArmor["category"].InnerText).Name + "]";
                        lstArmors.Add(objItem);
                    }
                    catch
                    {
                    }
                }
                SortListItem objSort = new SortListItem();
                lstArmors.Sort(objSort.Compare);
                lstArmor.DataSource = null;
                lstArmor.ValueMember = "Value";
                lstArmor.DisplayMember = "Name";
                lstArmor.DataSource = lstArmors;
            }
        }
Esempio n. 44
0
        private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_objMode == Mode.Bioware)
            {
                // If the window is currently showing Bioware, we may need to rebuild the Grade list since Cultured Bioware is not allowed to select Standard (Second-Hand) as as Grade.
                if (cboGrade.SelectedValue != null)
                {
                    string strSelectedValue = cboGrade.SelectedValue.ToString();
                    bool blnCultured = cboCategory.SelectedValue.ToString() == "Cultured";
                    PopulateGrades(blnCultured);
                    cboGrade.SelectedValue = strSelectedValue;
                }
                if (cboGrade.SelectedIndex == -1 && cboGrade.Items.Count > 0)
                    cboGrade.SelectedIndex = 0;
            }

            // Update the list of Cyberware based on the selected Category.
            XmlNodeList objXmlCyberwareList;
            List<ListItem> lstCyberwares = new List<ListItem>();

            if (cboCategory.SelectedValue.ToString().StartsWith("Genetech:") ||
                cboCategory.SelectedValue.ToString() == "Symbionts" ||
                cboCategory.SelectedValue.ToString() == "Genemods" ||
                _blnLockGrade)
            {
                cboGrade.Enabled = false;

            }
            else
            {
                cboGrade.Enabled = true;
            }

            if (cboCategory.SelectedValue.ToString().StartsWith("Genetech:") ||
                cboCategory.SelectedValue.ToString() == "Symbionts" ||
                cboCategory.SelectedValue.ToString() == "Genemods")
            {
                cboGrade.SelectedValue = "Standard";
            }

            // Retrieve the list of Cyberware for the selected Category.
            if (_blnShowOnlySubsystems)
                objXmlCyberwareList = _objXmlDocument.SelectNodes("/chummer/" + _strNode + "s/" + _strNode + "[category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ") and contains(capacity, \"[\")]");
            else
                objXmlCyberwareList = _objXmlDocument.SelectNodes("/chummer/" + _strNode + "s/" + _strNode + "[category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ")]");
            foreach (XmlNode objXmlCyberware in objXmlCyberwareList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlCyberware["name"].InnerText;
                if (objXmlCyberware["translate"] != null)
                    objItem.Name = objXmlCyberware["translate"].InnerText;
                else
                    objItem.Name = objXmlCyberware["name"].InnerText;
                lstCyberwares.Add(objItem);
            }
            SortListItem objSort = new SortListItem();
            lstCyberwares.Sort(objSort.Compare);
            lstCyberware.DataSource = null;
            lstCyberware.ValueMember = "Value";
            lstCyberware.DisplayMember = "Name";
            lstCyberware.DataSource = lstCyberwares;
        }
Esempio n. 45
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            if (txtSearch.Text == "")
            {
                cboCategory_SelectedIndexChanged(sender, e);
                return;
            }

            List<ListItem> lstCyberwares = new List<ListItem>();
            string strCategoryFilter = "";

            foreach (ListItem objAllowedCategory in _lstCategory)
            {
                if (objAllowedCategory.Value != "")
                    strCategoryFilter += "category = \"" + objAllowedCategory.Value + "\" or ";
            }

            // Treat everything as being uppercase so the search is case-insensitive.
            string strSearch = "/chummer/" + _strNode + "s/" + _strNode + "[(" + _objCharacter.Options.BookXPath() + ") and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))";
            if (strCategoryFilter != "")
                strSearch += " and (" + strCategoryFilter + ")";
            // Remove the trailing " or ";
            strSearch = strSearch.Substring(0, strSearch.Length - 4) + ")";
            strSearch += "]";

            XmlNodeList objXmlCyberwareList = _objXmlDocument.SelectNodes(strSearch);
            foreach (XmlNode objXmlCyberware in objXmlCyberwareList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlCyberware["name"].InnerText;
                if (objXmlCyberware["translate"] != null)
                    objItem.Name = objXmlCyberware["translate"].InnerText;
                else
                    objItem.Name = objXmlCyberware["name"].InnerText;

                try
                {
                    objItem.Name += " [" + _lstCategory.Find(objFind => objFind.Value == objXmlCyberware["category"].InnerText).Name + "]";
                    lstCyberwares.Add(objItem);
                }
                catch
                {
                }
            }
            SortListItem objSort = new SortListItem();
            lstCyberwares.Sort(objSort.Compare);
            lstCyberware.DataSource = null;
            lstCyberware.ValueMember = "Value";
            lstCyberware.DisplayMember = "Name";
            lstCyberware.DataSource = lstCyberwares;
        }
Esempio n. 46
0
        private void tmrSearch_Tick(object sender, EventArgs e)
        {
            tmrSearch.Stop();
            tmrSearch.Enabled = false;

            if (txtSearch.Text == "")
            {
                cboCategory_SelectedIndexChanged(sender, e);
                return;
            }

            // Treat everything as being uppercase so the search is case-insensitive.
            string strSearch = "/chummer/weapons/weapon[(" + _objCharacter.Options.BookXPath() + ") and category != \"Cyberware\" and category != \"Gear\" and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))]";

            XmlNodeList objXmlWeaponList = _objXmlDocument.SelectNodes(strSearch);

            if (dgvWeapons.Visible)
            {
                DataTable tabWeapons = new DataTable("weapons");
                tabWeapons.Columns.Add("WeaponName");
                tabWeapons.Columns.Add("Dice");
                tabWeapons.Columns.Add("Accuracy");
                tabWeapons.Columns["Accuracy"].DataType = typeof(Int32);
                tabWeapons.Columns.Add("Damage");
                tabWeapons.Columns.Add("AP");
                tabWeapons.Columns.Add("RC");
                tabWeapons.Columns["RC"].DataType = typeof(Int32);
                tabWeapons.Columns.Add("Ammo");
                tabWeapons.Columns.Add("Mode");
                tabWeapons.Columns.Add("Reach");
                tabWeapons.Columns.Add("Accessories");
                tabWeapons.Columns.Add("Avail");
                tabWeapons.Columns.Add("Source");
                tabWeapons.Columns.Add("Cost");
                tabWeapons.Columns["Cost"].DataType = typeof(Int32);

                // Populate the Weapon list.
                foreach (XmlNode objXmlWeapon in objXmlWeaponList)
                {
                    TreeNode objNode = new TreeNode();
                    Weapon objWeapon = new Weapon(_objCharacter);
                    objWeapon.Create(objXmlWeapon, _objCharacter, objNode, null, null, null);

                    string strWeaponName = objWeapon.Name;
                    string strDice = objWeapon.DicePool;
                    int intAccuracy = Convert.ToInt32(objWeapon.TotalAccuracy);
                    string strDamage = objWeapon.CalculatedDamage();
                    string strAP = objWeapon.TotalAP;
                    if (strAP == "-")
                        strAP = "0";
                    int intRC = Convert.ToInt32(objWeapon.TotalRC);
                    string strAmmo = objWeapon.Ammo;
                    string strMode = objWeapon.Mode;
                    string strReach = objWeapon.TotalReach.ToString();
                    string strAccessories = "";
                    foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
                    {
                        if (strAccessories.Length > 0)
                            strAccessories += "\n";
                        strAccessories += objAccessory.Name;
                    }
                    string strAvail = objWeapon.Avail.ToString();
                    string strSource = objWeapon.Source + " " + objWeapon.Page;
                    int intCost = objWeapon.Cost;

                    if (objWeapon.DisplayCategory == "Blades" || objWeapon.DisplayCategory == "Clubs" || objWeapon.DisplayCategory == "Improvised Weapons" || objWeapon.DisplayCategory == "Exotic Melee Weapons" || objWeapon.DisplayCategory == "Unarmed")
                    {
                        strAmmo = "";
                        strMode = "";
                    }
                    else
                    {
                        strReach = "";
                    }

                    tabWeapons.Rows.Add(strWeaponName, strDice, intAccuracy, strDamage, strAP, intRC, strAmmo, strMode, strReach, strAccessories, strAvail, strSource, intCost);
                }

                DataSet set = new DataSet("weapons");
                set.Tables.Add(tabWeapons);

                dgvWeapons.Columns[5].Visible = true;
                dgvWeapons.Columns[6].Visible = true;
                dgvWeapons.Columns[7].Visible = true;
                dgvWeapons.Columns[8].Visible = true;
                dgvWeapons.Columns[12].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight;

                dgvWeapons.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                dgvWeapons.DataSource = set;
                dgvWeapons.DataMember = "weapons";
            }
            else
            {
                List<ListItem> lstWeapons = new List<ListItem>();
                foreach (XmlNode objXmlWeapon in objXmlWeaponList)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlWeapon["name"].InnerText;
                    if (objXmlWeapon["translate"] != null)
                        objItem.Name = objXmlWeapon["translate"].InnerText;
                    else
                        objItem.Name = objXmlWeapon["name"].InnerText;

                    try
                    {
                        objItem.Name += " [" + _lstCategory.Find(objFind => objFind.Value == objXmlWeapon["category"].InnerText).Name + "]";
                        lstWeapons.Add(objItem);
                    }
                    catch
                    {
                    }
                }
                SortListItem objSort = new SortListItem();
                lstWeapons.Sort(objSort.Compare);
                lstWeapon.DataSource = null;
                lstWeapon.ValueMember = "Value";
                lstWeapon.DisplayMember = "Name";
                lstWeapon.DataSource = lstWeapons;
            }
        }
Esempio n. 47
0
        private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            List<ListItem> lstWeapons = new List<ListItem>();

            // Populate the Weapon list.
            XmlNodeList objXmlWeaponList = _objXmlDocument.SelectNodes("/chummer/weapons/weapon[category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ")]");
            foreach (XmlNode objXmlWeapon in objXmlWeaponList)
            {
                bool blnCyberware = false;
                try
                {
                    if (objXmlWeapon["cyberware"].InnerText == "yes")
                        blnCyberware = true;
                }
                catch
                { }

                if (!blnCyberware)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlWeapon["name"].InnerText;
                    if (objXmlWeapon["translate"] != null)
                        objItem.Name = objXmlWeapon["translate"].InnerText;
                    else
                        objItem.Name = objXmlWeapon["name"].InnerText;
                    lstWeapons.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();
            lstWeapons.Sort(objSort.Compare);
            lstWeapon.DataSource = null;
            lstWeapon.ValueMember = "Value";
            lstWeapon.DisplayMember = "Name";
            lstWeapon.DataSource = lstWeapons;

            if (chkBrowse.Checked)
                LoadGrid();
        }
Esempio n. 48
0
        /// <summary>
        /// Buid the list of Skills.
        /// </summary>
        private void BuildSkillList()
        {
            // Load the Skills information.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("skills.xml");

            // Populate the Skills list.
            XmlNodeList objXmlSkillList = objXmlDocument.SelectNodes("/chummer/skills/skill[not(exotic) and (" + Options.BookXPath() + ")]");

            // First pass, build up a list of all of the Skills so we can sort them in alphabetical order for the current language.
            List<ListItem> lstSkillOrder = new List<ListItem>();
            foreach (XmlNode objXmlSkill in objXmlSkillList)
            {
                ListItem objSkill = new ListItem();
                objSkill.Value = objXmlSkill["name"].InnerText;
                if (objXmlSkill["translate"] != null)
                    objSkill.Name = objXmlSkill["translate"].InnerText;
                else
                    objSkill.Name = objXmlSkill["name"].InnerText;
                lstSkillOrder.Add(objSkill);
            }
            SortListItem objSort = new SortListItem();
            lstSkillOrder.Sort(objSort.Compare);

            // Second pass, retrieve the Skills in the order they're presented in the list.
            foreach (ListItem objItem in lstSkillOrder)
            {
                XmlNode objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + objItem.Value + "\"]");
                Skill objSkill = new Skill(this);
                objSkill.Name = objXmlSkill["name"].InnerText;
                objSkill.Id = Guid.Parse(objXmlSkill["id"].InnerText);
                objSkill.SkillCategory = objXmlSkill["category"].InnerText;
                objSkill.SkillGroup = objXmlSkill["skillgroup"].InnerText;
                objSkill.Attribute = objXmlSkill["attribute"].InnerText;
                if (objXmlSkill["default"].InnerText.ToLower() == "yes")
                    objSkill.Default = true;
                else
                    objSkill.Default = false;
                if (objXmlSkill["source"] != null)
                    objSkill.Source = objXmlSkill["source"].InnerText;
                if (objXmlSkill["page"] != null)
                    objSkill.Page = objXmlSkill["page"].InnerText;
                _lstSkills.Add(objSkill);
            }
        }
Esempio n. 49
0
        /// <summary>
        /// Load the Character from an XML file.
        /// </summary>
        public bool Load()
        {
            XmlDocument objXmlDocument = new XmlDocument();
            objXmlDocument.Load(_strFileName);

            XmlNode objXmlCharacter = objXmlDocument.SelectSingleNode("/character");
            XmlNodeList objXmlNodeList;

            try
            {
                _blnIgnoreRules = Convert.ToBoolean(objXmlCharacter["ignorerules"].InnerText);
            }
            catch
            {
                _blnIgnoreRules = false;
            }
            try
            {
                _blnCreated = Convert.ToBoolean(objXmlCharacter["created"].InnerText);
            }
            catch
            {
            }

            ResetCharacter();

            // Get the game edition of the file if possible and make sure it's intended to be used with this version of the application.
            try
            {
                if (objXmlCharacter["gameedition"].InnerText != string.Empty && objXmlCharacter["gameedition"].InnerText != "SR5")
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_IncorrectGameVersion_SR4"), LanguageManager.Instance.GetString("MessageTitle_IncorrectGameVersion"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
            }
            catch
            {
            }

            // Get the name of the settings file in use if possible.
            try
            {
                _strSettingsFileName = objXmlCharacter["settings"].InnerText;
            }
            catch
            {
            }

            // Load the character's settings file.
            if (!_objOptions.Load(_strSettingsFileName))
                return false;

            try
            {
                _decEssenceAtSpecialStart = Convert.ToDecimal(objXmlCharacter["essenceatspecialstart"].InnerText, GlobalOptions.Instance.CultureInfo);
                // fix to work around a mistake made when saving decimal values in previous versions.
                if (_decEssenceAtSpecialStart > EssenceMaximum)
                    _decEssenceAtSpecialStart /= 10;
            }
            catch
            {
            }

            try
            {
                _strVersionCreated = objXmlCharacter["createdversion"].InnerText;
            }
            catch
            {
            }

            // Metatype information.
            _strMetatype = objXmlCharacter["metatype"].InnerText;
            try
            {
                _strWalk = objXmlCharacter["walk"].InnerText;
                _strRun = objXmlCharacter["run"].InnerText;
                _strSprint = objXmlCharacter["sprint"].InnerText;
            }
            catch
            {
            }
            _intMetatypeBP = Convert.ToInt32(objXmlCharacter["metatypebp"].InnerText);
            _strMetavariant = objXmlCharacter["metavariant"].InnerText;
            try
            {
                _strMetatypeCategory = objXmlCharacter["metatypecategory"].InnerText;
            }
            catch
            {
            }
            try
            {
                _intMutantCritterBaseSkills = Convert.ToInt32(objXmlCharacter["mutantcritterbaseskills"].InnerText);
            }
            catch
            {
            }

            // General character information.
            _strName = objXmlCharacter["name"].InnerText;
            try
            {
                _strMugshot = objXmlCharacter["mugshot"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strSex = objXmlCharacter["sex"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strAge = objXmlCharacter["age"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strEyes = objXmlCharacter["eyes"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strHeight = objXmlCharacter["height"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strWeight = objXmlCharacter["weight"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strSkin = objXmlCharacter["skin"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strHair = objXmlCharacter["hair"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strDescription = objXmlCharacter["description"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strBackground = objXmlCharacter["background"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strConcept = objXmlCharacter["concept"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strNotes = objXmlCharacter["notes"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strAlias = objXmlCharacter["alias"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strPlayerName = objXmlCharacter["playername"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strGameNotes = objXmlCharacter["gamenotes"].InnerText;
            }
            catch
            {
            }

            try
            {
                _strGameplayOption = objXmlCharacter["gameplayoption"].InnerText;
            }
            catch
            {
            }
            try
            {
                _intMaxNuyen = Convert.ToInt32(objXmlCharacter["maxnuyen"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intContactMultiplier = Convert.ToInt32(objXmlCharacter["contactmultiplier"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intMaxKarma = Convert.ToInt32(objXmlCharacter["maxkarma"].InnerText);
            }
            catch
            {
            }
            try
            {
                _strPriorityMetatype = objXmlCharacter["prioritymetatype"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strPriorityAttributes = objXmlCharacter["priorityattributes"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strPrioritySpecial = objXmlCharacter["priorityspecial"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strPrioritySkills = objXmlCharacter["priorityskills"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strPriorityResources = objXmlCharacter["priorityresources"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strSkill1 = objXmlCharacter["priorityskill1"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strSkill2 = objXmlCharacter["priorityskill2"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strSkillGroup = objXmlCharacter["priorityskillgroup"].InnerText;
            }
            catch
            {
            }

            try
            {
                _blnIsCritter = Convert.ToBoolean(objXmlCharacter["iscritter"].InnerText);
            }
            catch
            {
            }

            try
            {
                _blnPossessed = Convert.ToBoolean(objXmlCharacter["possessed"].InnerText);
            }
            catch
            {
            }

            try
            {
                _blnOverrideSpecialAttributeESSLoss = Convert.ToBoolean(objXmlCharacter["overridespecialattributeessloss"].InnerText);
            }
            catch
            {
            }

            try
            {
                _intContactPoints = Convert.ToInt32(objXmlCharacter["contactpoints"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intContactPointsUsed = Convert.ToInt32(objXmlCharacter["contactpointsused"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intCFPLimit = Convert.ToInt32(objXmlCharacter["cfplimit"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intSpellLimit = Convert.ToInt32(objXmlCharacter["spelllimit"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intKarma = Convert.ToInt32(objXmlCharacter["karma"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intTotalKarma = Convert.ToInt32(objXmlCharacter["totalkarma"].InnerText);
            }
            catch
            {
            }

            try
            {
                _intSpecial = Convert.ToInt32(objXmlCharacter["special"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intTotalSpecial = Convert.ToInt32(objXmlCharacter["totalspecial"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intAttributes = Convert.ToInt32(objXmlCharacter["attributes"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intTotalAttributes = Convert.ToInt32(objXmlCharacter["totalattributes"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intContactPoints = Convert.ToInt32(objXmlCharacter["contactpoints"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intContactPointsUsed = Convert.ToInt32(objXmlCharacter["contactpointsused"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intStreetCred = Convert.ToInt32(objXmlCharacter["streetcred"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intNotoriety = Convert.ToInt32(objXmlCharacter["notoriety"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intPublicAwareness = Convert.ToInt32(objXmlCharacter["publicawareness"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intBurntStreetCred = Convert.ToInt32(objXmlCharacter["burntstreetcred"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intMaxAvail = Convert.ToInt32(objXmlCharacter["maxavail"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intNuyen = Convert.ToInt32(objXmlCharacter["nuyen"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intStartingNuyen = Convert.ToInt32(objXmlCharacter["startingnuyen"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intAdeptWayDiscount = Convert.ToInt32(objXmlCharacter["adeptwaydiscount"].InnerText);
            }
            catch
            {
            }

            // Sum to X point value.
            try
            {
                _intSumtoTen = Convert.ToInt32(objXmlCharacter["sumtoten"].InnerText);
            }
            catch
            {
            }
            // Build Points/Karma.
            _intBuildPoints = Convert.ToInt32(objXmlCharacter["bp"].InnerText);
            try
            {
                _intBuildKarma = Convert.ToInt32(objXmlCharacter["buildkarma"].InnerText);
                if (_intMaxKarma == 0)
                    _intMaxKarma = _intBuildKarma;
                if (_intBuildKarma == 35 && _strGameplayOption == "")
                {
                    _strGameplayOption = "Prime Runner";
                }
                if (_intBuildKarma == 35 && _intMaxNuyen == 0)
                {
                    _intMaxNuyen = 25;
                }
            }
            catch
            {
            }
            //Maximum number of Karma that can be spent/gained on Qualities.
            try
            {
                _intGameplayOptionQualityLimit = Convert.ToInt32(objXmlCharacter["gameplayoptionqualitylimit"].InnerText);
            }
            catch
            {
            }
            try
            {
                _objBuildMethod = ConvertToCharacterBuildMethod(objXmlCharacter["buildmethod"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intKnowledgeSkills = Convert.ToInt32(objXmlCharacter["knowskillpts"].InnerText);

            }
            catch { }
            _intKnowledgeSkillPoints = Convert.ToInt32(objXmlCharacter["knowpts"].InnerText);
            _intSkillPoints = Convert.ToInt32(objXmlCharacter["skillpts"].InnerText);
            _intSkillPointsMaximum = Convert.ToInt32(objXmlCharacter["skillptsmax"].InnerText);
            _intSkillGroups = Convert.ToInt32(objXmlCharacter["skillgrps"].InnerText);
            _intSkillGroupsMaximum = Convert.ToInt32(objXmlCharacter["skillgrpsmax"].InnerText);
            _decNuyenBP = Convert.ToDecimal(objXmlCharacter["nuyenbp"].InnerText, GlobalOptions.Instance.CultureInfo);
            _decNuyenMaximumBP = Convert.ToDecimal(objXmlCharacter["nuyenmaxbp"].InnerText, GlobalOptions.Instance.CultureInfo);
            _blnAdeptEnabled = Convert.ToBoolean(objXmlCharacter["adept"].InnerText);
            _blnMagicianEnabled = Convert.ToBoolean(objXmlCharacter["magician"].InnerText);
            _blnTechnomancerEnabled = Convert.ToBoolean(objXmlCharacter["technomancer"].InnerText);
            try
            {
                _blnInitiationEnabled = Convert.ToBoolean(objXmlCharacter["initiationoverride"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnCritterEnabled = Convert.ToBoolean(objXmlCharacter["critter"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnUneducated = Convert.ToBoolean(objXmlCharacter["uneducated"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnUncouth = Convert.ToBoolean(objXmlCharacter["uncouth"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnSchoolOfHardKnocks = Convert.ToBoolean(objXmlCharacter["schoolofhardknocks"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnFriendsInHighPlaces = Convert.ToBoolean(objXmlCharacter["friendsinhighplaces"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnCollegeEducation = Convert.ToBoolean(objXmlCharacter["collegeeducation"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnJackOfAllTrades = Convert.ToBoolean(objXmlCharacter["jackofalltrades"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnInfirm = Convert.ToBoolean(objXmlCharacter["infirm"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnBlackMarket = Convert.ToBoolean(objXmlCharacter["blackmarket"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnExCon = Convert.ToBoolean(objXmlCharacter["excon"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnTrustFund = Convert.ToBoolean(objXmlCharacter["trustfund"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnTechSchool = Convert.ToBoolean(objXmlCharacter["techschool"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnRestrictedGear = Convert.ToBoolean(objXmlCharacter["restrictedgear"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnOverclocker = Convert.ToBoolean(objXmlCharacter["overclocker"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnMadeMan = Convert.ToBoolean(objXmlCharacter["mademan"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnLinguist = Convert.ToBoolean(objXmlCharacter["linguist"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnLightningReflexes = Convert.ToBoolean(objXmlCharacter["lightningreflexes"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnFame = Convert.ToBoolean(objXmlCharacter["fame"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnBornRich = Convert.ToBoolean(objXmlCharacter["bornrich"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnErased = Convert.ToBoolean(objXmlCharacter["erased"].InnerText);
            }
            catch
            {
            }
            _blnMAGEnabled = Convert.ToBoolean(objXmlCharacter["magenabled"].InnerText);
            try
            {
                _intInitiateGrade = Convert.ToInt32(objXmlCharacter["initiategrade"].InnerText);
            }
            catch
            {
            }
            _blnRESEnabled = Convert.ToBoolean(objXmlCharacter["resenabled"].InnerText);
            try
            {
                _intSubmersionGrade = Convert.ToInt32(objXmlCharacter["submersiongrade"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnGroupMember = Convert.ToBoolean(objXmlCharacter["groupmember"].InnerText);
            }
            catch
            {
            }
            try
            {
                _strGroupName = objXmlCharacter["groupname"].InnerText;
                _strGroupNotes = objXmlCharacter["groupnotes"].InnerText;
            }
            catch
            {
            }

            // Improvements.
            XmlNodeList objXmlImprovementList = objXmlDocument.SelectNodes("/character/improvements/improvement");
            foreach (XmlNode objXmlImprovement in objXmlImprovementList)
            {
                Improvement objImprovement = new Improvement();
                objImprovement.Load(objXmlImprovement);
                _lstImprovements.Add(objImprovement);
            }

            // Qualities
            objXmlNodeList = objXmlDocument.SelectNodes("/character/qualities/quality");
            bool blnHasOldQualities = false;
            foreach (XmlNode objXmlQuality in objXmlNodeList)
            {
                if (objXmlQuality["name"] != null)
                {
                    Quality objQuality = new Quality(this);
                    objQuality.Load(objXmlQuality);
                    _lstQualities.Add(objQuality);
                }
                else
                {
                    // If the Quality does not have a name tag, it is in the old format. Set the flag to show that old Qualities are in use.
                    blnHasOldQualities = true;
                }
            }
            // If old Qualities are in use, they need to be converted before we can continue.
            if (blnHasOldQualities)
                ConvertOldQualities(objXmlNodeList);

            // Attributes.
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"BOD\"]");
            _attBOD.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"AGI\"]");
            _attAGI.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"REA\"]");
            _attREA.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"STR\"]");
            _attSTR.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"CHA\"]");
            _attCHA.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"INT\"]");
            _attINT.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"LOG\"]");
            _attLOG.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"WIL\"]");
            _attWIL.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"INI\"]");
            _attINI.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"EDG\"]");
            _attEDG.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"MAG\"]");
            _attMAG.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"RES\"]");
            _attRES.Load(objXmlCharacter);
            objXmlCharacter = objXmlDocument.SelectSingleNode("/character/attributes/attribute[name = \"ESS\"]");
            _attESS.Load(objXmlCharacter);

            // A.I. Attributes.
            try
            {
                _intSignal = Convert.ToInt32(objXmlDocument.SelectSingleNode("/character/attributes/signal").InnerText);
                _intResponse = Convert.ToInt32(objXmlDocument.SelectSingleNode("/character/attributes/response").InnerText);
            }
            catch
            {
            }

            // Force.
            try
            {
                _intMaxSkillRating = Convert.ToInt32(objXmlDocument.SelectSingleNode("/character/attributes/maxskillrating").InnerText);
            }
            catch
            {
            }

            // Attempt to load the split MAG Attribute information for Mystic Adepts.
            if (_blnAdeptEnabled && _blnMagicianEnabled)
            {
                try
                {
                    _intMAGAdept = Convert.ToInt32(objXmlDocument.SelectSingleNode("/character/magsplitadept").InnerText);
                    _intMAGMagician = Convert.ToInt32(objXmlDocument.SelectSingleNode("/character/magsplitmagician").InnerText);
                }
                catch
                {
                }
            }

            // Attempt to load the Magic Tradition.
            try
            {
                _strMagicTradition = objXmlDocument.SelectSingleNode("/character/tradition").InnerText;
            }
            catch
            {
            }
            // Attempt to load the Magic Tradition Drain Attributes.
            try
            {
                _strTraditionDrain = objXmlDocument.SelectSingleNode("/character/traditiondrain").InnerText;
            }
            catch
            {
            }
            // Attempt to load the Magic Tradition Name.
            try
            {
                _strTraditionName = objXmlDocument.SelectSingleNode("/character/traditionname").InnerText;
            }
            catch
            {
            }
            // Attempt to load the Spirit Combat Name.
            try
            {
                _strSpiritCombat = objXmlDocument.SelectSingleNode("/character/spiritcombat").InnerText;
            }
            catch
            {
            }
            // Attempt to load the Spirit Detection Name.
            try
            {
                _strSpiritDetection = objXmlDocument.SelectSingleNode("/character/spiritdetection").InnerText;
            }
            catch
            {
            }
            // Attempt to load the Spirit Health Name.
            try
            {
                _strSpiritHealth = objXmlDocument.SelectSingleNode("/character/spirithealth").InnerText;
            }
            catch
            {
            }
            // Attempt to load the Spirit Illusion Name.
            try
            {
                _strSpiritIllusion = objXmlDocument.SelectSingleNode("/character/spiritillusion").InnerText;
            }
            catch
            {
            }
            // Attempt to load the Spirit Manipulation Name.
            try
            {
                _strSpiritManipulation = objXmlDocument.SelectSingleNode("/character/spiritmanipulation").InnerText;
            }
            catch
            {
            }
            // Attempt to load the Technomancer Stream.
            try
            {
                _strTechnomancerStream = objXmlDocument.SelectSingleNode("/character/stream").InnerText;
            }
            catch
            {
            }

            // Attempt to load Condition Monitor Progress.
            try
            {
                _intPhysicalCMFilled = Convert.ToInt32(objXmlDocument.SelectSingleNode("/character/physicalcmfilled").InnerText);
                _intStunCMFilled = Convert.ToInt32(objXmlDocument.SelectSingleNode("/character/stuncmfilled").InnerText);
            }
            catch
            {
            }

            // Skills.
            foreach (Skill objSkill in _lstSkills)
            {
                XmlNode objXmlSkill = objXmlDocument.SelectSingleNode("/character/skills/skill[name = \"" + objSkill.Name + "\"]");
                if (objXmlSkill != null)
                {
                    objSkill.Load(objXmlSkill);
                }
            }

            // Exotic Skills.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/skills/skill[exotic = \"True\"]");
            foreach (XmlNode objXmlSkill in objXmlNodeList)
            {
                Skill objSkill = new Skill(this);
                objSkill.Load(objXmlSkill);
                _lstSkills.Add(objSkill);
            }

            // SkillGroups.
            foreach (SkillGroup objGroup in _lstSkillGroups)
            {
                XmlNode objXmlSkill = objXmlDocument.SelectSingleNode("/character/skillgroups/skillgroup[name = \"" + objGroup.Name + "\"]");
                if (objXmlSkill != null)
                {
                    objGroup.Load(objXmlSkill);
                    // If the character is set to ignore rules or is in Career Mode, Skill Groups should have a maximum Rating of 6 unless they have been given a higher maximum Rating already.
                    if ((_blnIgnoreRules || _blnCreated) && objGroup.RatingMaximum < 12)
                        objGroup.RatingMaximum = 12;
                }
            }

            // Apply the broken skill group fix
            foreach (Skill objSkill in _lstSkills)
            {
                foreach (SkillGroup objGroup in _lstSkillGroups)
                {
                    if (objGroup.Broken && objGroup.Name == objSkill.SkillGroup)
                    {
                        objSkill.FreeLevels = objGroup.Rating;
                        objSkill.Base = objGroup.Rating;
                        objSkill.Karma = objSkill.Rating - objSkill.Base;
                    }
                }
            }

            foreach (SkillGroup objGroup in _lstSkillGroups)
            {
                if (objGroup.Base == 0 && objGroup.Karma == 0 && objGroup.Rating > 0)
                    objGroup.Base = objGroup.Rating;
            }

            // Knowledge Skills.
            List<ListItem> lstKnowledgeSkillOrder = new List<ListItem>();
            objXmlNodeList = objXmlDocument.SelectNodes("/character/skills/skill[knowledge = \"True\"]");
            // Sort the Knowledge Skills in alphabetical order.
            foreach (XmlNode objXmlSkill in objXmlNodeList)
            {
                ListItem objGroup = new ListItem();
                objGroup.Value = objXmlSkill["name"].InnerText;
                objGroup.Name = objXmlSkill["name"].InnerText;
                lstKnowledgeSkillOrder.Add(objGroup);
            }
            SortListItem objSort = new SortListItem();
            lstKnowledgeSkillOrder.Sort(objSort.Compare);

            foreach (ListItem objItem in lstKnowledgeSkillOrder)
            {
                Skill objSkill = new Skill(this);
                XmlNode objNode = objXmlDocument.SelectSingleNode("/character/skills/skill[knowledge = \"True\" and name = " + CleanXPath(objItem.Value) + "]");
                objSkill.Load(objNode);
                _lstSkills.Add(objSkill);
            }

            // Contacts.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/contacts/contact");
            foreach (XmlNode objXmlContact in objXmlNodeList)
            {
                Contact objContact = new Contact(this);
                objContact.Load(objXmlContact);
                _lstContacts.Add(objContact);
            }

            // Armor.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/armors/armor");
            foreach (XmlNode objXmlArmor in objXmlNodeList)
            {
                Armor objArmor = new Armor(this);
                objArmor.Load(objXmlArmor);
                _lstArmor.Add(objArmor);
            }

            // Weapons.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/weapons/weapon");
            foreach (XmlNode objXmlWeapon in objXmlNodeList)
            {
                Weapon objWeapon = new Weapon(this);
                objWeapon.Load(objXmlWeapon);
                _lstWeapons.Add(objWeapon);
            }

            // Cyberware/Bioware.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/cyberwares/cyberware");
            foreach (XmlNode objXmlCyberware in objXmlNodeList)
            {
                Cyberware objCyberware = new Cyberware(this);
                objCyberware.Load(objXmlCyberware);
                _lstCyberware.Add(objCyberware);
            }

            // Spells.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/spells/spell");
            foreach (XmlNode objXmlSpell in objXmlNodeList)
            {
                Spell objSpell = new Spell(this);
                objSpell.Load(objXmlSpell);
                _lstSpells.Add(objSpell);
            }

            // Foci.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/foci/focus");
            foreach (XmlNode objXmlFocus in objXmlNodeList)
            {
                Focus objFocus = new Focus();
                objFocus.Load(objXmlFocus);
                _lstFoci.Add(objFocus);
            }

            // Stacked Foci.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/stackedfoci/stackedfocus");
            foreach (XmlNode objXmlStack in objXmlNodeList)
            {
                StackedFocus objStack = new StackedFocus(this);
                objStack.Load(objXmlStack);
                _lstStackedFoci.Add(objStack);
            }

            // Powers.
            List<ListItem> lstPowerOrder = new List<ListItem>();
            objXmlNodeList = objXmlDocument.SelectNodes("/character/powers/power");
            // Sort the Powers in alphabetical order.
            foreach (XmlNode objXmlPower in objXmlNodeList)
            {
                ListItem objGroup = new ListItem();
                objGroup.Value = objXmlPower["extra"].InnerText;
                objGroup.Name = objXmlPower["name"].InnerText;

                lstPowerOrder.Add(objGroup);
            }
            objSort = new SortListItem();
            lstPowerOrder.Sort(objSort.Compare);

            foreach (ListItem objItem in lstPowerOrder)
            {
                Power objPower = new Power(this);
                XmlNode objNode = objXmlDocument.SelectSingleNode("/character/powers/power[name = " + CleanXPath(objItem.Name) + " and extra = " + CleanXPath(objItem.Value) + "]");
                objPower.Load(objNode);
                _lstPowers.Add(objPower);
            }

            // Spirits/Sprites.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/spirits/spirit");
            foreach (XmlNode objXmlSpirit in objXmlNodeList)
            {
                Spirit objSpirit = new Spirit(this);
                objSpirit.Load(objXmlSpirit);
                _lstSpirits.Add(objSpirit);
            }

            // Compex Forms/Technomancer Programs.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/complexforms/complexform");
            foreach (XmlNode objXmlProgram in objXmlNodeList)
            {
                ComplexForm objProgram = new ComplexForm(this);
                objProgram.Load(objXmlProgram);
                _lstComplexForms.Add(objProgram);
            }

            // Martial Arts.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/martialarts/martialart");
            foreach (XmlNode objXmlArt in objXmlNodeList)
            {
                MartialArt objMartialArt = new MartialArt(this);
                objMartialArt.Load(objXmlArt);
                _lstMartialArts.Add(objMartialArt);
            }

            // Martial Art Maneuvers.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/martialartmaneuvers/martialartmaneuver");
            foreach (XmlNode objXmlManeuver in objXmlNodeList)
            {
                MartialArtManeuver objManeuver = new MartialArtManeuver(this);
                objManeuver.Load(objXmlManeuver);
                _lstMartialArtManeuvers.Add(objManeuver);
            }

            // Limit Modifiers.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/limitmodifiers/limitmodifier");
            foreach (XmlNode objXmlLimit in objXmlNodeList)
            {
                LimitModifier obLimitModifier = new LimitModifier(this);
                obLimitModifier.Load(objXmlLimit);
                _lstLimitModifiers.Add(obLimitModifier);
            }

            // Lifestyles.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/lifestyles/lifestyle");
            foreach (XmlNode objXmlLifestyle in objXmlNodeList)
            {
                Lifestyle objLifestyle = new Lifestyle(this);
                objLifestyle.Load(objXmlLifestyle);
                _lstLifestyles.Add(objLifestyle);
            }

            // <gears>
            objXmlNodeList = objXmlDocument.SelectNodes("/character/gears/gear");
            foreach (XmlNode objXmlGear in objXmlNodeList)
            {
                switch (objXmlGear["category"].InnerText)
                {
                    case "Commlinks":
                    case "Cyberdecks":
                    case "Rigger Command Consoles":
                        Commlink objCommlink = new Commlink(this);
                        objCommlink.Load(objXmlGear);
                        _lstGear.Add(objCommlink);
                        break;
                    default:
                        Gear objGear = new Gear(this);
                        objGear.Load(objXmlGear);
                        _lstGear.Add(objGear);
                        break;
                }
            }

            // Vehicles.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/vehicles/vehicle");
            foreach (XmlNode objXmlVehicle in objXmlNodeList)
            {
                Vehicle objVehicle = new Vehicle(this);
                objVehicle.Load(objXmlVehicle);
                _lstVehicles.Add(objVehicle);
            }

            // Metamagics/Echoes.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/metamagics/metamagic");
            foreach (XmlNode objXmlMetamagic in objXmlNodeList)
            {
                Metamagic objMetamagic = new Metamagic(this);
                objMetamagic.Load(objXmlMetamagic);
                _lstMetamagics.Add(objMetamagic);
            }

            // Arts
            objXmlNodeList = objXmlDocument.SelectNodes("/character/arts/art");
            foreach (XmlNode objXmlArt in objXmlNodeList)
            {
                Art objArt = new Art(this);
                objArt.Load(objXmlArt);
                _lstArts.Add(objArt);
            }

            // Enhancements
            objXmlNodeList = objXmlDocument.SelectNodes("/character/enhancements/enhancement");
            foreach (XmlNode objXmlEnhancement in objXmlNodeList)
            {
                Enhancement objEnhancement = new Enhancement(this);
                objEnhancement.Load(objXmlEnhancement);
                _lstEnhancements.Add(objEnhancement);
            }

            // Critter Powers.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/critterpowers/critterpower");
            foreach (XmlNode objXmlPower in objXmlNodeList)
            {
                CritterPower objPower = new CritterPower(this);
                objPower.Load(objXmlPower);
                _lstCritterPowers.Add(objPower);
            }

            // Initiation Grades.
            objXmlNodeList = objXmlDocument.SelectNodes("/character/initiationgrades/initiationgrade");
            foreach (XmlNode objXmlGrade in objXmlNodeList)
            {
                InitiationGrade objGrade = new InitiationGrade(this);
                objGrade.Load(objXmlGrade);
                _lstInitiationGrades.Add(objGrade);
            }

            // Expense Log Entries.
            XmlNodeList objXmlExpenseList = objXmlDocument.SelectNodes("/character/expenses/expense");
            foreach (XmlNode objXmlExpense in objXmlExpenseList)
            {
                ExpenseLogEntry objExpenseLogEntry = new ExpenseLogEntry();
                objExpenseLogEntry.Load(objXmlExpense);
                _lstExpenseLog.Add(objExpenseLogEntry);
            }

            // Locations.
            XmlNodeList objXmlLocationList = objXmlDocument.SelectNodes("/character/locations/location");
            foreach (XmlNode objXmlLocation in objXmlLocationList)
            {
                _lstLocations.Add(objXmlLocation.InnerText);
            }

            // Armor Bundles.
            XmlNodeList objXmlBundleList = objXmlDocument.SelectNodes("/character/armorbundles/armorbundle");
            foreach (XmlNode objXmlBundle in objXmlBundleList)
            {
                _lstArmorBundles.Add(objXmlBundle.InnerText);
            }

            // Weapon Locations.
            XmlNodeList objXmlWeaponLocationList = objXmlDocument.SelectNodes("/character/weaponlocations/weaponlocation");
            foreach (XmlNode objXmlLocation in objXmlWeaponLocationList)
            {
                _lstWeaponLocations.Add(objXmlLocation.InnerText);
            }

            // Improvement Groups.
            XmlNodeList objXmlGroupList = objXmlDocument.SelectNodes("/character/improvementgroups/improvementgroup");
            foreach (XmlNode objXmlGroup in objXmlGroupList)
            {
                _lstImprovementGroups.Add(objXmlGroup.InnerText);
            }

            // Calendar.
            XmlNodeList objXmlWeekList = objXmlDocument.SelectNodes("/character/calendar/week");
            foreach (XmlNode objXmlWeek in objXmlWeekList)
            {
                CalendarWeek objWeek = new CalendarWeek();
                objWeek.Load(objXmlWeek);
                _lstCalendar.Add(objWeek);
            }

            // Look for the unarmed attack
            bool blnFoundUnarmed = false;
            foreach (Weapon objWeapon in _lstWeapons)
            {
                if (objWeapon.Name == "Unarmed Attack")
                    blnFoundUnarmed = true;
            }

            if (!blnFoundUnarmed)
            {
                // Add the Unarmed Attack Weapon to the character.
                try
                {
                    XmlDocument objXmlWeaponDoc = XmlManager.Instance.Load("weapons.xml");
                    XmlNode objXmlWeapon = objXmlWeaponDoc.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]");
                    TreeNode objGearWeaponNode = new TreeNode();
                    Weapon objWeapon = new Weapon(this);
                    objWeapon.Create(objXmlWeapon, this, objGearWeaponNode, null, null, null);
                    objGearWeaponNode.ForeColor = SystemColors.GrayText;
                    _lstWeapons.Add(objWeapon);
                }
                catch
                {
                }
            }

            // converting from old dwarven resistance to new dwarven resistance
            if (this.Metatype.ToLower().Equals("dwarf")
                && this.Qualities.Where(x => x.Name.Equals("Dwarf Resistance")).FirstOrDefault() == null
                && this.Qualities.Where(x => x.Name.Equals("Resistance to Pathogens and Toxins")).FirstOrDefault() != null)
            {
                this.Qualities.Remove(this.Qualities.Where(x => x.Name.Equals("Resistance to Pathogens and Toxins")).First());
                XmlNode objXmlDwarfQuality = XmlManager.Instance.Load("qualities.xml").SelectSingleNode("/chummer/qualities/quality[name = \"Dwarf Resistance\"]");

                TreeNode objNode = new TreeNode();
                List<Weapon> objWeapons = new List<Weapon>();
                List<TreeNode> objWeaponNodes = new List<TreeNode>();
                Quality objQuality = new Quality(this);

                objQuality.Create(objXmlDwarfQuality, this, QualitySource.Metatype, objNode, objWeapons, objWeaponNodes);
                this._lstQualities.Add(objQuality);
                blnHasOldQualities = true;
            }

            // load issue where the contact multiplier was set to 0
            if (_intContactMultiplier == 0 && _strGameplayOption != string.Empty)
            {
                XmlDocument objXmlDocumentPriority = XmlManager.Instance.Load("gameplayoptions.xml");
                XmlNode objXmlGameplayOption = objXmlDocumentPriority.SelectSingleNode("/chummer/gameplayoptions/gameplayoption[name = \"" + _strGameplayOption + "\"]");
                string strKarma = objXmlGameplayOption["karma"].InnerText;
                string strNuyen = objXmlGameplayOption["maxnuyen"].InnerText;
                string strContactMultiplier = "0";
                if (!_objOptions.FreeContactsMultiplierEnabled)
                {

                    strContactMultiplier = objXmlGameplayOption["contactmultiplier"].InnerText;
                }
                else
                {
                    strContactMultiplier = _objOptions.FreeContactsMultiplier.ToString();
                }
                _intMaxKarma = Convert.ToInt32(strKarma);
                _intMaxNuyen = Convert.ToInt32(strNuyen);
                _intContactMultiplier = Convert.ToInt32(strContactMultiplier);
                _intContactPoints = (CHA.Base + CHA.Karma) * _intContactMultiplier;
            }

            // If the character had old Qualities that were converted, immediately save the file so they are in the new format.
            if (blnHasOldQualities)
                Save();

            return true;
        }
Esempio n. 50
0
        /// <summary>
        /// Build the list of Qualities.
        /// </summary>
        private void BuildQualityList()
        {
            List<ListItem> lstQuality = new List<ListItem>();
            if (txtSearch.Text.Trim() != "")
            {
                // Treat everything as being uppercase so the search is case-insensitive.
                string strSearch = "/chummer/qualities/quality[(" + _objCharacter.Options.BookXPath() + ") and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))";
                if (chkMetagenetic.Checked)
                {
                    strSearch += " and (required/oneof[contains(., 'Changeling (Class I SURGE)')] or metagenetic = 'yes')";
                }
                strSearch += "]";

                XmlNodeList objXmlQualityList = _objXmlDocument.SelectNodes(strSearch);
                foreach (XmlNode objXmlQuality in objXmlQualityList)
                {
                    if (objXmlQuality["hide"] == null)
                    {
                        if (!chkLimitList.Checked || (chkLimitList.Checked && RequirementMet(objXmlQuality, false)))
                        {
                            ListItem objItem = new ListItem();
                            objItem.Value = objXmlQuality["name"].InnerText;
                            if (objXmlQuality["translate"] != null)
                                objItem.Name = objXmlQuality["translate"].InnerText;
                            else
                                objItem.Name = objXmlQuality["name"].InnerText;

                             try
                             {
                                 objItem.Name += " [" + _lstCategory.Find(objFind => objFind.Value == objXmlQuality["category"].InnerText).Name + "]";

                                 lstQuality.Add(objItem);

                             }
                             catch
                             {
                             }
                        }
                    }
                }
            }
            else
            {
                XmlDocument objXmlMetatypeDocument = new XmlDocument();
                if (_objCharacter.Metatype == "A.I." || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients")
                    objXmlMetatypeDocument = XmlManager.Instance.Load("metatypes.xml");

                string strXPath = "category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ")";
                if (chkMetagenetic.Checked)
                {
                    strXPath += " and (required/oneof[contains(., 'Changeling (Class I SURGE)')] or metagenetic = 'yes')";
                }

                foreach (XmlNode objXmlQuality in _objXmlDocument.SelectNodes("/chummer/qualities/quality[" + strXPath + "]"))
                {
                    if (objXmlQuality["name"].InnerText.StartsWith("Infected"))
                    {
                    }
                    if ((_objCharacter.Metatype == "A.I." || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients") && chkLimitList.Checked)
                    {
                        XmlNode objXmlMetatype = objXmlMetatypeDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
                        if (objXmlMetatype.SelectSingleNode("qualityrestriction/" + cboCategory.SelectedValue.ToString().ToLower() + "/quality[. = \"" + objXmlQuality["name"].InnerText + "\"]") != null)
                        {
                            if (!chkLimitList.Checked || (chkLimitList.Checked && RequirementMet(objXmlQuality, false)))
                            {
                                if (objXmlQuality["hide"] == null)
                                {
                                    ListItem objItem = new ListItem();
                                    objItem.Value = objXmlQuality["name"].InnerText;
                                    if (objXmlQuality["translate"] != null)
                                        objItem.Name = objXmlQuality["translate"].InnerText;
                                    else
                                        objItem.Name = objXmlQuality["name"].InnerText;

                                    lstQuality.Add(objItem);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!chkLimitList.Checked || (chkLimitList.Checked && RequirementMet(objXmlQuality, false)))
                        {
                            if (objXmlQuality["hide"] == null)
                            {
                                ListItem objItem = new ListItem();
                                objItem.Value = objXmlQuality["name"].InnerText;
                                if (objXmlQuality["translate"] != null)
                                    objItem.Name = objXmlQuality["translate"].InnerText;
                                else
                                    objItem.Name = objXmlQuality["name"].InnerText;

                                lstQuality.Add(objItem);
                            }
                        }
                    }
                }
            }
            SortListItem objSort = new SortListItem();
            lstQuality.Sort(objSort.Compare);
            lstQualities.DataSource = null;
            lstQualities.ValueMember = "Value";
            lstQualities.DisplayMember = "Name";
            lstQualities.DataSource = lstQuality;
        }
Esempio n. 51
0
        private void frmSelectSkillGroup_Load(object sender, EventArgs e)
        {
            List<ListItem> lstGroups = new List<ListItem>();
            _objXmlDocument = XmlManager.Instance.Load("skills.xml");

            if (_strForceValue == "")
            {
                // Build the list of Skill Groups found in the Skills file.
                XmlNodeList objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skillgroups/name");
                foreach (XmlNode objXmlSkill in objXmlSkillList)
                {
                    bool blnAdd = true;
                    if (_strExcludeCategory != string.Empty)
                    {
                        blnAdd = false;
                        string[] strExcludes = _strExcludeCategory.Split(',');
                        string strExclude = "";
                        for (int i = 0; i <= strExcludes.Length - 1; i++)
                            strExclude += "category != \"" + strExcludes[i].Trim() + "\" and ";
                        // Remove the trailing " and ";
                        strExclude = strExclude.Substring(0, strExclude.Length - 5);

                        XmlNodeList objXmlNodeList = _objXmlDocument.SelectNodes("/chummer/skills/skill[" + strExclude + " and skillgroup = \"" + objXmlSkill.InnerText + "\"]");
                        blnAdd = objXmlNodeList.Count > 0;
                    }

                    if (blnAdd)
                    {
                        ListItem objItem = new ListItem();
                        objItem.Value = objXmlSkill.InnerText;
                        if (objXmlSkill.Attributes != null)
                        {
                            if (objXmlSkill.Attributes["translate"] != null)
                                objItem.Name = objXmlSkill.Attributes["translate"].InnerText;
                            else
                                objItem.Name = objXmlSkill.InnerText;
                        }
                        else
                            objItem.Name = objXmlSkill.InnerXml;
                        lstGroups.Add(objItem);
                    }
                }
            }
            else
            {
                ListItem objItem = new ListItem();
                objItem.Value = _strForceValue;
                objItem.Name = _strForceValue;
                lstGroups.Add(objItem);
            }
            SortListItem objSort = new SortListItem();
            lstGroups.Sort(objSort.Compare);
            cboSkillGroup.ValueMember = "Value";
            cboSkillGroup.DisplayMember = "Name";
            cboSkillGroup.DataSource = lstGroups;

            // Select the first Skill in the list.
            cboSkillGroup.SelectedIndex = 0;

            if (cboSkillGroup.Items.Count == 1)
                cmdOK_Click(sender, e);
        }
Esempio n. 52
0
		private void txtSearch_TextChanged(object sender, EventArgs e)
		{
			XmlNodeList objXmlPowerList;
			if (txtSearch.Text == "")
				objXmlPowerList = _objXmlDocument.SelectNodes("/chummer/powers/power[" + _objCharacter.Options.BookXPath() + "]");
			else
				objXmlPowerList = _objXmlDocument.SelectNodes("/chummer/powers/power[(" + _objCharacter.Options.BookXPath() + ") and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))]");

			List<ListItem> lstPower = new List<ListItem>();
			foreach (XmlNode objXmlPower in objXmlPowerList)
			{
				ListItem objItem = new ListItem();
				objItem.Value = objXmlPower["name"].InnerText;
				if (objXmlPower["translate"] != null)
					objItem.Name = objXmlPower["translate"].InnerText;
				else
					objItem.Name = objXmlPower["name"].InnerText;
				lstPower.Add(objItem);
			}
			SortListItem objSort = new SortListItem();
			lstPower.Sort(objSort.Compare);
			lstPowers.DataSource = null;
			lstPowers.ValueMember = "Value";
			lstPowers.DisplayMember = "Name";
			lstPowers.DataSource = lstPower;
		}
Esempio n. 53
0
        private void frmSelectCritterPower_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in this.Controls.OfType<Label>())
            {
                if (objLabel.Text.StartsWith("["))
                    objLabel.Text = "";
            }

            _objXmlDocument = XmlManager.Instance.Load("critterpowers.xml");

            // Populate the Category list.
            XmlNodeList objXmlCategoryList = _objXmlDocument.SelectNodes("/chummer/categories/category");
            foreach (XmlNode objXmlCategory in objXmlCategoryList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlCategory.InnerText;
                if (objXmlCategory.Attributes != null)
                {
                    if (objXmlCategory.Attributes["translate"] != null)
                        objItem.Name = objXmlCategory.Attributes["translate"].InnerText;
                    else
                        objItem.Name = objXmlCategory.InnerText;
                }
                else
                    objItem.Name = objXmlCategory.InnerXml;
                _lstCategory.Add(objItem);
            }

            if (_objCharacter.IsCritter)
                _objXmlCritterDocument = XmlManager.Instance.Load("critters.xml");
            else
                _objXmlCritterDocument = XmlManager.Instance.Load("metatypes.xml");
            XmlNode objXmlCritter = _objXmlCritterDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");

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

            // Remove Optional Powers if the Critter does not have access to them.
            if (objXmlCritter["optionalpowers"] == null)
            {
                foreach (ListItem objItem in _lstCategory)
                {
                    if (objItem.Value == "Allowed Optional Powers")
                    {
                        _lstCategory.Remove(objItem);
                        break;
                    }
                }
            }

            // Remove Free Spirit Powers if the critter is not a Free Spirit.
            if (_objCharacter.Metatype != "Free Spirit")
            {
                foreach (ListItem objItem in _lstCategory)
                {
                    if (objItem.Value == "Free Spirit")
                    {
                        _lstCategory.Remove(objItem);
                        break;
                    }
                }
            }

            // Remove Toxic Critter Powers if the critter is not a Toxic Critter.
            if (_objCharacter.MetatypeCategory != "Toxic Critters")
            {
                foreach (ListItem objItem in _lstCategory)
                {
                    if (objItem.Value == "Toxic Critter Powers")
                    {
                        _lstCategory.Remove(objItem);
                        break;
                    }
                }
            }

            // Remove Emergent Powers if the critter is not a Sprite or A.I.
            if (!_objCharacter.MetatypeCategory.EndsWith("Sprites") && !_objCharacter.MetatypeCategory.EndsWith("Sprite") && !_objCharacter.MetatypeCategory.EndsWith("A.I.s") & _objCharacter.MetatypeCategory != "Technocritters" && _objCharacter.MetatypeCategory != "Protosapients")
            {
                foreach (ListItem objItem in _lstCategory)
                {
                    if (objItem.Value == "Emergent")
                    {
                        _lstCategory.Remove(objItem);
                        break;
                    }
                }
            }

            // Remove Echoes Powers if the critter is not a Free Sprite.
            if (!_objCharacter.IsFreeSprite)
            {
                foreach (ListItem objItem in _lstCategory)
                {
                    if (objItem.Value == "Echoes")
                    {
                        _lstCategory.Remove(objItem);
                        break;
                    }
                }
            }

            // Remove Shapeshifter Powers if the critter is not a Shapeshifter.
            if (_objCharacter.MetatypeCategory != "Shapeshifter")
            {
                foreach (ListItem objItem in _lstCategory)
                {
                    if (objItem.Value == "Shapeshifter")
                    {
                        _lstCategory.Remove(objItem);
                        break;
                    }
                }
            }

            SortListItem objSort = new SortListItem();
            _lstCategory.Sort(objSort.Compare);
            cboCategory.DataSource = null;
            cboCategory.ValueMember = "Value";
            cboCategory.DisplayMember = "Name";
            cboCategory.DataSource = _lstCategory;

            // Select the first Category in the list.
            if (_strSelectCategory == "")
                cboCategory.SelectedIndex = 0;
            else
            {
                try
                {
                    cboCategory.SelectedValue = _strSelectCategory;
                }
                catch
                {
                }
            }

            if (cboCategory.SelectedIndex == -1)
                cboCategory.SelectedIndex = 0;
        }
Esempio n. 54
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            if (txtSearch.Text == "")
            {
                cboCategory_SelectedIndexChanged(sender, e);
                return;
            }

            // Treat everything as being uppercase so the search is case-insensitive.
            string strSearch = "/chummer/weapons/weapon[(" + _objCharacter.Options.BookXPath() + ") and category != \"Cyberware\" and category != \"Gear\" and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))]";

            XmlNodeList objXmlWeaponList = _objXmlDocument.SelectNodes(strSearch);
            List<ListItem> lstWeapons = new List<ListItem>();
            foreach (XmlNode objXmlWeapon in objXmlWeaponList)
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlWeapon["name"].InnerText;
                if (objXmlWeapon["translate"] != null)
                    objItem.Name = objXmlWeapon["translate"].InnerText;
                else
                    objItem.Name = objXmlWeapon["name"].InnerText;

                try
                {
                    objItem.Name += " [" + _lstCategory.Find(objFind => objFind.Value == objXmlWeapon["category"].InnerText).Name + "]";
                    lstWeapons.Add(objItem);
                }
                catch
                {
                }
            }
            SortListItem objSort = new SortListItem();
            lstWeapons.Sort(objSort.Compare);
            lstWeapon.DataSource = null;
            lstWeapon.ValueMember = "Value";
            lstWeapon.DisplayMember = "Name";
            lstWeapon.DataSource = lstWeapons;
        }
Esempio n. 55
0
        private void frmSelectSkill_Load(object sender, EventArgs e)
        {
            List<ListItem> lstSkills = new List<ListItem>();

            if (!_blnKnowledgeSkill)
            {
                _objXmlDocument = XmlManager.Instance.Load("skills.xml");

                // Build the list of non-Exotic Skills from the Skills file.
                XmlNodeList objXmlSkillList;
                if (_strForceSkill != "")
                {
                    objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skills/skill[name = \"" + _strForceSkill + "\" and not(exotic)]");
                }
                else
                {
                    if (_strIncludeCategory != "")
                        objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skills/skill[category = \"" + _strIncludeCategory + "\" and not(exotic)]");
                    else if (_strExcludeCategory != "")
                    {
                        string[] strExcludes = _strExcludeCategory.Split(',');
                        string strExclude = "";
                        for (int i = 0; i <= strExcludes.Length - 1; i++)
                            strExclude += "category != \"" + strExcludes[i].Trim() + "\" and ";
                        // Remove the trailing " and ";
                        strExclude = strExclude.Substring(0, strExclude.Length - 5);
                        objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skills/skill[" + strExclude + " and not(exotic)]");
                    }
                    else if (_strIncludeSkillGroup != "")
                        objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skills/skill[skillgroup = \"" + _strIncludeSkillGroup + "\" and not(exotic)]");
                    else if (_strExcludeSkillGroup != "")
                        objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skills/skill[skillgroup != \"" + _strExcludeSkillGroup + "\" and not(exotic)]");
                    else if (_strLimitToSkill != "")
                    {
                        string strFilter = "not(exotic) and (";
                        string[] strValue = _strLimitToSkill.Split(',');
                        foreach (string strSkill in strValue)
                            strFilter += "name = \"" + strSkill.Trim() + "\" or ";
                        // Remove the trailing " or ".
                        strFilter = strFilter.Substring(0, strFilter.Length - 4);
                        strFilter += ")";
                        objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skills/skill[" + strFilter + "]");
                    }
                    else
                        objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skills/skill[not(exotic)]");
                }

                // Add the Skills to the list.
                foreach (XmlNode objXmlSkill in objXmlSkillList)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlSkill["name"].InnerText;
                    if (objXmlSkill.Attributes != null)
                    {
                        if (objXmlSkill["translate"] != null)
                            objItem.Name = objXmlSkill["translate"].InnerText;
                        else
                            objItem.Name = objXmlSkill["name"].InnerText;
                    }
                    else
                        objItem.Name = objXmlSkill["name"].InnerXml;
                    lstSkills.Add(objItem);
                }

                // Add in any Exotic Skills the character has.
                foreach (Skill objSkill in _objCharacter.Skills)
                {
                    if (objSkill.ExoticSkill)
                    {
                        bool blnAddSkill = true;
                        if (_strForceSkill != "")
                            blnAddSkill = _strForceSkill == objSkill.Name + " (" + objSkill.Specialization + ")";
                        else
                        {
                            if (_strIncludeCategory != "")
                                blnAddSkill = _strIncludeCategory == objSkill.SkillCategory;
                            else if (_strExcludeCategory != "")
                                blnAddSkill = !_strExcludeCategory.Contains(objSkill.SkillCategory);
                            else if (_strIncludeSkillGroup != "")
                                blnAddSkill = _strIncludeSkillGroup == objSkill.SkillGroup;
                            else if (_strExcludeSkillGroup != "")
                                blnAddSkill = _strExcludeSkillGroup != objSkill.SkillGroup;
                            else if (_strLimitToSkill != "")
                                blnAddSkill = _strLimitToSkill.Contains(objSkill.Name);
                        }

                        if (blnAddSkill)
                        {
                            ListItem objItem = new ListItem();
                            objItem.Value = objSkill.Name + " (" + objSkill.Specialization + ")";
                            // Use the translated Exotic Skill name if available.
                            XmlNode objXmlSkill = _objXmlDocument.SelectSingleNode("/chummer/skills/skill[exotic = \"Yes\" and name = \"" + objSkill.Name + "\"]");
                            if (objXmlSkill["translate"] != null)
                                objItem.Name = objXmlSkill["translate"].InnerText + " (" + objSkill.Specialization + ")";
                            else
                                objItem.Name = objSkill.Name + " (" + objSkill.Specialization + ")";
                            lstSkills.Add(objItem);
                        }
                    }
                }
            }
            else
            {
                // Instead of showing all available Active Skills, show a list of Knowledge Skills that the character currently has.
                foreach (Skill objKnow in _objCharacter.Skills)
                {
                    if (objKnow.KnowledgeSkill)
                    {
                        ListItem objSkill = new ListItem();
                        objSkill.Value = objKnow.Name;
                        objSkill.Name = objKnow.DisplayName;
                        lstSkills.Add(objSkill);
                    }
                }
            }
            SortListItem objSort = new SortListItem();
            lstSkills.Sort(objSort.Compare);
            cboSkill.ValueMember = "Value";
            cboSkill.DisplayMember = "Name";
            cboSkill.DataSource = lstSkills;

            // Select the first Skill in the list.
            cboSkill.SelectedIndex = 0;

            if (cboSkill.Items.Count == 1)
                cmdOK_Click(sender, e);
        }
Esempio n. 56
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;
        }
Esempio n. 57
0
        /// <summary>
        /// Build the list of Skill Groups.
        /// </summary>
        private void BuildSkillGroupList()
        {
            XmlDocument objXmlDocument = XmlManager.Instance.Load("skills.xml");

            // Populate the Skill Group list.
            XmlNodeList objXmlGroupList = objXmlDocument.SelectNodes("/chummer/skillgroups/name");

            // First pass, build up a list of all of the Skill Groups so we can sort them in alphabetical order for the current language.
            List<ListItem> lstSkillOrder = new List<ListItem>();
            foreach (XmlNode objXmlGroup in objXmlGroupList)
            {
                ListItem objGroup = new ListItem();
                objGroup.Value = objXmlGroup.InnerText;
                if (objXmlGroup.Attributes["translate"] != null)
                    objGroup.Name = objXmlGroup.Attributes["translate"].InnerText;
                else
                    objGroup.Name = objXmlGroup.InnerText;
                lstSkillOrder.Add(objGroup);
            }
            SortListItem objSort = new SortListItem();
            lstSkillOrder.Sort(objSort.Compare);

            // Second pass, retrieve the Skill Groups in the order they're presented in the list.
            foreach (ListItem objItem in lstSkillOrder)
            {
                XmlNode objXmlGroup = objXmlDocument.SelectSingleNode("/chummer/skillgroups/name[. = \"" + objItem.Value + "\"]");
                SkillGroup objGroup = new SkillGroup();
                objGroup.Name = objXmlGroup.InnerText;
                // Maximum Skill Group Rating
                objGroup.RatingMaximum = 6;
                _lstSkillGroups.Add(objGroup);
            }
        }
        /// <summary>
        /// Build the list of Mods.
        /// </summary>
        private void BuildModList()
        {
            foreach (Label objLabel in this.Controls.OfType<Label>())
            {
                if (objLabel.Text.StartsWith("["))
                    objLabel.Text = "";
            }

            // Update the list of Mods based on the selected Category.
            XmlNodeList objXmlModList;

            // Load the Mod information.
            _objXmlDocument = XmlManager.Instance.Load(_strInputFile + ".xml");

            // Retrieve the list of Mods for the selected Category.
            if (txtSearch.Text == "")
                objXmlModList = _objXmlDocument.SelectNodes("/chummer/mods/mod[(" + _objCharacter.Options.BookXPath() + ") and category != \"Special\"]");
            else
                objXmlModList = _objXmlDocument.SelectNodes("/chummer/mods/mod[(" + _objCharacter.Options.BookXPath() + ") and category != \"Special\" and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))]");
            bool blnAdd = true;
            List<ListItem> lstMods = new List<ListItem>();
            foreach (XmlNode objXmlMod in objXmlModList)
            {
                blnAdd = true;
                if (objXmlMod["response"] != null)
                {
                    if (Convert.ToInt32(objXmlMod["response"].InnerText) > _intMaxResponse || Convert.ToInt32(objXmlMod["response"].InnerText) <= _intDeviceRating)
                        blnAdd = false;
                }
                if (objXmlMod["system"] != null)
                {
                    if (Convert.ToInt32(objXmlMod["system"].InnerText) <= _intDeviceRating)
                        blnAdd = false;
                }
                if (objXmlMod["firewall"] != null)
                {
                    if (Convert.ToInt32(objXmlMod["firewall"].InnerText) <= _intDeviceRating)
                        blnAdd = false;
                }
                if (objXmlMod["signal"] != null)
                {
                    if (Convert.ToInt32(objXmlMod["signal"].InnerText) > _intMaxSignal || Convert.ToInt32(objXmlMod["signal"].InnerText) <= _intDeviceRating)
                        blnAdd = false;
                }

                if (blnAdd)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlMod["name"].InnerText;
                    if (objXmlMod["translate"] != null)
                        objItem.Name = objXmlMod["translate"].InnerText;
                    else
                        objItem.Name = objXmlMod["name"].InnerText;
                    lstMods.Add(objItem);
                }
            }
            SortListItem objSort = new SortListItem();
            lstMods.Sort(objSort.Compare);
            lstMod.DataSource = null;
            lstMod.ValueMember = "Value";
            lstMod.DisplayMember = "Name";
            lstMod.DataSource = lstMods;
        }
Esempio n. 59
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");
	        
        }
Esempio n. 60
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;
        }