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;
		}
Exemplo n.º 2
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;
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
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;
                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;
        }
Exemplo n.º 6
0
		private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
		{
			// Update the list of Kits based on the selected Category.
			List<ListItem> lstKit = new List<ListItem>();

			// Retrieve the list of Kits for the selected Category.
			XmlNodeList objXmlPacksList = _objXmlDocument.SelectNodes("/chummer/packs/pack[category = \"" + cboCategory.SelectedValue + "\"]");
			foreach (XmlNode objXmlPack in objXmlPacksList)
			{
				ListItem objItem = new ListItem();
				objItem.Value = objXmlPack["name"].InnerText;
				if (objXmlPack["translate"] != null)
					objItem.Name = objXmlPack["translate"].InnerText;
				else
					objItem.Name = objXmlPack["name"].InnerText;
				lstKit.Add(objItem);
			}
			SortListItem objSort = new SortListItem();
			lstKit.Sort(objSort.Compare);
			lstKits.DataSource = null;
			lstKits.ValueMember = "Value";
			lstKits.DisplayMember = "Name";
			lstKits.DataSource = lstKit;

			if (lstKits.Items.Count == 0)
				treContents.Nodes.Clear();

			if (cboCategory.SelectedValue.ToString() == "Custom")
			    cmdDelete.Visible = true;
			else
			    cmdDelete.Visible = false;
		}
Exemplo n.º 7
0
		private void frmSelectWeaponCategory_Load(object sender, EventArgs e)
		{
			_objXmlDocument = XmlManager.Instance.Load("weapons.xml");

			// Build a list of Weapon Categories found in the Weapons file.
			XmlNodeList objXmlCategoryList;
			List<ListItem> lstCategory = new List<ListItem>();
			if (_strForceCategory != "")
			{
				objXmlCategoryList = _objXmlDocument.SelectNodes("/chummer/categories/category[. = \"" + _strForceCategory + "\"]");
			}
			else
			{
				objXmlCategoryList = _objXmlDocument.SelectNodes("/chummer/categories/category");
			}

			foreach (XmlNode objXmlCategory in objXmlCategoryList)
			{
				if (WeaponType != null)
				{
					if (objXmlCategory.Attributes["type"] == null)
						continue;

					if (objXmlCategory.Attributes["type"].Value != WeaponType)
						continue;
				}

				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.InnerText;
				lstCategory.Add(objItem);
			}

			// Add the Cyberware Category.
			if (/*_strForceCategory == "" ||*/ _strForceCategory == "Cyberware")
			{
				ListItem objItem = new ListItem();
				objItem.Value = "Cyberware";
				objItem.Name = "Cyberware";
				lstCategory.Add(objItem);
			}
			cboCategory.ValueMember = "Value";
			cboCategory.DisplayMember = "Name";
			cboCategory.DataSource = lstCategory;

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

			if (cboCategory.Items.Count == 1)
				cmdOK_Click(sender, e);
		}
Exemplo n.º 8
0
        public frmSelectBP(Character objCharacter, bool blnUseCurrentValues = false)
        {
            _objCharacter = objCharacter;
            _objOptions = _objCharacter.Options;
            _blnUseCurrentValues = blnUseCurrentValues;
            InitializeComponent();
            LanguageManager.Instance.Load(this);

            // Populate the Build Method list.
            List<ListItem> lstBuildMethod = new List<ListItem>();
            //ListItem objBP = new ListItem();
            //objBP.Value = "BP";
            //objBP.Name = LanguageManager.Instance.GetString("String_BP");

            //ListItem objKarma = new ListItem();
            //objKarma.Value = "Karma";
            //objKarma.Name = LanguageManager.Instance.GetString("String_Karma");

            ListItem objPriority = new ListItem();
            objPriority.Value = "Priority";
            objPriority.Name = LanguageManager.Instance.GetString("String_Priority");

            //lstBuildMethod.Add(objBP);
            //lstBuildMethod.Add(objKarma);
            lstBuildMethod.Add(objPriority);
            cboBuildMethod.DataSource = lstBuildMethod;
            cboBuildMethod.ValueMember = "Value";
            cboBuildMethod.DisplayMember = "Name";

            cboBuildMethod.SelectedValue = _objOptions.BuildMethod;
            nudBP.Value = _objOptions.BuildPoints;
            nudMaxAvail.Value = _objOptions.Availability;

            toolTip1.SetToolTip(chkIgnoreRules, LanguageManager.Instance.GetString("Tip_SelectBP_IgnoreRules"));

            if (blnUseCurrentValues)
            {
                //if (objCharacter.BuildMethod == CharacterBuildMethod.Karma)
                //{
                //    cboBuildMethod.SelectedValue = "Karma";
                //    nudBP.Value = objCharacter.BuildKarma;
                //}
                //else if (objCharacter.BuildMethod == CharacterBuildMethod.BP)
                //{
                //    cboBuildMethod.SelectedValue = "BP";
                //    nudBP.Value = objCharacter.BuildPoints;
                //}
                cboBuildMethod.SelectedValue = "Priority";
                nudBP.Value = objCharacter.BuildKarma;

                nudMaxAvail.Value = objCharacter.MaximumAvailability;

                cboBuildMethod.Enabled = false;
            }
        }
Exemplo n.º 9
0
		/// <summary>
		/// Limit the list to a single Power.
		/// </summary>
		/// <param name="strValue">Single Power to display.</param>
		public void SinglePower(string strValue)
		{
			List<ListItem> lstItems = new List<ListItem>();
			ListItem objItem = new ListItem();
			objItem.Value = strValue;
			objItem.Name = strValue;
			lstItems.Add(objItem);
			cboPower.DataSource = null;
			cboPower.ValueMember = "Value";
			cboPower.DisplayMember = "Name";
			cboPower.DataSource = lstItems;
		}
Exemplo n.º 10
0
		private void frmReload_Load(object sender, EventArgs e)
		{
			List<ListItem> lstAmmo = new List<ListItem>();

			// Add each of the items to a new List since we need to also grab their plugin information.
			foreach (Gear objGear in _lstAmmo)
			{
				ListItem objAmmo = new ListItem();
				objAmmo.Value = objGear.InternalId;
				objAmmo.Name = objGear.DisplayNameShort;
				objAmmo.Name += " x" + objGear.Quantity.ToString();
				if (objGear.Parent != null)
				{
					if (objGear.Parent.DisplayNameShort != string.Empty)
					{
						objAmmo.Name += " (" + objGear.Parent.DisplayNameShort;
						if (objGear.Parent.Location != string.Empty)
							objAmmo.Name += " @ " + objGear.Parent.Location;
						objAmmo.Name += ")";
					}
				}
				if (objGear.Location != string.Empty)
					objAmmo.Name += " (" + objGear.Location + ")";
				// Retrieve the plugin information if it has any.
				if (objGear.Children.Count > 0)
				{
					string strPlugins = "";
					foreach (Gear objChild in objGear.Children)
					{
						strPlugins += objChild.DisplayNameShort + ", ";
					}
					// Remove the trailing comma.
					strPlugins = strPlugins.Substring(0, strPlugins.Length - 2);
					// Append the plugin information to the name.
					objAmmo.Name += " [" + strPlugins + "]";
				}
				lstAmmo.Add(objAmmo);
			}

			// Populate the lists.
			cboAmmo.DataSource = lstAmmo;
			cboAmmo.ValueMember = "Value";
			cboAmmo.DisplayMember = "Name";

			cboType.DataSource = _lstCount;

			// If there's only 1 value in each list, the character doesn't have a choice, so just accept it.
			if (cboAmmo.Items.Count == 1 && cboType.Items.Count == 1)
				AcceptForm();
		}
Exemplo n.º 11
0
        private void frmSelectLifestyleQuality_Load(object sender, EventArgs e)
        {
            _objXmlDocument = XmlManager.Instance.Load("lifestyles.xml");

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

            // Load the Quality information.
            _objXmlDocument = XmlManager.Instance.Load("lifestyles.xml");

            // Populate the Quality 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);
            }
            cboCategory.ValueMember = "Value";
            cboCategory.DisplayMember = "Name";
            cboCategory.DataSource = _lstCategory;

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

            if (cboCategory.SelectedIndex == -1)
                cboCategory.SelectedIndex = 0;

            // Change the BP Label to Karma if the character is being built with Karma instead (or is in Career Mode).
            if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma || _objCharacter.BuildMethod == CharacterBuildMethod.Priority || _objCharacter.Created)
                lblBPLabel.Text = LanguageManager.Instance.GetString("Label_Karma");

            BuildQualityList();
        }
		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;
		}
Exemplo n.º 13
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;
			}
		}
Exemplo n.º 14
0
 /// <summary>
 /// Limit the list to a few Powers.
 /// </summary>
 /// <param name="strValue">List of Powers.</param>
 public void LimitToList(List<string> strValue)
 {
     _lstPowers.Clear();
     foreach (string strPower in strValue)
     {
         ListItem objItem = new ListItem();
         objItem.Value = strPower;
         objItem.Name = strPower;
         _lstPowers.Add(objItem);
     }
     cboPower.DataSource = null;
     cboPower.DataSource = _lstPowers;
     cboPower.ValueMember = "Value";
     cboPower.DisplayMember = "Name";
 }
Exemplo n.º 15
0
 /// <summary>
 /// Limit the list to a few Limits.
 /// </summary>
 /// <param name="strValue">List of Limits.</param>
 public void LimitToList(List<string> strValue)
 {
     _lstLimits.Clear();
     foreach (string strLimit in strValue)
     {
         ListItem objItem = new ListItem();
         objItem.Value = strLimit;
         objItem.Name = LanguageManager.Instance.GetString("String_Limit" + strLimit + "Short");
         _lstLimits.Add(objItem);
     }
     cboLimit.DataSource = null;
     cboLimit.DataSource = _lstLimits;
     cboLimit.ValueMember = "Value";
     cboLimit.DisplayMember = "Name";
 }
Exemplo n.º 16
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;
        }
Exemplo n.º 17
0
        public frmSelectAttribute()
        {
            InitializeComponent();
            LanguageManager.Instance.Load(this);

            // Build the list of Attributes.
            ListItem objBOD = new ListItem();
            ListItem objAGI = new ListItem();
            ListItem objREA = new ListItem();
            ListItem objSTR = new ListItem();
            ListItem objCHA = new ListItem();
            ListItem objINT = new ListItem();
            ListItem objLOG = new ListItem();
            ListItem objWIL = new ListItem();
            ListItem objEDG = new ListItem();
            objBOD.Value = "BOD";
            objBOD.Name = LanguageManager.Instance.GetString("String_AttributeBODShort");
            objAGI.Value = "AGI";
            objAGI.Name = LanguageManager.Instance.GetString("String_AttributeAGIShort");
            objREA.Value = "REA";
            objREA.Name = LanguageManager.Instance.GetString("String_AttributeREAShort");
            objSTR.Value = "STR";
            objSTR.Name = LanguageManager.Instance.GetString("String_AttributeSTRShort");
            objCHA.Value = "CHA";
            objCHA.Name = LanguageManager.Instance.GetString("String_AttributeCHAShort");
            objINT.Value = "INT";
            objINT.Name = LanguageManager.Instance.GetString("String_AttributeINTShort");
            objLOG.Value = "LOG";
            objLOG.Name = LanguageManager.Instance.GetString("String_AttributeLOGShort");
            objWIL.Value = "WIL";
            objWIL.Name = LanguageManager.Instance.GetString("String_AttributeWILShort");
            objEDG.Value = "EDG";
            objEDG.Name = LanguageManager.Instance.GetString("String_AttributeEDGShort");
            _lstAttributes.Add(objBOD);
            _lstAttributes.Add(objAGI);
            _lstAttributes.Add(objREA);
            _lstAttributes.Add(objSTR);
            _lstAttributes.Add(objCHA);
            _lstAttributes.Add(objINT);
            _lstAttributes.Add(objLOG);
            _lstAttributes.Add(objWIL);
            _lstAttributes.Add(objEDG);

            cboAttribute.ValueMember = "Value";
            cboAttribute.DisplayMember = "Name";
            cboAttribute.DataSource = _lstAttributes;
        }
Exemplo n.º 18
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 frmSelectWeapon_Load(object sender, EventArgs e)
        {
			foreach (Label objLabel in this.Controls.OfType<Label>())
			{
				if (objLabel.Text.StartsWith("["))
					objLabel.Text = "";
			}

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

            // Populate the Weapon 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);
			}
			cboCategory.ValueMember = "Value";
			cboCategory.DisplayMember = "Name";
			cboCategory.DataSource = _lstCategory;

			chkBlackMarketDiscount.Visible = _objCharacter.BlackMarketDiscount;

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

			if (cboCategory.SelectedIndex == -1)
				cboCategory.SelectedIndex = 0;

            if (chkBrowse.Checked)
                LoadGrid();
        }
		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;
		}
Exemplo n.º 21
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;
		}
Exemplo n.º 22
0
        public frmDiceRoller(frmMain frmMainForm, List<Quality> lstQualities = null, int intDice = 1)
        {
            InitializeComponent();
            LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this);
            _frmMain = frmMainForm;
            _RNG = new MTRNG();
            nudDice.Value = intDice;
            if (lstQualities != null)
            {
                foreach (Quality objQuality in lstQualities)
                {
                    if (objQuality.Name.StartsWith("Gremlins"))
                    {
                        int intRating = Convert.ToInt32(objQuality.Name.Substring(objQuality.Name.Length - 2, 1));
                        nudGremlins.Value = intRating;
                    }
                }
            }
            MoveControls();

            List<ListItem> lstMethod = new List<ListItem>();
            ListItem itmStandard = new ListItem();
            itmStandard.Value = "Standard";
            itmStandard.Name = LanguageManager.Instance.GetString("String_DiceRoller_Standard");

            ListItem itmLarge = new ListItem();
            itmLarge.Value = "Large";
            itmLarge.Name = LanguageManager.Instance.GetString("String_DiceRoller_Large");

            ListItem itmReallyLarge = new ListItem();
            itmReallyLarge.Value = "ReallyLarge";
            itmReallyLarge.Name = LanguageManager.Instance.GetString("String_DiceRoller_ReallyLarge");

            lstMethod.Add(itmStandard);
            lstMethod.Add(itmLarge);
            lstMethod.Add(itmReallyLarge);

            cboMethod.ValueMember = "Value";
            cboMethod.DisplayMember = "Name";
            cboMethod.DataSource = lstMethod;
            cboMethod.SelectedIndex = 0;
        }
Exemplo n.º 23
0
		private void frmSelectSpellCategory_Load(object sender, EventArgs e)
		{
			_objXmlDocument = XmlManager.Instance.Load("spells.xml");

			// Build the list of Spell Categories from the Spells file.
			XmlNodeList objXmlCategoryList;
			List<ListItem> lstCategory = new List<ListItem>();
			if (_strForceCategory != "")
			{
				objXmlCategoryList = _objXmlDocument.SelectNodes("/chummer/categories/category[. = \"" + _strForceCategory + "\"]");
			}
			else
			{
				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.InnerText;
				lstCategory.Add(objItem);
			}

			cboCategory.ValueMember = "Value";
			cboCategory.DisplayMember = "Name";
			cboCategory.DataSource = lstCategory;

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

			if (cboCategory.Items.Count == 1)
				cmdOK_Click(sender, e);
		}
Exemplo n.º 24
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;
		}
Exemplo n.º 25
0
        public frmSelectSide()
        {
            InitializeComponent();
            LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this);

            // Create a list for the sides.
            List<ListItem> lstSides = new List<ListItem>();
            ListItem objLeft = new ListItem();
            objLeft.Value = "Left";
            objLeft.Name = LanguageManager.Instance.GetString("String_Improvement_SideLeft");

            ListItem objRight = new ListItem();
            objRight.Value = "Right";
            objRight.Name = LanguageManager.Instance.GetString("String_Improvement_SideRight");

            lstSides.Add(objLeft);
            lstSides.Add(objRight);

            cboSide.DataSource = lstSides;
            cboSide.ValueMember = "Value";
            cboSide.DisplayMember = "Name";
        }
Exemplo n.º 26
0
		/// <summary>
		/// Populate the Created Status list.
		/// </summary>
		public void PopulateMode()
		{
			List<ListItem> lstMode = new List<ListItem>();

			ListItem objAny = new ListItem();
			objAny.Value = "-1";
			objAny.Name = "Any Mode";
			lstMode.Add(objAny);

			ListItem objCreate = new ListItem();
			objCreate.Value = "0";
			objCreate.Name = "Create Mode";
			lstMode.Add(objCreate);

			ListItem objCareer = new ListItem();
			objCareer.Value = "1";
			objCareer.Name = "Career Mode";
			lstMode.Add(objCareer);

			cboFilterMode.DataSource = lstMode;
			cboFilterMode.ValueMember = "Value";
			cboFilterMode.DisplayMember = "Name";
		}
Exemplo n.º 27
0
		/// <summary>
		/// Populate the sort order list.
		/// </summary>
		public void PopulateSortOrder()
		{
			List<ListItem> lstSort = new List<ListItem>();

			ListItem objName = new ListItem();
			objName.Value = "0";
			objName.Name = "Name";
			lstSort.Add(objName);

			ListItem objDate = new ListItem();
			objDate.Value = "1";
			objDate.Name = "Most Recent";
			lstSort.Add(objDate);

			ListItem objPopular = new ListItem();
			objPopular.Value = "2";
			objPopular.Name = "Most Downloaded";
			lstSort.Add(objPopular);

			cboSortOrder.DataSource = lstSort;
			cboSortOrder.ValueMember = "Value";
			cboSortOrder.DisplayMember = "Name";
		}
Exemplo n.º 28
0
        public frmSelectLimit()
        {
            InitializeComponent();
			LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this);

			// Build the list of Limits.
			ListItem objPhysical = new ListItem();
			ListItem objMental = new ListItem();
			ListItem objSocial = new ListItem();
            objPhysical.Value = "Physical";
            objPhysical.Name = LanguageManager.Instance.GetString("Node_Physical");
            objMental.Value = "Mental";
            objMental.Name = LanguageManager.Instance.GetString("Node_Mental");
            objSocial.Value = "Social";
            objSocial.Name = LanguageManager.Instance.GetString("Node_Social");
            _lstLimits.Add(objPhysical);
            _lstLimits.Add(objMental);
            _lstLimits.Add(objSocial);

			cboLimit.ValueMember = "Value";
			cboLimit.DisplayMember = "Name";
			cboLimit.DataSource = _lstLimits;
        }
Exemplo n.º 29
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;
            }
        }
Exemplo n.º 30
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;
                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;
        }
Exemplo n.º 31
0
        /// <summary>
        /// Build the list of Mods.
        /// </summary>
        private void BuildModList()
        {
            // Select the first Category in the list.
            if (string.IsNullOrEmpty(_strSelectCategory))
            {
                cboCategory.SelectedIndex = 0;
            }
            else
            {
                cboCategory.SelectedValue = _strSelectCategory;
            }

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

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

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

            // Load the Vehicle information.
            _objXmlDocument = XmlManager.Instance.Load("vehicles.xml");

            XmlNode objXmlVehicleNode = _objXmlDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + _objVehicle.Name + "\"]");

            // Retrieve the list of Mods for the selected Category.
            if (string.IsNullOrEmpty(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() + "\"))]");
            }
            List <ListItem> lstMods = new List <ListItem>();

            if (objXmlModList != null)
            {
                foreach (XmlNode objXmlMod in objXmlModList)
                {
                    if (objXmlMod["hidden"] != null)
                    {
                        continue;
                    }

                    if (objXmlMod["forbidden"]?["vehicledetails"] != null)
                    {
                        // Assumes topmost parent is an AND node
                        if (objXmlVehicleNode.ProcessFilterOperationNode(objXmlMod["forbidden"]["vehicledetails"], false))
                        {
                            continue;
                        }
                    }
                    if (objXmlMod["required"]?["vehicledetails"] != null)
                    {
                        // Assumes topmost parent is an AND node
                        if (!objXmlVehicleNode.ProcessFilterOperationNode(objXmlMod["required"]["vehicledetails"], false))
                        {
                            continue;
                        }
                    }

                    if (objXmlMod["forbidden"]?["oneof"] != null)
                    {
                        XmlNodeList objXmlForbiddenList = objXmlMod.SelectNodes("forbidden/oneof/mods");
                        //Add to set for O(N log M) runtime instead of O(N * M)

                        HashSet <string> objForbiddenAccessory = new HashSet <string>();
                        foreach (XmlNode node in objXmlForbiddenList)
                        {
                            objForbiddenAccessory.Add(node.InnerText);
                        }

                        foreach (VehicleMod objAccessory in _lstMods.Where(objAccessory => objForbiddenAccessory.Contains(objAccessory.Name)))
                        {
                            goto NextItem;
                        }
                    }

                    if (objXmlMod["required"]?["oneof"] != null)
                    {
                        bool        boolCanAdd         = false;
                        XmlNodeList objXmlRequiredList = objXmlMod.SelectNodes("required/oneof/mods");
                        //Add to set for O(N log M) runtime instead of O(N * M)

                        HashSet <string> objRequiredAccessory = new HashSet <string>();
                        foreach (XmlNode node in objXmlRequiredList)
                        {
                            objRequiredAccessory.Add(node.InnerText);
                        }

                        foreach (VehicleMod objAccessory in _lstMods.Where(objAccessory => objRequiredAccessory.Contains(objAccessory.Name)))
                        {
                            boolCanAdd = true;
                            break;
                        }
                        if (!boolCanAdd)
                        {
                            continue;
                        }
                    }

                    XmlNode objXmlRequirements = objXmlMod.SelectSingleNode("requires");
                    if (objXmlRequirements != null)
                    {
                        if (_objVehicle.Seats < Convert.ToInt32(objXmlRequirements["seats"]?.InnerText))
                        {
                            continue;
                        }
                    }

                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlMod["id"].InnerText;
                    objItem.Name  = objXmlMod["translate"]?.InnerText ?? objXmlMod["name"].InnerText;
                    lstMods.Add(objItem);
                    NextItem :;
                }
            }
            SortListItem objSort = new SortListItem();

            lstMods.Sort(objSort.Compare);
            lstMod.BeginUpdate();
            lstMod.DataSource    = null;
            lstMod.ValueMember   = "Value";
            lstMod.DisplayMember = "Name";
            lstMod.DataSource    = lstMods;
            lstMod.EndUpdate();
        }
Exemplo n.º 32
0
        /// <summary>
        /// Update the Program List based on a base program node list.
        /// </summary>
        private void UpdateProgramList(XmlNodeList objXmlNodeList)
        {
            List <ListItem> lstPrograms           = new List <ListItem>();
            bool            blnCheckForOptional   = false;
            XmlNode         objXmlCritter         = null;
            XmlDocument     objXmlCritterDocument = null;

            if (_objCharacter.IsCritter)
            {
                objXmlCritterDocument = XmlManager.Load("critters.xml");
                objXmlCritter         = objXmlCritterDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
                if (objXmlCritter.InnerXml.Contains("<optionalaiprograms>"))
                {
                    blnCheckForOptional = true;
                }
            }

            foreach (XmlNode objXmlProgram in objXmlNodeList)
            {
                bool blnAdd = true;
                if (chkLimitList.Checked && objXmlProgram["require"] != null)
                {
                    blnAdd = false;
                    foreach (AIProgram objAIProgram in _objCharacter.AIPrograms)
                    {
                        if (objAIProgram.Name == objXmlProgram["require"].InnerText)
                        {
                            blnAdd = true;
                            break;
                        }
                    }
                    if (!blnAdd)
                    {
                        continue;
                    }
                }
                // If this is a critter with Optional Programs, see if this Program is allowed.
                if (blnCheckForOptional)
                {
                    blnAdd = false;
                    foreach (XmlNode objXmlForm in objXmlCritter.SelectNodes("optionalaiprograms/program"))
                    {
                        if (objXmlForm.InnerText == objXmlProgram["name"].InnerText)
                        {
                            blnAdd = true;
                            break;
                        }
                    }
                    if (!blnAdd)
                    {
                        continue;
                    }
                }
                string strDisplayName = objXmlProgram["translate"]?.InnerText ?? objXmlProgram["name"].InnerText;
                if (!_objCharacter.Options.SearchInCategoryOnly && txtSearch.TextLength != 0)
                {
                    string strCategory = objXmlProgram["category"]?.InnerText;
                    if (!string.IsNullOrEmpty(strCategory))
                    {
                        ListItem objFoundItem = _lstCategory.Find(objFind => objFind.Value == strCategory);
                        if (!string.IsNullOrEmpty(objFoundItem.Name))
                        {
                            strDisplayName += " [" + objFoundItem.Name + "]";
                        }
                    }
                }
                lstPrograms.Add(new ListItem(objXmlProgram["id"].InnerText, strDisplayName));
            }

            lstPrograms.Sort(CompareListItems.CompareNames);
            lstAIPrograms.BeginUpdate();
            lstAIPrograms.DataSource    = null;
            lstAIPrograms.ValueMember   = "Value";
            lstAIPrograms.DisplayMember = "Name";
            lstAIPrograms.DataSource    = lstPrograms;
            lstAIPrograms.EndUpdate();
        }
Exemplo n.º 33
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;
            }
        }
Exemplo n.º 34
0
        private void frmSelectArmor_Load(object sender, EventArgs e)
        {
            foreach (Label objLabel in this.Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith("["))
                {
                    objLabel.Text = "";
                }
            }

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

            // Populate the Armor 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);
            }
            cboCategory.ValueMember        = "Value";
            cboCategory.DisplayMember      = "Name";
            cboCategory.DataSource         = _lstCategory;
            chkBlackMarketDiscount.Visible = _objCharacter.BlackMarketDiscount;
            // Select the first Category in the list.
            if (_strSelectCategory == "")
            {
                cboCategory.SelectedIndex = 0;
            }
            else
            {
                cboCategory.SelectedValue = _strSelectCategory;
            }

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

            if (chkBrowse.Checked)
            {
                LoadGrid();
            }
        }
        private void frmSelectAdvancedLifestyle_Load(object sender, EventArgs e)
        {
            _blnSkipRefresh = true;

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

            // Load the Lifestyles information.
            _objXmlDocument = XmlManager.Instance.Load("lifestyles.xml");

            // Populate the Lifestyle ComboBoxes.
            List <ListItem> lstLifestyle = new List <ListItem>();

            foreach (XmlNode objXmlComfort in _objXmlDocument.SelectNodes("/chummer/lifestyles/lifestyle"))
            {
                ListItem objItem = new ListItem();
                objItem.Value = objXmlComfort["name"].InnerText;
                if (objXmlComfort["translate"] != null)
                {
                    objItem.Name = objXmlComfort["translate"].InnerText;
                }
                else
                {
                    objItem.Name = objXmlComfort["name"].InnerText;
                }
                lstLifestyle.Add(objItem);
            }
            cboLifestyle.ValueMember   = "Name";
            cboLifestyle.DisplayMember = "Name";
            cboLifestyle.DataSource    = lstLifestyle;

            cboLifestyle.SelectedValue = _objLifestyle.BaseLifestyle;
            if (cboLifestyle.SelectedIndex == -1)
            {
                cboLifestyle.SelectedIndex = 0;
            }

            // Fill the Options list.
            foreach (XmlNode objXmlOption in _objXmlDocument.SelectNodes("/chummer/qualities/quality"))
            {
                TreeNode nodOption = new TreeNode();

                XmlNode nodCost = objXmlOption["lifestylecost"];
                if (nodCost != null)
                {
                    string strCost = nodCost.InnerText;
                    int    intCost = Convert.ToInt32(strCost);
                    if (intCost > 0)
                    {
                        nodOption.Tag = objXmlOption["name"].InnerText + " [+" + intCost.ToString() + "%]";
                        if (objXmlOption["translate"] != null)
                        {
                            nodOption.Text = objXmlOption["translate"].InnerText + " [+" + intCost.ToString() + "%]";
                        }
                        else
                        {
                            nodOption.Text = objXmlOption["name"].InnerText + " [+" + intCost.ToString() + "%]";
                        }
                        treQualities.Nodes.Add(nodOption);
                    }
                    else
                    {
                        nodOption.Tag = objXmlOption["name"].InnerText + " [" + intCost.ToString() + "%]";
                        if (objXmlOption["translate"] != null)
                        {
                            nodOption.Text = objXmlOption["translate"].InnerText + " [" + intCost.ToString() + "%]";
                        }
                        else
                        {
                            nodOption.Text = objXmlOption["name"].InnerText + " [" + intCost.ToString() + "%]";
                        }
                        treQualities.Nodes.Add(nodOption);
                    }
                }
                else
                {
                    string strCost = objXmlOption["cost"].InnerText;
                    nodOption.Tag = objXmlOption["name"].InnerText + " [" + strCost + "¥]";
                    if (objXmlOption["translate"] != null)
                    {
                        nodOption.Text = objXmlOption["translate"].InnerText + " [" + strCost + "¥]";
                    }
                    else
                    {
                        nodOption.Text = objXmlOption["name"].InnerText + " [" + strCost + "¥]";
                    }
                    treQualities.Nodes.Add(nodOption);
                }
            }

            SortTree(treQualities);

            if (_objSourceLifestyle != null)
            {
                txtLifestyleName.Text      = _objSourceLifestyle.Name;
                cboLifestyle.SelectedValue = _objSourceLifestyle.BaseLifestyle;
                nudRoommates.Value         = _objSourceLifestyle.Roommates;
                nudPercentage.Value        = _objSourceLifestyle.Percentage;
                foreach (string strQuality in _objSourceLifestyle.Qualities)
                {
                    foreach (TreeNode objNode in treQualities.Nodes)
                    {
                        if (objNode.Tag.ToString() == strQuality)
                        {
                            objNode.Checked = true;
                            break;
                        }
                    }
                }
            }

            _blnSkipRefresh = false;
            CalculateValues();
        }
Exemplo n.º 36
0
        // Rebuild the list of Spirits/Sprites based on the character's selected Tradition/Stream.
        public void RebuildSpiritList(string strTradition)
        {
            string strCurrentValue = string.Empty;

            if (strTradition.Length == 0)
            {
                return;
            }
            if (cboSpiritName.SelectedValue != null)
            {
                strCurrentValue = cboSpiritName.SelectedValue.ToString();
            }
            else
            {
                strCurrentValue = _objSpirit.Name;
            }

            XmlDocument objXmlDocument        = new XmlDocument();
            XmlDocument objXmlCritterDocument = new XmlDocument();

            if (_objSpirit.EntityType == SpiritType.Spirit)
            {
                objXmlDocument = XmlManager.Instance.Load("traditions.xml");
            }
            else
            {
                objXmlDocument = XmlManager.Instance.Load("streams.xml");
            }
            objXmlCritterDocument = XmlManager.Instance.Load("critters.xml");

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

            if (strTradition == "Custom")
            {
                ListItem objCombat = new ListItem();
                objCombat.Value = _objSpirit.CharacterObject.SpiritCombat;
                objCombat.Name  = _objSpirit.CharacterObject.SpiritCombat;
                lstCritters.Add(objCombat);

                ListItem objDetection = new ListItem();
                objDetection.Value = _objSpirit.CharacterObject.SpiritDetection;
                objDetection.Name  = _objSpirit.CharacterObject.SpiritDetection;
                lstCritters.Add(objDetection);

                ListItem objHealth = new ListItem();
                objHealth.Value = _objSpirit.CharacterObject.SpiritHealth;
                objHealth.Name  = _objSpirit.CharacterObject.SpiritHealth;
                lstCritters.Add(objHealth);

                ListItem objIllusion = new ListItem();
                objIllusion.Value = _objSpirit.CharacterObject.SpiritIllusion;
                objIllusion.Name  = _objSpirit.CharacterObject.SpiritIllusion;
                lstCritters.Add(objIllusion);

                ListItem objManipulation = new ListItem();
                objManipulation.Value = _objSpirit.CharacterObject.SpiritManipulation;
                objManipulation.Name  = _objSpirit.CharacterObject.SpiritManipulation;
                lstCritters.Add(objManipulation);
            }
            else
            {
                foreach (XmlNode objXmlSpirit in objXmlDocument.SelectSingleNode("/chummer/traditions/tradition[name = \"" + strTradition + "\"]/spirits").ChildNodes)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlSpirit.InnerText;
                    XmlNode objXmlCritterNode = objXmlCritterDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + objXmlSpirit.InnerText + "\"]");
                    if (objXmlCritterNode["translate"] != null)
                    {
                        objItem.Name = objXmlCritterNode["translate"].InnerText;
                    }
                    else
                    {
                        objItem.Name = objXmlSpirit.InnerText;
                    }

                    lstCritters.Add(objItem);
                }
            }

            if (_objSpirit.CharacterObject.RESEnabled)
            {
                // Add any additional Sprites the character has Access to through Sprite Link.
                foreach (Improvement objImprovement in _objSpirit.CharacterObject.Improvements)
                {
                    if (objImprovement.ImproveType == Improvement.ImprovementType.AddSprite)
                    {
                        ListItem objItem = new ListItem();
                        objItem.Value = objImprovement.ImprovedName;
                        objItem.Name  = objImprovement.ImprovedName;
                        lstCritters.Add(objItem);
                    }
                }
            }

            //Add Ally Spirit to MAG-enabled traditions.
            if (_objSpirit.CharacterObject.MAGEnabled)
            {
                ListItem objItem = new ListItem();
                objItem.Value = "Ally Spirit";
                XmlNode objXmlCritterNode = objXmlCritterDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + objItem.Value + "\"]");
                if (objXmlCritterNode["translate"] != null)
                {
                    objItem.Name = objXmlCritterNode["translate"].InnerText;
                }
                else
                {
                    objItem.Name = objItem.Value;
                }
                lstCritters.Add(objItem);
            }

            cboSpiritName.BeginUpdate();
            cboSpiritName.DisplayMember = "Name";
            cboSpiritName.ValueMember   = "Value";
            cboSpiritName.DataSource    = lstCritters;

            // Set the control back to its original value.
            cboSpiritName.SelectedValue = strCurrentValue;
            cboSpiritName.EndUpdate();
        }
Exemplo n.º 37
0
        public frmPriority(Character objCharacter)
        {
            _objCharacter = objCharacter;
            InitializeComponent();
            LanguageManager.Instance.Load(this);

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

            // Create the list of Priorities (A - E).
            List <ListItem> lstPriorities = new List <ListItem>();

            ListItem objA = new ListItem();

            objA.Value = "A";
            objA.Name  = LanguageManager.Instance.GetString("String_Priority_A");

            ListItem objB = new ListItem();

            objB.Value = "B";
            objB.Name  = LanguageManager.Instance.GetString("String_Priority_B");

            ListItem objC = new ListItem();

            objC.Value = "C";
            objC.Name  = LanguageManager.Instance.GetString("String_Priority_C");

            ListItem objD = new ListItem();

            objD.Value = "D";
            objD.Name  = LanguageManager.Instance.GetString("String_Priority_D");

            ListItem objE = new ListItem();

            objE.Value = "E";
            objE.Name  = LanguageManager.Instance.GetString("String_Priority_E");

            lstPriorities.Add(objA);
            lstPriorities.Add(objB);
            lstPriorities.Add(objC);
            lstPriorities.Add(objD);
            lstPriorities.Add(objE);

            // Create a unique list for each category.
            List <ListItem> lstMetatype  = new List <ListItem>();
            List <ListItem> lstAttribute = new List <ListItem>();
            List <ListItem> lstSpecial   = new List <ListItem>();
            List <ListItem> lstSkill     = new List <ListItem>();
            List <ListItem> lstNuyen     = new List <ListItem>();

            foreach (ListItem objItem in lstPriorities)
            {
                lstMetatype.Add(objItem);
                lstAttribute.Add(objItem);
                lstSpecial.Add(objItem);
                lstSkill.Add(objItem);
                lstNuyen.Add(objItem);
            }

            cboPriorityMetatype.DisplayMember = "Name";
            cboPriorityMetatype.ValueMember   = "Value";
            cboPriorityMetatype.DataSource    = lstMetatype;

            cboPriorityAttributes.DisplayMember = "Name";
            cboPriorityAttributes.ValueMember   = "Value";
            cboPriorityAttributes.DataSource    = lstAttribute;

            cboPrioritySpecial.DisplayMember = "Name";
            cboPrioritySpecial.ValueMember   = "Value";
            cboPrioritySpecial.DataSource    = lstSpecial;

            cboPrioritySkills.DisplayMember = "Name";
            cboPrioritySkills.ValueMember   = "Value";
            cboPrioritySkills.DataSource    = lstSkill;

            cboPriorityNuyen.DisplayMember = "Name";
            cboPriorityNuyen.ValueMember   = "Value";
            cboPriorityNuyen.DataSource    = lstNuyen;
        }
Exemplo n.º 38
0
        public frmSelectBP(Character objCharacter, bool blnUseCurrentValues = false)
        {
            _objCharacter        = objCharacter;
            _objOptions          = _objCharacter.Options;
            _blnUseCurrentValues = blnUseCurrentValues;
            InitializeComponent();
            LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this);

            // Populate the Build Method list.
            List <ListItem> lstBuildMethod = new List <ListItem>();
            ListItem        objKarma       = new ListItem();

            objKarma.Value = "Karma";
            objKarma.Name  = LanguageManager.Instance.GetString("String_Karma");

            ListItem objPriority = new ListItem();

            objPriority.Value = "Priority";
            objPriority.Name  = LanguageManager.Instance.GetString("String_Priority");

            ListItem objSumtoTen = new ListItem();

            objSumtoTen.Value = "SumtoTen";
            objSumtoTen.Name  = LanguageManager.Instance.GetString("String_SumtoTen");

            if (GlobalOptions.Instance.LifeModuleEnabled)
            {
                ListItem objLifeModule = new ListItem();
                objLifeModule.Value = "LifeModule";
                objLifeModule.Name  = LanguageManager.Instance.GetString("String_LifeModule");
                lstBuildMethod.Add(objLifeModule);
            }

            lstBuildMethod.Add(objPriority);
            lstBuildMethod.Add(objKarma);
            lstBuildMethod.Add(objSumtoTen);
            cboBuildMethod.DataSource    = lstBuildMethod;
            cboBuildMethod.ValueMember   = "Value";
            cboBuildMethod.DisplayMember = "Name";

            cboBuildMethod.SelectedValue = _objOptions.BuildMethod;
            nudKarma.Value    = _objOptions.BuildPoints;
            nudMaxAvail.Value = _objOptions.Availability;


            // Load the Priority information.

            XmlDocument objXmlDocumentGameplayOptions = XmlManager.Instance.Load("gameplayoptions.xml");

            // Populate the Gameplay Options list.
            string      strDefault = "";
            XmlNodeList objXmlGameplayOptionList = objXmlDocumentGameplayOptions.SelectNodes("/chummer/gameplayoptions/gameplayoption");

            foreach (XmlNode objXmlGameplayOption in objXmlGameplayOptionList)
            {
                string strName = objXmlGameplayOption["name"].InnerText;
                try
                {
                    if (objXmlGameplayOption["default"].InnerText == "yes")
                    {
                        strDefault = strName;
                    }
                }
                catch { }
                ListItem lstGameplay = new ListItem();
                cboGamePlay.Items.Add(strName);
            }
            cboGamePlay.Text = strDefault;
            XmlNode objXmlSelectedGameplayOption = objXmlDocumentGameplayOptions.SelectSingleNode("/chummer/gameplayoptions/gameplayoption[name = \"" + cboGamePlay.Text + "\"]");

            intQualityLimits = Convert.ToInt32(objXmlSelectedGameplayOption["karma"].InnerText);
            intNuyenBP       = Convert.ToInt32(objXmlSelectedGameplayOption["maxnuyen"].InnerText);
            toolTip1.SetToolTip(chkIgnoreRules, LanguageManager.Instance.GetString("Tip_SelectKarma_IgnoreRules"));

            if (blnUseCurrentValues)
            {
                cboBuildMethod.SelectedValue = "Karma";
                nudKarma.Value = objCharacter.BuildKarma;

                nudMaxAvail.Value = objCharacter.MaximumAvailability;

                cboBuildMethod.Enabled = false;
            }
        }
Exemplo n.º 39
0
        private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Load the Vehicle information.
            _objXmlDocument = XmlManager.Instance.Load("vehicles.xml");

            XmlNode objXmlVehicleNode = _objXmlDocument.SelectSingleNode("/chummer/vehicles/vehicle[id = \"" + _objVehicle.SourceID + "\"]");

            List <ListItem> lstMods       = new List <ListItem>();
            XmlNodeList     objXmlModList = null;

            // Populate the Mod list.
            objXmlModList = cboCategory.SelectedValue != null && (string)cboCategory.SelectedValue != "All"
                        ? _objXmlDocument.SelectNodes("/chummer/mods/mod[(" + _objCharacter.Options.BookXPath() + ") and category = \"" + cboCategory.SelectedValue + "\"]")
                        : _objXmlDocument.SelectNodes("/chummer/mods/mod[" + _objCharacter.Options.BookXPath() + "]");
            if (objXmlModList != null)
            {
                foreach (XmlNode objXmlMod in objXmlModList)
                {
                    if (objXmlMod["hidden"] != null)
                    {
                        continue;
                    }

                    if (objXmlMod["forbidden"]?["vehicledetails"] != null)
                    {
                        // Assumes topmost parent is an AND node
                        if (objXmlVehicleNode.ProcessFilterOperationNode(objXmlMod["forbidden"]["vehicledetails"], false))
                        {
                            continue;
                        }
                    }
                    if (objXmlMod["required"]?["vehicledetails"] != null)
                    {
                        // Assumes topmost parent is an AND node
                        if (!objXmlVehicleNode.ProcessFilterOperationNode(objXmlMod["required"]["vehicledetails"], false))
                        {
                            continue;
                        }
                    }

                    if (objXmlMod["forbidden"]?["oneof"] != null)
                    {
                        XmlNodeList objXmlForbiddenList = objXmlMod.SelectNodes("forbidden/oneof/mods");
                        //Add to set for O(N log M) runtime instead of O(N * M)

                        HashSet <string> objForbiddenAccessory = new HashSet <string>();
                        foreach (XmlNode node in objXmlForbiddenList)
                        {
                            objForbiddenAccessory.Add(node.InnerText);
                        }

                        if (_lstMods.Any(objAccessory => objForbiddenAccessory.Contains(objAccessory.Name)))
                        {
                            continue;
                        }
                    }

                    if (objXmlMod["required"]?["oneof"] != null)
                    {
                        XmlNodeList objXmlRequiredList = objXmlMod.SelectNodes("required/oneof/mods");
                        //Add to set for O(N log M) runtime instead of O(N * M)

                        HashSet <string> objRequiredAccessory = new HashSet <string>();
                        foreach (XmlNode node in objXmlRequiredList)
                        {
                            objRequiredAccessory.Add(node.InnerText);
                        }

                        if (!_lstMods.Any(objAccessory => objRequiredAccessory.Contains(objAccessory.Name)))
                        {
                            continue;
                        }
                    }
                    if (!Backend.Shared_Methods.SelectionShared.CheckAvailRestriction(objXmlMod, _objCharacter, chkHideOverAvailLimit.Checked, Convert.ToInt32(nudRating.Value)))
                    {
                        continue;
                    }
                    ListItem objItem = new ListItem {
                        Value = objXmlMod["id"]?.InnerText
                    };
                    objItem.Name = objXmlMod["translate"]?.InnerText ?? objXmlMod["name"]?.InnerText;
                    lstMods.Add(objItem);
                }
            }
            lstMod.BeginUpdate();
            lstMod.DataSource    = null;
            lstMod.ValueMember   = "Value";
            lstMod.DisplayMember = "Name";
            lstMod.DataSource    = lstMods;
            lstMod.EndUpdate();
        }
        private void lstMentor_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(lstMentor.Text))
            {
                return;
            }

            // Get the information for the selected Mentor.
            XmlNode objXmlMentor = _objXmlDocument.SelectSingleNode("/chummer/mentors/mentor[id = \"" + lstMentor.SelectedValue + "\"]");

            lblAdvantage.Text    = objXmlMentor["altadvantage"]?.InnerText ?? objXmlMentor["advantage"].InnerText;
            lblDisadvantage.Text = objXmlMentor["altdisadvantage"]?.InnerText ?? objXmlMentor["disadvantage"].InnerText;

            cboChoice1.BeginUpdate();
            cboChoice2.BeginUpdate();
            cboChoice1.DataSource = null;
            cboChoice2.DataSource = null;

            // If the Mentor offers a choice of bonuses, build the list and let the user select one.
            if (objXmlMentor["choices"] != null)
            {
                List <ListItem> lstChoice1 = new List <ListItem>();
                List <ListItem> lstChoice2 = new List <ListItem>();

                foreach (XmlNode objChoice in objXmlMentor["choices"].SelectNodes("choice"))
                {
                    bool blnShow = !(objChoice["name"].InnerText.StartsWith("Adept:") && !_objCharacter.AdeptEnabled);
                    if (objChoice["name"].InnerText.StartsWith("Magician:") && !_objCharacter.MagicianEnabled)
                    {
                        blnShow = false;
                    }

                    if (!blnShow)
                    {
                        continue;
                    }
                    ListItem objItem = new ListItem();
                    objItem.Value = objChoice["name"].InnerText;
                    objItem.Name  = objChoice["translate"]?.InnerText ?? objChoice["name"].InnerText;

                    if (objChoice.Attributes["set"] != null)
                    {
                        if (objChoice.Attributes["set"].InnerText == "2")
                        {
                            lstChoice2.Add(objItem);
                        }
                        else
                        {
                            lstChoice1.Add(objItem);
                        }
                    }
                    else
                    {
                        lstChoice1.Add(objItem);
                    }
                }

                lblChoice1.Visible       = true;
                cboChoice1.Visible       = true;
                cboChoice1.ValueMember   = "Value";
                cboChoice1.DisplayMember = "Name";
                cboChoice1.DataSource    = lstChoice1;

                lblChoice1.Top = lblAdvantage.Top + lblAdvantage.Height + 6;
                cboChoice1.Top = lblChoice1.Top + lblChoice1.Height + 3;
                lblChoice2.Top = cboChoice1.Top + cboChoice1.Height + 6;
                cboChoice2.Top = lblChoice2.Top + lblChoice2.Height + 3;

                if (lstChoice2.Count > 0)
                {
                    lblChoice2.Visible       = true;
                    cboChoice2.Visible       = true;
                    cboChoice2.ValueMember   = "Value";
                    cboChoice2.DisplayMember = "Name";
                    cboChoice2.DataSource    = lstChoice2;
                    chkMentorMask.Top        = cboChoice2.Top + cboChoice2.Height + 6;
                }
                else
                {
                    lblChoice2.Visible = false;
                    cboChoice2.Visible = false;
                    chkMentorMask.Top  = cboChoice1.Top + cboChoice1.Height + 6;
                }

                lblDisadvantageLabel.Top = Math.Max(chkMentorMask.Top + chkMentorMask.Height + 6, 133);
                lblDisadvantage.Top      = Math.Max(chkMentorMask.Top + chkMentorMask.Height + 6, 133);
            }
            else
            {
                lblChoice1.Visible = false;
                cboChoice1.Visible = false;
                lblChoice2.Visible = false;
                cboChoice2.Visible = false;
            }
            cboChoice1.EndUpdate();
            cboChoice2.EndUpdate();

            string strBook = _objCharacter.Options.LanguageBookShort(objXmlMentor["source"].InnerText);
            string strPage = objXmlMentor["page"].InnerText;

            if (objXmlMentor["altpage"] != null)
            {
                strPage = objXmlMentor["altpage"].InnerText;
            }
            lblSource.Text = strBook + " " + strPage;

            tipTooltip.SetToolTip(lblSource, _objCharacter.Options.LanguageBookLong(objXmlMentor["source"].InnerText) + " " + LanguageManager.Instance.GetString("String_Page") + " " + strPage);
        }
Exemplo n.º 41
0
        private void BuildVehicleList(XPathNodeIterator objXmlVehicleList)
        {
            string          strSpace     = LanguageManager.GetString("String_Space");
            int             intOverLimit = 0;
            List <ListItem> lstVehicles  = new List <ListItem>();

            foreach (XPathNavigator objXmlVehicle in objXmlVehicleList)
            {
                if (chkHideOverAvailLimit.Checked && !objXmlVehicle.CheckAvailRestriction(_objCharacter))
                {
                    ++intOverLimit;
                    continue;
                }
                if (!chkFreeItem.Checked && chkShowOnlyAffordItems.Checked)
                {
                    decimal decCostMultiplier = 1.0m;
                    if (chkUsedVehicle.Checked)
                    {
                        decCostMultiplier -= (nudUsedVehicleDiscount.Value / 100.0m);
                    }
                    decCostMultiplier *= 1 + (nudMarkup.Value / 100.0m);
                    if (_setBlackMarketMaps.Contains(objXmlVehicle.SelectSingleNode("category")?.Value))
                    {
                        decCostMultiplier *= 0.9m;
                    }
                    if (_setDealerConnectionMaps?.Any(set => objXmlVehicle.SelectSingleNode("category")?.Value.StartsWith(set, StringComparison.Ordinal) == true) == true)
                    {
                        decCostMultiplier *= 0.9m;
                    }
                    if (!objXmlVehicle.CheckNuyenRestriction(_objCharacter.Nuyen, decCostMultiplier))
                    {
                        ++intOverLimit;
                        continue;
                    }
                }

                string strDisplayname = objXmlVehicle.SelectSingleNode("translate")?.Value ?? objXmlVehicle.SelectSingleNode("name")?.Value ?? LanguageManager.GetString("String_Unknown");

                if (!GlobalOptions.SearchInCategoryOnly && txtSearch.TextLength != 0)
                {
                    string strCategory = objXmlVehicle.SelectSingleNode("category")?.Value;
                    if (!string.IsNullOrEmpty(strCategory))
                    {
                        ListItem objFoundItem = _lstCategory.Find(objFind => objFind.Value.ToString() == strCategory);
                        if (!string.IsNullOrEmpty(objFoundItem.Name))
                        {
                            strDisplayname += strSpace + '[' + objFoundItem.Name + ']';
                        }
                    }
                }
                lstVehicles.Add(new ListItem(objXmlVehicle.SelectSingleNode("id")?.Value ?? string.Empty, strDisplayname));
            }
            lstVehicles.Sort(CompareListItems.CompareNames);
            if (intOverLimit > 0)
            {
                // Add after sort so that it's always at the end
                lstVehicles.Add(new ListItem(string.Empty,
                                             string.Format(GlobalOptions.CultureInfo, LanguageManager.GetString("String_RestrictedItemsHidden"),
                                                           intOverLimit)));
            }
            string strOldSelected = lstVehicle.SelectedValue?.ToString();

            _blnLoading = true;
            lstVehicle.BeginUpdate();
            lstVehicle.PopulateWithListItems(lstVehicles);
            _blnLoading = false;
            if (string.IsNullOrEmpty(strOldSelected))
            {
                lstVehicle.SelectedIndex = -1;
            }
            else
            {
                lstVehicle.SelectedValue = strOldSelected;
            }
            lstVehicle.EndUpdate();
        }
Exemplo n.º 42
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");
	        
        }
Exemplo n.º 43
0
        /// <summary>
        /// Build the list of Metamagics.
        /// </summary>
        private void BuildMetamagicList()
        {
            XmlNodeList     objXmlMetamagicList;
            List <ListItem> lstMetamagics = new List <ListItem>();

            // Load the Metamagic information.
            switch (_objMode)
            {
            case Mode.Metamagic:
                _objXmlDocument = XmlManager.Instance.Load("metamagic.xml");
                break;

            case Mode.Echo:
                _objXmlDocument = XmlManager.Instance.Load("echoes.xml");
                break;
            }

            // 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.Instance.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, "", s));
                    if (!add)
                    {
                        continue;
                    }
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlMetamagic["name"]?.InnerText;
                    objItem.Name  = objXmlMetamagic["translate"]?.InnerText ?? objXmlMetamagic["name"]?.InnerText;
                    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();
        }
Exemplo n.º 44
0
        /// <summary>
        /// Add or remove the Adapsin Cyberware Grade categories.
        /// </summary>
        public void PopulateCyberwareGradeList(bool blnBioware = false, bool blnIgnoreSecondHand = false)
        {
            // Load the Cyberware information.
            GradeList objGradeList;
            if (blnBioware)
                objGradeList = GlobalOptions.BiowareGrades;
            else
                objGradeList = GlobalOptions.CyberwareGrades;
            List<ListItem> lstCyberwareGrades = new List<ListItem>();

            foreach (Grade objWareGrade in objGradeList)
            {
                bool blnAddItem = true;

                ListItem objItem = new ListItem();
                objItem.Value = objWareGrade.Name;
                objItem.Name = objWareGrade.DisplayName;

                if (blnIgnoreSecondHand && objWareGrade.SecondHand)
                    blnAddItem = false;
                if (!_objCharacter.AdapsinEnabled && objWareGrade.Adapsin)
                    blnAddItem = false;

                if (blnAddItem)
                    lstCyberwareGrades.Add(objItem);
            }
            //cboCyberwareGrade.DataSource = null;
            cboCyberwareGrade.ValueMember = "Value";
            cboCyberwareGrade.DisplayMember = "Name";
            cboCyberwareGrade.DataSource = lstCyberwareGrades;
        }
Exemplo n.º 45
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 (!string.IsNullOrEmpty(_strForceSkill))
                {
                    objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skills/skill[name = \"" + _strForceSkill + "\" and not(exotic) and (" + _objCharacter.Options.BookXPath() + ")]");
                }
                else
                {
                    if (!string.IsNullOrEmpty(_strLimitToCategories))
                    {
                        objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/skills/skill[category = " + _strLimitToCategories + " and (" + _objCharacter.Options.BookXPath() + ")]");
                    }
                    else
                    {
                        string strFilter = "not(exotic)";
                        if (!string.IsNullOrEmpty(_strIncludeCategory))
                        {
                            strFilter += " and (";
                            string[] strValue = _strIncludeCategory.Split(',');
                            foreach (string strSkillCategory in strValue)
                            {
                                strFilter += "category = \"" + strSkillCategory.Trim() + "\" or ";
                            }
                            // Remove the trailing " or ".
                            strFilter  = strFilter.Substring(0, strFilter.Length - 4);
                            strFilter += ")";
                        }
                        if (!string.IsNullOrEmpty(_strExcludeCategory))
                        {
                            strFilter += " and (";
                            string[] strValue = _strExcludeCategory.Split(',');
                            foreach (string strSkillCategory in strValue)
                            {
                                strFilter += "category != \"" + strSkillCategory.Trim() + "\" and ";
                            }
                            // Remove the trailing " and ".
                            strFilter  = strFilter.Substring(0, strFilter.Length - 5);
                            strFilter += ")";
                        }
                        if (!string.IsNullOrEmpty(_strIncludeSkillGroup))
                        {
                            strFilter += " and (";
                            string[] strValue = _strIncludeSkillGroup.Split(',');
                            foreach (string strSkillGroup in strValue)
                            {
                                strFilter += "skillgroup = \"" + strSkillGroup.Trim() + "\" or ";
                            }
                            // Remove the trailing " or ".
                            strFilter  = strFilter.Substring(0, strFilter.Length - 4);
                            strFilter += ")";
                        }
                        if (!string.IsNullOrEmpty(_strExcludeSkillGroup))
                        {
                            strFilter += " and (";
                            string[] strValue = _strExcludeSkillGroup.Split(',');
                            foreach (string strSkillGroup in strValue)
                            {
                                strFilter += "skillgroup != \"" + strSkillGroup.Trim() + "\" and ";
                            }
                            // Remove the trailing " and ".
                            strFilter  = strFilter.Substring(0, strFilter.Length - 5);
                            strFilter += ")";
                        }
                        if (!string.IsNullOrEmpty(LinkedAttribute))
                        {
                            strFilter += " and (";
                            string[] strValue = LinkedAttribute.Split(',');
                            foreach (string strAttribute in strValue)
                            {
                                strFilter += "attribute = \"" + strAttribute.Trim() + "\" or ";
                            }
                            // Remove the trailing " or ".
                            strFilter  = strFilter.Substring(0, strFilter.Length - 4);
                            strFilter += ")";
                        }
                        if (!string.IsNullOrEmpty(_strLimitToSkill))
                        {
                            strFilter += " 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 + " and (" + _objCharacter.Options.BookXPath() + ")]");
                    }
                }

                // Add the Skills to the list.
                foreach (XmlNode objXmlSkill in objXmlSkillList)
                {
                    string strXmlSkillName = objXmlSkill["name"].InnerText;
                    if (!_objCharacter.SkillsSection.Skills.Any(objSkill => objSkill.Name == strXmlSkillName && objSkill.Rating >= _intMinimumRating))
                    {
                        continue;
                    }
                    ListItem objItem = new ListItem();
                    objItem.Value = strXmlSkillName;
                    objItem.Name  = objXmlSkill["translate"]?.InnerText ?? strXmlSkillName;
                    lstSkills.Add(objItem);
                }

                // Add in any Exotic Skills the character has.
                foreach (Skill objSkill in _objCharacter.SkillsSection.Skills)
                {
                    if (objSkill.IsExoticSkill)
                    {
                        ExoticSkill objExoticSkill = objSkill as ExoticSkill;
                        bool        blnAddSkill    = true;
                        if (objSkill.Rating < _intMinimumRating)
                        {
                            blnAddSkill = false;
                        }
                        else if (!string.IsNullOrEmpty(_strForceSkill))
                        {
                            blnAddSkill = _strForceSkill == objExoticSkill.Name + " (" + objExoticSkill.Specific + ")";
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(_strIncludeCategory))
                            {
                                blnAddSkill = _strIncludeCategory.Contains(objExoticSkill.SkillCategory);
                            }
                            else if (!string.IsNullOrEmpty(_strExcludeCategory))
                            {
                                blnAddSkill = !_strExcludeCategory.Contains(objExoticSkill.SkillCategory);
                            }
                            else if (!string.IsNullOrEmpty(_strIncludeSkillGroup))
                            {
                                blnAddSkill = _strIncludeSkillGroup.Contains(objExoticSkill.SkillGroup);
                            }
                            else if (!string.IsNullOrEmpty(_strExcludeSkillGroup))
                            {
                                blnAddSkill = !_strExcludeSkillGroup.Contains(objExoticSkill.SkillGroup);
                            }
                            else if (!string.IsNullOrEmpty(_strLimitToSkill))
                            {
                                blnAddSkill = _strLimitToSkill.Contains(objExoticSkill.Name);
                            }
                        }

                        if (blnAddSkill)
                        {
                            ListItem objItem = new ListItem();
                            objItem.Value = objExoticSkill.Name + " (" + objExoticSkill.Specific + ")";
                            // Use the translated Exotic Skill name if available.
                            XmlNode objXmlSkill =
                                _objXmlDocument.SelectSingleNode("/chummer/skills/skill[exotic = \"Yes\" and name = \"" + objExoticSkill.Name + "\"]");
                            objItem.Name = objXmlSkill["translate"] != null
                                ? objXmlSkill["translate"].InnerText + " (" + objExoticSkill.DisplaySpecialization + ")"
                                : objExoticSkill.Name + " (" + objExoticSkill.DisplaySpecialization + ")";
                            lstSkills.Add(objItem);
                        }
                    }
                }
            }
            else
            {
                //TODO: This is less robust than it should be. Should be refactored to support the rest of the entries.
                if (!string.IsNullOrWhiteSpace(_strLimitToSkill))
                {
                    _objXmlDocument = XmlManager.Instance.Load("skills.xml");
                    string   strFilter = string.Empty;
                    string[] strValue  = _strLimitToSkill.Split(',');
                    strFilter = strValue.Aggregate(strFilter, (current, strSkill) => current + "name = \"" + strSkill.Trim() + "\" or ");
                    // Remove the trailing " or ".
                    strFilter = strFilter.Substring(0, strFilter.Length - 4);
                    XmlNodeList objXmlSkillList = _objXmlDocument.SelectNodes("/chummer/knowledgeskills/skill[" + strFilter + "]");

                    // Add the Skills to the list.
                    foreach (XmlNode objXmlSkill in objXmlSkillList)
                    {
                        string strXmlSkillName = objXmlSkill["name"].InnerText;
                        if (!_objCharacter.SkillsSection.KnowledgeSkills.Any(objSkill => objSkill.Name == strXmlSkillName && objSkill.Rating >= _intMinimumRating))
                        {
                            continue;
                        }
                        ListItem objItem = new ListItem();
                        objItem.Value = strXmlSkillName;
                        if (objXmlSkill.Attributes != null)
                        {
                            objItem.Name = objXmlSkill["translate"]?.InnerText ?? strXmlSkillName;
                        }
                        else
                        {
                            objItem.Name = strXmlSkillName;
                        }
                        lstSkills.Add(objItem);
                    }
                }
                else
                {
                    // Instead of showing all available Active Skills, show a list of Knowledge Skills that the character currently has.
                    foreach (KnowledgeSkill objKnow in _objCharacter.SkillsSection.KnowledgeSkills)
                    {
                        if (objKnow.Rating < _intMinimumRating)
                        {
                            continue;
                        }
                        ListItem objSkill = new ListItem();
                        objSkill.Value = objKnow.Name;
                        objSkill.Name  = objKnow.DisplayName;
                        lstSkills.Add(objSkill);
                    }
                }
            }
            if (lstSkills.Count <= 0)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_Improvement_EmptySelectionListNamed").Replace("{0}", _strSourceName));
                DialogResult = DialogResult.Cancel;
                return;
            }

            SortListItem objSort = new SortListItem();

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

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

            if (cboSkill.Items.Count == 1)
            {
                cmdOK_Click(sender, e);
            }
        }