Пример #1
0
        private void chkArmorEquipped_CheckedChanged(object sender, EventArgs e)
        {
            if (_blnSkipRefresh)
                return;

            // Locate the selected Armor or Armor Mod.
            try
            {
                if (treArmor.SelectedNode.Level == 1)
                {
                    Armor objArmor = _objFunctions.FindArmor(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
                    if (objArmor != null)
                    {
                        objArmor.Equipped = chkArmorEquipped.Checked;
                        if (chkArmorEquipped.Checked)
                        {
                            // Add the Armor's Improevments to the character.
                            if (objArmor.Bonus != null)
                                _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Armor, objArmor.InternalId, objArmor.Bonus, false, 1, objArmor.DisplayNameShort);
                            // Add the Improvements from any Armor Mods in the Armor.
                            foreach (ArmorMod objMod in objArmor.ArmorMods)
                            {
                                if (objMod.Bonus != null && objMod.Equipped)
                                    _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId, objMod.Bonus, false, objMod.Rating, objMod.DisplayNameShort);
                            }
                            // Add the Improvements from any Gear in the Armor.
                            foreach (Gear objGear in objArmor.Gear)
                            {
                                if (objGear.Bonus != null && objGear.Equipped)
                                    _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId, objGear.Bonus, false, objGear.Rating, objGear.DisplayNameShort);
                            }
                        }
                        else
                        {
                            // Remove any Improvements the Armor created.
                            if (objArmor.Bonus != null)
                                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Armor, objArmor.InternalId);
                            // Remove any Improvements from any Armor Mods in the Armor.
                            foreach (ArmorMod objMod in objArmor.ArmorMods)
                            {
                                if (objMod.Bonus != null)
                                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);
                            }
                            // Remove any Improvements from any Gear in the Armor.
                            foreach (Gear objGear in objArmor.Gear)
                            {
                                if (objGear.Bonus != null)
                                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
                            }
                        }
                    }
                }
                else if (treArmor.SelectedNode.Level > 1)
                {
                    ArmorMod objMod = _objFunctions.FindArmorMod(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
                    if (objMod != null)
                    {
                        objMod.Equipped = chkArmorEquipped.Checked;
                        if (chkArmorEquipped.Checked)
                        {
                            // Add the Mod's Improevments to the character.
                            if (objMod.Bonus != null && objMod.Parent.Equipped)
                                _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId, objMod.Bonus, false, objMod.Rating, objMod.DisplayNameShort);
                        }
                        else
                        {
                            // Remove any Improvements the Mod created.
                            if (objMod.Bonus != null)
                                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);
                        }
                    }

                    Armor objFoundArmor = new Armor(_objCharacter);
                    Gear objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objFoundArmor);
                    if (objGear != null)
                    {
                        objGear.Equipped = chkArmorEquipped.Checked;
                        if (chkArmorEquipped.Checked)
                        {
                            // Add the Gear's Improevments to the character.
                            if (objGear.Bonus != null && objFoundArmor.Equipped)
                                _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId, objGear.Bonus, false, objGear.Rating, objGear.DisplayNameShort);
                        }
                        else
                        {
                            // Remove any Improvements the Gear created.
                            if (objGear.Bonus != null)
                                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
                        }
                    }
                }
                RefreshSelectedArmor();
                UpdateCharacterInfo();

                _blnIsDirty = true;
                UpdateWindowTitle();
            }
            catch
            {
            }
        }
Пример #2
0
        private void tsArmorGearAddAsPlugin_Click(object sender, EventArgs e)
        {
            // Make sure a parent items is selected, then open the Select Gear window.
            try
            {
                if (treArmor.SelectedNode.Level == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectArmor"), LanguageManager.Instance.GetString("MessageTitle_SelectArmor"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectArmor"), LanguageManager.Instance.GetString("MessageTitle_SelectArmor"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Make sure the selected item is another piece of Gear.
            bool blnFound = false;
            Armor objFoundArmor = new Armor(_objCharacter);
            Gear objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objFoundArmor);
            if (objGear != null)
                blnFound = true;

            if (!blnFound)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectArmor"), LanguageManager.Instance.GetString("MessageTitle_SelectArmor"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            bool blnAddAgain = PickArmorGear();
            if (blnAddAgain)
                tsArmorGearAddAsPlugin_Click(sender, e);
        }
Пример #3
0
        private void tsArmorGearNotes_Click(object sender, EventArgs e)
        {
            try
            {
                bool blnFound = false;
                Armor objFoundArmor = new Armor(_objCharacter);
                Gear objArmorGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objFoundArmor);
                if (objArmorGear != null)
                    blnFound = true;

                if (blnFound)
                {
                    frmNotes frmItemNotes = new frmNotes();
                    frmItemNotes.Notes = objArmorGear.Notes;
                    string strOldValue = objArmorGear.Notes;
                    frmItemNotes.ShowDialog(this);

                    if (frmItemNotes.DialogResult == DialogResult.OK)
                    {
                        objArmorGear.Notes = frmItemNotes.Notes;
                        if (objArmorGear.Notes != strOldValue)
                        {
                            _blnIsDirty = true;
                            UpdateWindowTitle();
                        }
                    }

                    if (objArmorGear.Notes != string.Empty)
                        treArmor.SelectedNode.ForeColor = Color.SaddleBrown;
                    else
                        treArmor.SelectedNode.ForeColor = SystemColors.WindowText;
                    treArmor.SelectedNode.ToolTipText = CommonFunctions.WordWrap(objArmorGear.Notes, 100);
                }
            }
            catch
            {
            }
        }
Пример #4
0
        /// <summary>
        /// Locate a piece of Gear within the character's Armors.
        /// </summary>
        /// <param name="strGuid">InternalId of the Gear to find.</param>
        /// <param name="lstArmors">List of Armors to search.</param>
        /// <param name="objFoundArmor">Armor that the Gear was found in.</param>
        public Gear FindArmorGear(string strGuid, List<Armor> lstArmors, out Armor objFoundArmor)
        {
            Gear objReturn = new Gear(_objCharacter);
            foreach (Armor objArmor in lstArmors)
            {
                objReturn = FindGear(strGuid, objArmor.Gear);

                if (objReturn != null)
                {
                    if (objReturn.InternalId != Guid.Empty.ToString() && objReturn.Name != "")
                    {
                        objFoundArmor = objArmor;
                        return objReturn;
                    }
                }
            }

            objFoundArmor = null;
            return objReturn;
        }
Пример #5
0
        /// <summary>
        /// Enable/Disable the Paste Menu and ToolStrip items as appropriate.
        /// </summary>
        private void RefreshPasteStatus()
        {
            bool blnPasteEnabled = false;
            bool blnCopyEnabled = false;

            if (tabCharacterTabs.SelectedTab == tabStreetGear)
            {
                // Lifestyle Tab.
                if (tabStreetGearTabs.SelectedTab == tabLifestyle)
                {
                    if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Lifestyle)
                        blnPasteEnabled = true;

                    try
                    {
                        foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
                        {
                            if (objLifestyle.InternalId == treLifestyles.SelectedNode.Tag.ToString())
                            {
                                blnCopyEnabled = true;
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                // Armor Tab.
                if (tabStreetGearTabs.SelectedTab == tabArmor)
                {
                    if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Armor)
                        blnPasteEnabled = true;
                    if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem)
                    {
                        // Gear can only be pasted into Armor, not Armor Mods.
                        try
                        {
                            foreach (Armor objArmor in _objCharacter.Armor)
                            {
                                if (objArmor.InternalId == treArmor.SelectedNode.Tag.ToString())
                                {
                                    blnPasteEnabled = true;
                                    break;
                                }
                            }
                        }
                        catch
                        {
                        }
                    }

                    try
                    {
                        foreach (Armor objArmor in _objCharacter.Armor)
                        {
                            if (objArmor.InternalId == treArmor.SelectedNode.Tag.ToString())
                            {
                                blnCopyEnabled = true;
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        Armor objArmor = new Armor(_objCharacter);
                        Gear objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objArmor);
                        if (objGear != null)
                            blnCopyEnabled = true;
                    }
                    catch
                    {
                    }
                }

                // Weapons Tab.
                if (tabStreetGearTabs.SelectedTab == tabWeapons)
                {
                    if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Weapon)
                        blnPasteEnabled = true;
                    if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem)
                    {
                        // Check if the copied Gear can be pasted into the selected Weapon Accessory.
                        Gear objGear = new Gear(_objCharacter);
                        XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");
                        if (objXmlNode != null)
                        {
                            switch (objXmlNode["category"].InnerText)
                            {
                                case "Commlinks":
                                case "Cyberdecks":
                                case "Rigger Command Consoles":
                                    Commlink objCommlink = new Commlink(_objCharacter);
                                    objCommlink.Load(objXmlNode, true);
                                    objGear = objCommlink;
                                    break;
                                default:
                                    Gear objNewGear = new Gear(_objCharacter);
                                    objNewGear.Load(objXmlNode, true);
                                    objGear = objNewGear;
                                    break;
                            }

                            objGear.Parent = null;

                            // Make sure that a Weapon Accessory is selected and that it allows Gear of the item's Category.
                            WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
                            try
                            {
                                foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
                                {
                                    foreach (WeaponAccessory objWeaponAccessory in objCharacterWeapon.WeaponAccessories)
                                    {
                                        if (objWeaponAccessory.InternalId == treWeapons.SelectedNode.Tag.ToString())
                                        {
                                            objAccessory = objWeaponAccessory;
                                            break;
                                        }
                                    }
                                }
                                if (objAccessory.AllowGear != null)
                                {
                                    foreach (XmlNode objAllowed in objAccessory.AllowGear.SelectNodes("gearcategory"))
                                    {
                                        if (objAllowed.InnerText == objGear.Category)
                                        {
                                            blnPasteEnabled = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }

                    try
                    {
                        foreach (Weapon objWeapon in _objCharacter.Weapons)
                        {
                            if (objWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
                            {
                                blnCopyEnabled = true;
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
                        Gear objGear = _objFunctions.FindWeaponGear(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons, out objAccessory);
                        if (objGear != null)
                            blnCopyEnabled = true;
                    }
                    catch
                    {
                    }
                }

                // Gear Tab.
                if (tabStreetGearTabs.SelectedTab == tabGear)
                {
                    if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem)
                        blnPasteEnabled = true;

                    try
                    {
                        Gear objGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
                        if (objGear != null)
                            blnCopyEnabled = true;
                    }
                    catch
                    {
                    }
                }
            }

            // Vehicles Tab.
            if (tabCharacterTabs.SelectedTab == tabVehicles)
            {
                if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Vehicle)
                    blnPasteEnabled = true;
                if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem)
                {
                    // Gear can only be pasted into Vehicles and Vehicle Gear.
                    try
                    {
                        foreach (Vehicle objVehicle in _objCharacter.Vehicles)
                        {
                            if (objVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
                            {
                                blnPasteEnabled = true;
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        Vehicle objVehicle = new Vehicle(_objCharacter);
                        Gear objGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle);
                        if (objGear != null)
                            blnPasteEnabled = true;
                    }
                    catch
                    {
                    }
                }
                if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Weapon)
                {
                    // Weapons can only be pasted into Vehicle Mods that allow them (Weapon Mounts and Mechanical Arms).
                    try
                    {
                        VehicleMod objMod = new VehicleMod(_objCharacter);
                        foreach (Vehicle objVehicle in _objCharacter.Vehicles)
                        {
                            foreach (VehicleMod objVehicleMod in objVehicle.Mods)
                            {
                                if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                {
                                    if (objVehicleMod.Name.Contains("Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm") || objMod.WeaponMountCategories != "")
                                    {
                                        blnPasteEnabled = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                try
                {
                    foreach (Vehicle objVehicle in _objCharacter.Vehicles)
                    {
                        if (objVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
                        {
                            blnCopyEnabled = true;
                            break;
                        }
                    }
                }
                catch
                {
                }
                try
                {
                    Vehicle objVehicle = new Vehicle(_objCharacter);
                    Gear objGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle);
                    if (objGear != null)
                        blnCopyEnabled = true;
                }
                catch
                {
                }
                try
                {
                    foreach (Vehicle objVehicle in _objCharacter.Vehicles)
                    {
                        foreach (VehicleMod objMod in objVehicle.Mods)
                        {
                            foreach (Weapon objWeapon in objMod.Weapons)
                            {
                                if (objWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                {
                                    blnCopyEnabled = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
            }

            mnuEditPaste.Enabled = blnPasteEnabled;
            tsbPaste.Enabled = blnPasteEnabled;
            mnuEditCopy.Enabled = blnCopyEnabled;
            tsbCopy.Enabled = blnCopyEnabled;
        }
Пример #6
0
        private void LoadGrid()
        {
            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.
            XmlNodeList objXmlArmorList;

            if (txtSearch.Text.Length > 1)
            {
                string strSearch = "/chummer/weapons/weapon[(" + _objCharacter.Options.BookXPath() + ") and category != \"Cyberware\" and category != \"Gear\" and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))]";
                objXmlArmorList = _objXmlDocument.SelectNodes(strSearch);
            }
            else
            {
                // Populate the Armor list.
                objXmlArmorList = _objXmlDocument.SelectNodes("/chummer/armors/armor[category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ")]");
            }

            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";
        }
Пример #7
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;
            }
        }
Пример #8
0
        private void mnuEditPaste_Click(object sender, EventArgs e)
        {
            if (tabCharacterTabs.SelectedTab == tabStreetGear)
            {
                // Lifestyle Tab.
                if (tabStreetGearTabs.SelectedTab == tabLifestyle)
                {
                    // Paste Lifestyle.
                    Lifestyle objLifestyle = new Lifestyle(_objCharacter);
                    XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/lifestyle");
                    if (objXmlNode != null)
                    {
                        objLifestyle.Load(objXmlNode, true);
                        // Reset the number of months back to 1 since 0 isn't valid in Create Mode.
                        objLifestyle.Months = 1;

                        _objCharacter.Lifestyles.Add(objLifestyle);

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

                        UpdateCharacterInfo();
                        _blnIsDirty = true;
                        UpdateWindowTitle();
                        return;
                    }
                }

                // Armor Tab.
                if (tabStreetGearTabs.SelectedTab == tabArmor)
                {
                    // Paste Armor.
                    Armor objArmor = new Armor(_objCharacter);
                    XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/armor");
                    if (objXmlNode != null)
                    {
                        objArmor.Load(objXmlNode, true);

                        _objCharacter.Armor.Add(objArmor);

                        _objFunctions.CreateArmorTreeNode(objArmor, treArmor, cmsArmor, cmsArmorMod, cmsArmorGear);

                        UpdateCharacterInfo();
                        _blnIsDirty = true;
                        UpdateWindowTitle();
                        return;
                    }

                    // Paste Gear.
                    Gear objGear = new Gear(_objCharacter);
                    objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");

                    if (objXmlNode != null)
                    {
                        switch (objXmlNode["category"].InnerText)
                        {
                            case "Commlinks":
                            case "Cyberdecks":
                            case "Rigger Command Consoles":
                                Commlink objCommlink = new Commlink(_objCharacter);
                                objCommlink.Load(objXmlNode, true);
                                objGear = objCommlink;
                                break;
                            default:
                                Gear objNewGear = new Gear(_objCharacter);
                                objNewGear.Load(objXmlNode, true);
                                objGear = objNewGear;
                                break;
                        }

                        foreach (Armor objCharacterArmor in _objCharacter.Armor)
                        {
                            if (objCharacterArmor.InternalId == treArmor.SelectedNode.Tag.ToString())
                            {
                                objCharacterArmor.Gear.Add(objGear);
                                TreeNode objNode = new TreeNode();
                                objNode.Text = objGear.DisplayName;
                                objNode.Tag = objGear.InternalId;
                                objNode.ContextMenuStrip = cmsArmorGear;

                                _objFunctions.BuildGearTree(objGear, objNode, cmsArmorGear);

                                treArmor.SelectedNode.Nodes.Add(objNode);
                                treArmor.SelectedNode.Expand();
                            }
                        }

                        // Add any Weapons that come with the Gear.
                        objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                        if (objXmlNode != null)
                        {
                            Weapon objWeapon = new Weapon(_objCharacter);
                            objWeapon.Load(objXmlNode, true);
                            _objCharacter.Weapons.Add(objWeapon);
                            objGear.WeaponID = objWeapon.InternalId;
                            _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear);
                        }

                        UpdateCharacterInfo();
                        _blnIsDirty = true;
                        UpdateWindowTitle();
                        return;
                    }
                }

                // Weapons Tab.
                if (tabStreetGearTabs.SelectedTab == tabWeapons)
                {
                    // Paste Gear into a Weapon Accessory.
                    Gear objGear = new Gear(_objCharacter);
                    XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");
                    if (objXmlNode != null)
                    {
                        switch (objXmlNode["category"].InnerText)
                        {
                            case "Commlinks":
                            case "Cyberdecks":
                            case "Rigger Command Consoles":
                                Commlink objCommlink = new Commlink(_objCharacter);
                                objCommlink.Load(objXmlNode, true);
                                objGear = objCommlink;
                                break;
                            default:
                                Gear objNewGear = new Gear(_objCharacter);
                                objNewGear.Load(objXmlNode, true);
                                objGear = objNewGear;
                                break;
                        }

                        objGear.Parent = null;

                        // Make sure that a Weapon Accessory is selected and that it allows Gear of the item's Category.
                        WeaponAccessory objAccessory = _objFunctions.FindWeaponAccessory(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);
                        bool blnAllowPaste = false;
                        if (objAccessory.AllowGear != null)
                        {
                            foreach (XmlNode objAllowed in objAccessory.AllowGear.SelectNodes("gearcategory"))
                            {
                                if (objAllowed.InnerText == objGear.Category)
                                {
                                    blnAllowPaste = true;
                                    break;
                                }
                            }
                        }
                        if (blnAllowPaste)
                        {
                            objAccessory.Gear.Add(objGear);
                            TreeNode objNode = new TreeNode();
                            objNode.Text = objGear.DisplayName;
                            objNode.Tag = objGear.InternalId;
                            objNode.ContextMenuStrip = cmsWeaponAccessoryGear;

                            _objFunctions.BuildGearTree(objGear, objNode, cmsWeaponAccessoryGear);

                            treWeapons.SelectedNode.Nodes.Add(objNode);
                            treWeapons.SelectedNode.Expand();

                            // Add any Weapons that come with the Gear.
                            objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                            if (objXmlNode != null)
                            {
                                Weapon objGearWeapon = new Weapon(_objCharacter);
                                objGearWeapon.Load(objXmlNode, true);
                                _objCharacter.Weapons.Add(objGearWeapon);
                                objGear.WeaponID = objGearWeapon.InternalId;
                                _objFunctions.CreateWeaponTreeNode(objGearWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear);
                            }

                            UpdateCharacterInfo();
                            _blnIsDirty = true;
                            UpdateWindowTitle();
                            return;
                        }
                    }

                    // Paste Weapon.
                    Weapon objWeapon = new Weapon(_objCharacter);
                    objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                    if (objXmlNode != null)
                    {
                        objWeapon.Load(objXmlNode, true);
                        objWeapon.VehicleMounted = false;

                        _objCharacter.Weapons.Add(objWeapon);

                        _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear);

                        UpdateCharacterInfo();
                        _blnIsDirty = true;
                        UpdateWindowTitle();
                        return;
                    }
                }

                // Gear Tab.
                if (tabStreetGearTabs.SelectedTab == tabGear)
                {
                    // Paste Gear.
                    Gear objGear = new Gear(_objCharacter);
                    XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");
                    if (objXmlNode != null)
                    {
                        switch (objXmlNode["category"].InnerText)
                        {
                            case "Commlinks":
                            case "Cyberdecks":
                            case "Rigger Command Consoles":
                                Commlink objCommlink = new Commlink(_objCharacter);
                                objCommlink.Load(objXmlNode, true);
                                _objCharacter.Gear.Add(objCommlink);
                                objGear = objCommlink;
                                break;
                            default:
                                Gear objNewGear = new Gear(_objCharacter);
                                objNewGear.Load(objXmlNode, true);
                                _objCharacter.Gear.Add(objNewGear);
                                objGear = objNewGear;
                                break;
                        }

                        objGear.Parent = null;

                        TreeNode objNode = new TreeNode();
                        objNode.Text = objGear.DisplayName;
                        objNode.Tag = objGear.InternalId;
                        if (objGear.Notes != string.Empty)
                            objNode.ForeColor = Color.SaddleBrown;
                        objNode.ToolTipText = CommonFunctions.WordWrap(objGear.Notes, 100);

                        _objFunctions.BuildGearTree(objGear, objNode, cmsGear);

                        objNode.ContextMenuStrip = cmsGear;

                        TreeNode objParent = new TreeNode();
                        if (objGear.Location == "")
                            objParent = treGear.Nodes[0];
                        else
                        {
                            foreach (TreeNode objFind in treGear.Nodes)
                            {
                                if (objFind.Text == objGear.Location)
                                {
                                    objParent = objFind;
                                    break;
                                }
                            }
                        }
                        objParent.Nodes.Add(objNode);
                        objParent.Expand();

                        // Add any Weapons that come with the Gear.
                        objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                        if (objXmlNode != null)
                        {
                            Weapon objWeapon = new Weapon(_objCharacter);
                            objWeapon.Load(objXmlNode, true);
                            _objCharacter.Weapons.Add(objWeapon);
                            objGear.WeaponID = objWeapon.InternalId;
                            _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear);
                        }

                        UpdateCharacterInfo();
                        _blnIsDirty = true;
                        UpdateWindowTitle();
                        return;
                    }
                }
            }

            // Vehicles Tab.
            if (tabCharacterTabs.SelectedTab == tabVehicles)
            {
                // Paste Vehicle.
                Vehicle objVehicle = new Vehicle(_objCharacter);
                XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/vehicle");
                if (objXmlNode != null)
                {
                    objVehicle.Load(objXmlNode, true);

                    _objCharacter.Vehicles.Add(objVehicle);

                    _objFunctions.CreateVehicleTreeNode(objVehicle, treVehicles, cmsVehicle, cmsVehicleLocation, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponAccessoryGear, cmsVehicleGear);

                    UpdateCharacterInfo();
                    _blnIsDirty = true;
                    UpdateWindowTitle();
                    return;
                }

                // Paste Gear.
                Gear objGear = new Gear(_objCharacter);
                objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");

                if (objXmlNode != null)
                {
                    switch (objXmlNode["category"].InnerText)
                    {
                        case "Commlinks":
                        case "Cyberdecks":
                        case "Rigger Command Consoles":
                            Commlink objCommlink = new Commlink(_objCharacter);
                            objCommlink.Load(objXmlNode, true);
                            objGear = objCommlink;
                            break;
                        default:
                            Gear objNewGear = new Gear(_objCharacter);
                            objNewGear.Load(objXmlNode, true);
                            objGear = objNewGear;
                            break;
                    }

                    // Paste the Gear into a Vehicle.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        if (objCharacterVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
                        {
                            objCharacterVehicle.Gear.Add(objGear);
                            TreeNode objNode = new TreeNode();
                            objNode.Text = objGear.DisplayName;
                            objNode.Tag = objGear.InternalId;
                            objNode.ContextMenuStrip = cmsVehicleGear;
                            objVehicle = objCharacterVehicle;

                            _objFunctions.BuildGearTree(objGear, objNode, cmsVehicleGear);

                            treVehicles.SelectedNode.Nodes.Add(objNode);
                            treVehicles.SelectedNode.Expand();
                        }
                    }

                    // Paste the Gear into a Vehicle's Gear.
                    Vehicle objTempVehicle = objVehicle;
                    Gear objVehicleGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle);
                    if (objVehicle == null)
                        objVehicle = objTempVehicle;
                    if (objVehicleGear != null)
                    {
                        objVehicleGear.Children.Add(objGear);
                        objGear.Parent = objVehicleGear;
                        TreeNode objNode = new TreeNode();
                        objNode.Text = objGear.DisplayName;
                        objNode.Tag = objGear.InternalId;
                        objNode.ContextMenuStrip = cmsVehicleGear;

                        _objFunctions.BuildGearTree(objGear, objNode, cmsVehicleGear);

                        treVehicles.SelectedNode.Nodes.Add(objNode);
                        treVehicles.SelectedNode.Expand();
                    }

                    UpdateCharacterInfo();
                    _blnIsDirty = true;
                    UpdateWindowTitle();
                    return;
                }

                // Paste Weapon.
                Weapon objWeapon = new Weapon(_objCharacter);
                objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                if (objXmlNode != null)
                {
                    objWeapon.Load(objXmlNode, true);
                    objWeapon.VehicleMounted = true;

                    try
                    {
                        // Weapons can only be added to Vehicle Mods that support them (Weapon Mounts and Mechanical Arms).
                        VehicleMod objMod = new VehicleMod(_objCharacter);
                        foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                        {
                            foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
                            {
                                if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                {
                                    if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm") || objVehicleMod.WeaponMountCategories != "")
                                    {
                                        objVehicleMod.Weapons.Add(objWeapon);

                                        _objFunctions.CreateWeaponTreeNode(objWeapon, treVehicles.SelectedNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, null);

                                        UpdateCharacterInfo();
                                        _blnIsDirty = true;
                                        UpdateWindowTitle();
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
Пример #9
0
        private void nudArmorRating_ValueChanged(object sender, EventArgs e)
        {
            if (_blnSkipRefresh)
                return;

            // Locate the selected ArmorMod.
            bool blnIsMod = false;
            ArmorMod objMod = _objFunctions.FindArmorMod(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
            if (objMod != null)
                blnIsMod = true;
            // Locate the selected Gear.
            bool blnIsGear = false;
                Armor objSelectedArmor = new Armor(_objCharacter);
                Gear objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objSelectedArmor);
            if (objGear != null)
                blnIsGear = true;

            if (blnIsGear)
            {

                objGear.Rating = Convert.ToInt32(nudArmorRating.Value);
                treArmor.SelectedNode.Text = objGear.DisplayName;

                // See if a Bonus node exists.
                if (objGear.Bonus != null)
                {
                    // If the Bonus contains "Rating", remove the existing Improvements and create new ones.
                    if (objGear.Bonus.InnerXml.Contains("Rating"))
                    {
                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
                        _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId, objGear.Bonus, false, objGear.Rating, objGear.DisplayNameShort);
                    }
                }
            }
            else if (blnIsMod)
            {
                objMod.Rating = Convert.ToInt32(nudArmorRating.Value);
                treArmor.SelectedNode.Text = objMod.DisplayName;

                // See if a Bonus node exists.
                if (objMod.Bonus != null)
                {
                    // If the Bonus contains "Rating", remove the existing Improvements and create new ones.
                    if (objMod.Bonus.InnerXml.Contains("Rating"))
                    {
                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);
                        _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId, objMod.Bonus, false, objMod.Rating, objMod.DisplayNameShort);
                    }
                }
            }

            else
            {
                Armor objArmor = _objFunctions.FindArmor(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
                objArmor.Rating = Convert.ToInt32(nudArmorRating.Value);
                treArmor.SelectedNode.Text = objArmor.DisplayName;
            }

            RefreshSelectedArmor();
            UpdateCharacterInfo();
            CalculateNuyen();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
Пример #10
0
        private void cmdAddArmor_Click(object sender, EventArgs e)
        {
            frmSelectArmor frmPickArmor = new frmSelectArmor(_objCharacter, true);
            frmPickArmor.ShowDialog(this);

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

            // Open the Armor XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("armor.xml");

            XmlNode objXmlArmor = objXmlDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + frmPickArmor.SelectedArmor + "\"]");

            TreeNode objNode = new TreeNode();
            Armor objArmor = new Armor(_objCharacter);
            objArmor.Create(objXmlArmor, objNode, cmsArmorMod, frmPickArmor.Rating);
            objArmor.DiscountCost = frmPickArmor.BlackMarketDiscount;

            if (objArmor.InternalId == Guid.Empty.ToString())
                return;

            int intCost = objArmor.TotalCost;
            // Apply a markup if applicable.
            if (frmPickArmor.Markup != 0)
            {
                double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
                dblCost *= 1 + (Convert.ToDouble(frmPickArmor.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
                intCost = Convert.ToInt32(dblCost);
            }

            // Multiply the cost if applicable.
            if (objArmor.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
                intCost *= _objOptions.RestrictedCostMultiplier;
            if (objArmor.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailForbidden")) && _objOptions.MultiplyForbiddenCost)
                intCost *= _objOptions.ForbiddenCostMultiplier;

            // Check the item's Cost and make sure the character can afford it.
            if (!frmPickArmor.FreeCost)
            {
                if (intCost > _objCharacter.Nuyen)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    // Remove the Improvements created by the Armor.
                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Armor, objArmor.InternalId);
                    if (frmPickArmor.AddAgain)
                        cmdAddArmor_Click(sender, e);

                    return;
                }
                else
                {
                    // Create the Expense Log Entry.
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseArmor") + " " + objArmor.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen -= intCost;

                    ExpenseUndo objUndo = new ExpenseUndo();
                    objUndo.CreateNuyen(NuyenExpenseType.AddArmor, objArmor.InternalId);
                    objExpense.Undo = objUndo;
                }
            }

            _objCharacter.Armor.Add(objArmor);

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

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickArmor.AddAgain)
                cmdAddArmor_Click(sender, e);
        }
Пример #11
0
        private void TestArmor()
        {
            Character objCharacter = new Character();
            XmlDocument objXmlDocument = XmlManager.Instance.Load("armor.xml");
            pgbProgress.Minimum = 0;
            pgbProgress.Value = 0;
            pgbProgress.Maximum = objXmlDocument.SelectNodes("/chummer/armors/armor").Count;
            pgbProgress.Maximum += objXmlDocument.SelectNodes("/chummer/mods/mod").Count;

            // Armor.
            foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/armors/armor"))
            {
                pgbProgress.Value++;
                Application.DoEvents();
                try
                {
                    TreeNode objTempNode = new TreeNode();
                    Armor objTemp = new Armor(objCharacter);
                    objTemp.Create(objXmlGear, objTempNode, null, 0);
                    try
                    {
                        int objValue = objTemp.TotalCost;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalCost\n";
                    }
                    try
                    {
                        int objValue = objTemp.TotalArmor;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalArmor\n";
                    }
                    try
                    {
                        string objValue = objTemp.TotalAvail;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAvail\n";
                    }
                    try
                    {
                        string objValue = objTemp.CalculatedCapacity;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedCapacity\n";
                    }
                }
                catch
                {
                    txtOutput.Text += objXmlGear["name"].InnerText + " general failure\n";
                }
            }

            // Armor Mods.
            foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/mods/mod"))
            {
                pgbProgress.Value++;
                Application.DoEvents();
                try
                {
                    TreeNode objTempNode = new TreeNode();
                    ArmorMod objTemp = new ArmorMod(objCharacter);
                    List<Weapon> lstWeaopns = new List<Weapon>();
                    List<TreeNode> lstNodes = new List<TreeNode>();
                    objTemp.Create(objXmlGear, objTempNode, 1, lstWeaopns, lstNodes);
                    try
                    {
                        string objValue = objTemp.TotalAvail;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAvail\n";
                    }
                    try
                    {
                        string objValue = objTemp.CalculatedCapacity;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedCapacity\n";
                    }
                }
                catch
                {
                    txtOutput.Text += objXmlGear["name"].InnerText + " general failure\n";
                }
            }
        }
Пример #12
0
        private void tsArmorSell_Click(object sender, EventArgs e)
        {
            // Delete the selected piece of Armor.
            try
            {
                if (treArmor.SelectedNode.Level == 1)
                {
                    // Locate the piece of Armor that is selected in the tree.
                    Armor objArmor = _objFunctions.FindArmor(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

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

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(objArmor.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldArmor") + " " + objArmor.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    // Remove any Improvements created by the Armor and its children.
                    foreach (ArmorMod objMod in objArmor.ArmorMods)
                    {
                        // Remove the Cyberweapon created by the Mod if applicable.
                        if (objMod.WeaponID != Guid.Empty.ToString())
                        {
                            // Remove the Weapon from the TreeView.
                            TreeNode objRemoveNode = new TreeNode();
                            foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes)
                            {
                                if (objWeaponNode.Tag.ToString() == objMod.WeaponID)
                                    objRemoveNode = objWeaponNode;
                            }
                            treWeapons.Nodes.Remove(objRemoveNode);

                            // Remove the Weapon from the Character.
                            Weapon objRemoveWeapon = new Weapon(_objCharacter);
                            foreach (Weapon objWeapon in _objCharacter.Weapons)
                            {
                                if (objWeapon.InternalId == objMod.WeaponID)
                                    objRemoveWeapon = objWeapon;
                            }
                            _objCharacter.Weapons.Remove(objRemoveWeapon);
                        }

                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);
                    }
                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Armor, objArmor.InternalId);

                    _objCharacter.Armor.Remove(objArmor);
                    treArmor.SelectedNode.Remove();
                }
                else if (treArmor.SelectedNode.Level == 2)
                {
                    // Locate the ArmorMod that is selected in the tree.
                    bool blnIsMod = false;
                    ArmorMod objMod = _objFunctions.FindArmorMod(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
                    if (objMod != null)
                        blnIsMod = true;

                    if (blnIsMod)
                    {
                        // Record the cost of the Armor with the ArmorMod.
                        int intOriginal = objMod.Parent.TotalCost;

                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Remove the Cyberweapon created by the Mod if applicable.
                        if (objMod.WeaponID != Guid.Empty.ToString())
                        {
                            // Remove the Weapon from the TreeView.
                            TreeNode objRemoveNode = new TreeNode();
                            foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes)
                            {
                                if (objWeaponNode.Tag.ToString() == objMod.WeaponID)
                                    objRemoveNode = objWeaponNode;
                            }
                            treWeapons.Nodes.Remove(objRemoveNode);

                            // Remove the Weapon from the Character.
                            Weapon objRemoveWeapon = new Weapon(_objCharacter);
                            foreach (Weapon objWeapon in _objCharacter.Weapons)
                            {
                                if (objWeapon.InternalId == objMod.WeaponID)
                                    objRemoveWeapon = objWeapon;
                            }
                            _objCharacter.Weapons.Remove(objRemoveWeapon);
                        }

                        // Remove any Improvements created by the ArmorMod.
                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);

                        objMod.Parent.ArmorMods.Remove(objMod);
                        treArmor.SelectedNode.Remove();

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objMod.Parent.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldArmorMod") + " " + objMod.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;
                    }
                    else
                    {
                        Armor objArmor = new Armor(_objCharacter);
                        Gear objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objArmor);

                        // Record the cost of the Armor with the ArmorMod.
                        int intOriginal = objArmor.TotalCost;

                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Remove any Improvements created by the Gear.
                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);

                        objArmor.Gear.Remove(objGear);
                        treArmor.SelectedNode.Remove();

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objArmor.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldArmorGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;

                        _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);
                    }
                }
                else if (treArmor.SelectedNode.Level > 2)
                {
                    Armor objArmor = new Armor(_objCharacter);
                    Gear objGear = new Gear(_objCharacter);
                    Gear objParent = new Gear(_objCharacter);
                    objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objArmor);
                    objParent = objGear.Parent;

                    // Record the cost of the Armor with the ArmorMod.
                    int intOriginal = objArmor.TotalCost;

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

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

                    // Remove any Improvements created by the Gear.
                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);

                    objParent.Children.Remove(objGear);
                    treArmor.SelectedNode.Remove();

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objArmor.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldArmorGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);
                }
                UpdateCharacterInfo();
                RefreshSelectedArmor();

                _blnIsDirty = true;
                UpdateWindowTitle();
            }
            catch
            {
            }
        }
Пример #13
0
        /// <summary>
        /// Select a piece of Gear and add it to a piece of Armor.
        /// </summary>
        /// <param name="blnShowArmorCapacityOnly">Whether or not only items that consume capacity should be shown.</param>
        private bool PickArmorGear(bool blnShowArmorCapacityOnly = false)
        {
            bool blnNullParent = true;
            Gear objSelectedGear = new Gear(_objCharacter);
            Armor objSelectedArmor = new Armor(_objCharacter);
            ExpenseUndo objUndo = new ExpenseUndo();

            foreach (Armor objArmor in _objCharacter.Armor)
            {
                if (objArmor.InternalId == treArmor.SelectedNode.Tag.ToString())
                    objSelectedArmor = objArmor;
            }

            if (treArmor.SelectedNode.Level > 1)
            {
                objSelectedGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objSelectedArmor);
                if (objSelectedGear != null)
                    blnNullParent = false;
            }

            // Open the Gear XML file and locate the selected Gear.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");

            XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objSelectedGear.Name + "\" and category = \"" + objSelectedGear.Category + "\"]");

            frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, true);
            frmPickGear.EnableStack = false;
            frmPickGear.ShowArmorCapacityOnly = blnShowArmorCapacityOnly;
            frmPickGear.CapacityDisplayStyle = objSelectedArmor.CapacityDisplayStyle;
            try
            {
                if (treArmor.SelectedNode.Level > 1)
                {
                    if (objXmlGear.InnerXml.Contains("<addoncategory>"))
                    {
                        string strCategories = "";
                        foreach (XmlNode objXmlCategory in objXmlGear.SelectNodes("addoncategory"))
                            strCategories += objXmlCategory.InnerText + ",";
                        // Remove the trailing comma.
                        strCategories = strCategories.Substring(0, strCategories.Length - 1);
                        frmPickGear.AllowedCategories = strCategories;
                    }

                    // If the Gear has a Capacity with no brackets (meaning it grants Capacity), show only Subsystems (those that conume Capacity).
                    if (!objSelectedGear.Capacity.Contains('['))
                    {
                        frmPickGear.MaximumCapacity = objSelectedGear.CapacityRemaining;

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

                    if (objSelectedGear.Category == "Commlink")
                    {
                        Commlink objCommlink = (Commlink)objSelectedGear;
                        frmPickGear.CommlinkResponse = objCommlink.DeviceRating;
                    }
                }
                else if (treArmor.SelectedNode.Level == 1)
                {
                    // Open the Armor XML file and locate the selected Gear.
                    objXmlDocument = XmlManager.Instance.Load("armor.xml");
                    objXmlGear = objXmlDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + objSelectedArmor.Name + "\"]");

                    if (objXmlGear.InnerXml.Contains("<addoncategory>"))
                    {
                        string strCategories = "";
                        foreach (XmlNode objXmlCategory in objXmlGear.SelectNodes("addoncategory"))
                            strCategories += objXmlCategory.InnerText + ",";
                        // Remove the trailing comma.
                        strCategories = strCategories.Substring(0, strCategories.Length - 1);
                        frmPickGear.AllowedCategories = strCategories;
                    }
                }
            }
            catch
            {
            }

            frmPickGear.ShowDialog(this);

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

            TreeNode objNode = new TreeNode();

            // Open the Cyberware XML file and locate the selected piece.
            objXmlDocument = XmlManager.Instance.Load("gear.xml");
            objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");

            // Create the new piece of Gear.
            Gear objNewGear = new Gear(_objCharacter);
            List<Weapon> objWeapons = new List<Weapon>();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();

            switch (frmPickGear.SelectedCategory)
            {
                case "Commlinks":
                case "Cyberdecks":
                case "Rigger Command Consoles":
                    Commlink objCommlink = new Commlink(_objCharacter);
                    objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating);
                    objCommlink.Quantity = frmPickGear.SelectedQty;

                    objNewGear = objCommlink;
                    break;
                default:
                    Gear objGear = new Gear(_objCharacter);
                    objGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", false, false, true, true, frmPickGear.Aerodynamic);
                    objGear.Quantity = frmPickGear.SelectedQty;

                    objNewGear = objGear;
                    break;
            }

            if (objNewGear.InternalId == Guid.Empty.ToString())
                return false;

            if (!blnNullParent)
                objNewGear.Parent = objSelectedGear;

            // Reduce the cost for Do It Yourself components.
            if (frmPickGear.DoItYourself)
                objNewGear.Cost = (Convert.ToDouble(objNewGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();

            // Apply a markup if applicable.
            int intCost = objNewGear.TotalCost;
            if (frmPickGear.Markup != 0)
            {
                double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
                dblCost *= 1 + (Convert.ToDouble(frmPickGear.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
                intCost = Convert.ToInt32(dblCost);
            }

            // Multiply the cost if applicable.
            if (objNewGear.TotalAvail().EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
                intCost *= _objOptions.RestrictedCostMultiplier;
            if (objNewGear.TotalAvail().EndsWith(LanguageManager.Instance.GetString("String_AvailForbidden")) && _objOptions.MultiplyForbiddenCost)
                intCost *= _objOptions.ForbiddenCostMultiplier;

            // Do not allow the user to add new Gear if the Armor's Capacity has been reached.
            if (_objOptions.EnforceCapacity)
            {
                objSelectedArmor.Gear.Add(objSelectedGear);
                if (treArmor.SelectedNode.Level > 1)
                {
                    if (objSelectedGear.CapacityRemaining < 0)
                    {
                        objSelectedArmor.Gear.Remove(objSelectedGear);
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return frmPickGear.AddAgain;
                    }
                    else
                        objSelectedArmor.Gear.Remove(objSelectedGear);
                }
                else
                {
                    if (objSelectedArmor.CapacityRemaining < 0)
                    {
                        objSelectedArmor.Gear.Remove(objSelectedGear);
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return frmPickGear.AddAgain;
                    }
                    else
                        objSelectedArmor.Gear.Remove(objSelectedGear);
                }
            }

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

                    objUndo.CreateNuyen(NuyenExpenseType.AddArmorGear, objNewGear.InternalId, objNewGear.Quantity);
                    objExpense.Undo = objUndo;
                }
            }

            if (objNewGear.InternalId == Guid.Empty.ToString())
                return false;

            // Create any Weapons that came with this Gear.
            foreach (Weapon objWeapon in objWeapons)
                _objCharacter.Weapons.Add(objWeapon);

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

            bool blnMatchFound = false;
            // If this is Ammunition, see if the character already has it on them.
            if (objNewGear.Category == "Ammunition")
            {
                foreach (Gear objCharacterGear in _objCharacter.Gear)
                {
                    if (objCharacterGear.Name == objNewGear.Name && objCharacterGear.Category == objNewGear.Category && objCharacterGear.Rating == objNewGear.Rating && objCharacterGear.Extra == objNewGear.Extra)
                    {
                        // A match was found, so increase the quantity instead.
                        objCharacterGear.Quantity += objNewGear.Quantity;
                        blnMatchFound = true;

                        if (objUndo.ObjectId != "")
                            objUndo.ObjectId = objCharacterGear.InternalId;

                        foreach (TreeNode objGearNode in treGear.Nodes[0].Nodes)
                        {
                            if (objCharacterGear.InternalId == objGearNode.Tag.ToString())
                            {
                                objGearNode.Text = objCharacterGear.DisplayName;
                                treArmor.SelectedNode = objGearNode;
                                break;
                            }
                        }

                        break;
                    }
                }
            }

            // Add the Gear.
            if (!blnMatchFound)
            {
                if (objSelectedGear.Name == string.Empty)
                {
                    objNode.ContextMenuStrip = cmsArmorGear;
                    treArmor.SelectedNode.Nodes.Add(objNode);
                    treArmor.SelectedNode.Expand();
                    objSelectedArmor.Gear.Add(objNewGear);
                }
                else
                {
                    objNode.ContextMenuStrip = cmsArmorGear;
                    treArmor.SelectedNode.Nodes.Add(objNode);
                    treArmor.SelectedNode.Expand();
                    objSelectedGear.Children.Add(objNewGear);
                }

                // Select the node that was just added.
                treArmor.SelectedNode = objNode;
            }

            UpdateCharacterInfo();
            RefreshSelectedArmor();

            _blnIsDirty = true;
            UpdateWindowTitle();

            return frmPickGear.AddAgain;
        }
Пример #14
0
 /// <summary>
 /// Copy the Improvements from a piece of Armor on one character to another.
 /// </summary>
 /// <param name="objSource">Source character.</param>
 /// <param name="objDestination">Destination character.</param>
 /// <param name="objArmor">Armor to copy.</param>
 private void CopyArmorImprovements(Character objSource, Character objDestination, Armor objArmor)
 {
     foreach (Improvement objImproevment in objSource.Improvements)
     {
         if (objImproevment.SourceName == objArmor.InternalId)
         {
             objDestination.Improvements.Add(objImproevment);
         }
     }
     // Look through any Armor Mods and add the Improvements as well.
     foreach (ArmorMod objMod in objArmor.ArmorMods)
     {
         foreach (Improvement objImproevment in objSource.Improvements)
         {
             if (objImproevment.SourceName == objMod.InternalId)
             {
                 objDestination.Improvements.Add(objImproevment);
             }
         }
     }
     // Look through any children and add their Improvements as well.
     foreach (Gear objChild in objArmor.Gear)
         CopyGearImprovements(objSource, objDestination, objChild);
 }
Пример #15
0
        private void cmdAddArmor_Click(object sender, EventArgs e)
        {
            frmSelectArmor frmPickArmor = new frmSelectArmor(_objCharacter);
            frmPickArmor.ShowDialog(this);

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

            // Open the Armor XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("armor.xml");

            XmlNode objXmlArmor = objXmlDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + frmPickArmor.SelectedArmor + "\"]");

            TreeNode objNode = new TreeNode();
            Armor objArmor = new Armor(_objCharacter);
            objArmor.Create(objXmlArmor, objNode, cmsArmorMod, frmPickArmor.Rating);
            objArmor.DiscountCost = frmPickArmor.BlackMarketDiscount;
            if (objArmor.InternalId == Guid.Empty.ToString())
                return;

            _objCharacter.Armor.Add(objArmor);
            objNode.ContextMenuStrip = cmsArmor;
            treArmor.Nodes[0].Nodes.Add(objNode);
            treArmor.Nodes[0].Expand();
            treArmor.SelectedNode = objNode;

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickArmor.AddAgain)
                cmdAddArmor_Click(sender, e);
        }
Пример #16
0
        /// <summary>
        /// Add a PACKS Kit to the character.
        /// </summary>
        public void AddPACKSKit()
        {
            frmSelectPACKSKit frmPickPACKSKit = new frmSelectPACKSKit(_objCharacter);
            frmPickPACKSKit.ShowDialog(this);

            bool blnCreateChildren = true;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

               //TODO: PACKS SKILLS?

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

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

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

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

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

                    objNode.ContextMenuStrip = cmsMartialArts;

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

                    treMartialArts.SelectedNode = objNode;
                }
            }

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

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

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

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

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

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

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

                    int i = panPowers.Controls.Count;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    _objCharacter.ComplexForms.Add(objProgram);

                    treComplexForms.SortCustom();
                }
            }

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

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

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

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

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

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

                        treSpells.SortCustom();
                    }
                }
            }

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

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

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

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

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

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

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

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

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

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

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

                        objNode.Text = strName;
                    }

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

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

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

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

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

                    Armor objArmor = new Armor(_objCharacter);
                    TreeNode objNode = new TreeNode();
                    int intArmorRating = 0;
                    if (objXmlArmor["rating"] != null)
                    {
                        intArmorRating = Convert.ToInt32(objXmlArmor["rating"].InnerText);
                    }
                    objArmor.Create(objXmlArmorNode, objNode, cmsArmorMod, intArmorRating, false, blnCreateChildren);
                    _objCharacter.Armor.Add(objArmor);

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

                            objArmor.ArmorMods.Add(objMod);

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

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

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

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

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

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

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

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

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

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

                            objWeapon.WeaponAccessories.Add(objMod);

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

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

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

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

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

                    Application.DoEvents();
                }
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    Application.DoEvents();
                }

                treCyberware.SortCustom();
            }

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

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

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

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

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

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

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

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

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

                    Application.DoEvents();
                }

                treCyberware.SortCustom();
            }

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

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

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

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

                    Application.DoEvents();
                }
            }

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

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

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

                    Gear objDefaultSensor = new Gear(_objCharacter);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    objWeapon.WeaponAccessories.Add(objMod);

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

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

                    Application.DoEvents();
                }
            }

            pgbProgress.Visible = false;

            if (frmPickPACKSKit.AddAgain)
                AddPACKSKit();

            PopulateGearList();
            UpdateCharacterInfo();
        }
Пример #17
0
        private void cmdDeleteArmor_Click(object sender, EventArgs e)
        {
            // Delete the selected piece of Armor.
            try
            {
                if (treArmor.SelectedNode.Level == 0)
                {
                    if (treArmor.SelectedNode.Text == LanguageManager.Instance.GetString("Node_SelectedArmor"))
                        return;

                    if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteArmorLocation")))
                        return;

                    // Move all of the child nodes in the current parent to the Selected Armor parent node.
                    foreach (TreeNode objNode in treArmor.SelectedNode.Nodes)
                    {
                        Armor objArmor = _objFunctions.FindArmor(objNode.Tag.ToString(), _objCharacter.Armor);

                        // Change the Location for the Armor.
                        objArmor.Location = "";

                        TreeNode nodNewNode = new TreeNode();
                        nodNewNode.Text = objNode.Text;
                        nodNewNode.Tag = objNode.Tag;
                        nodNewNode.ContextMenuStrip = cmsArmor;

                        // Add child nodes.
                        foreach (ArmorMod objChild in objArmor.ArmorMods)
                        {
                            TreeNode nodChildNode = new TreeNode();
                            nodChildNode.Text = objChild.DisplayName;
                            nodChildNode.Tag = objChild.InternalId;
                            nodChildNode.ContextMenuStrip = cmsArmorMod;
                            nodNewNode.Nodes.Add(nodChildNode);
                            nodNewNode.Expand();
                        }

                        foreach (Gear objChild in objArmor.Gear)
                        {
                            TreeNode nodChildNode = new TreeNode();
                            nodChildNode.Text = objChild.DisplayName;
                            nodChildNode.Tag = objChild.InternalId;
                            nodChildNode.ContextMenuStrip = cmsArmorGear;
                            nodNewNode.Nodes.Add(nodChildNode);
                            nodNewNode.Expand();
                        }

                        treArmor.Nodes[0].Nodes.Add(nodNewNode);
                        treArmor.Nodes[0].Expand();
                    }

                    // Remove the Location from the character, then remove the selected node.
                    _objCharacter.ArmorBundles.Remove(treArmor.SelectedNode.Text);
                    treArmor.SelectedNode.Remove();
                    return;
                }

                if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteArmor")))
                    return;

                if (treArmor.SelectedNode.Level == 1)
                {
                    Armor objArmor = _objFunctions.FindArmor(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
                    if (objArmor == null)
                        return;

                    // Remove any Improvements created by the Armor and its children.
                    foreach (ArmorMod objMod in objArmor.ArmorMods)
                    {
                        // Remove the Cyberweapon created by the Mod if applicable.
                        if (objMod.WeaponID != Guid.Empty.ToString())
                        {
                            // Remove the Weapon from the TreeView.
                            TreeNode objRemoveNode = new TreeNode();
                            foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes)
                            {
                                if (objWeaponNode.Tag.ToString() == objMod.WeaponID)
                                    objRemoveNode = objWeaponNode;
                            }
                            treWeapons.Nodes.Remove(objRemoveNode);

                            // Remove the Weapon from the Character.
                            Weapon objRemoveWeapon = new Weapon(_objCharacter);
                            foreach (Weapon objWeapon in _objCharacter.Weapons)
                            {
                                if (objWeapon.InternalId == objMod.WeaponID)
                                    objRemoveWeapon = objWeapon;
                            }
                            _objCharacter.Weapons.Remove(objRemoveWeapon);
                        }

                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);
                    }
                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Armor, objArmor.InternalId);

                    // Remove any Improvements created by the Armor's Gear.
                    foreach (Gear objGear in objArmor.Gear)
                        _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);

                    _objCharacter.Armor.Remove(objArmor);
                    treArmor.SelectedNode.Remove();
                }
                else if (treArmor.SelectedNode.Level == 2)
                {
                    bool blnIsMod = false;
                    ArmorMod objMod = _objFunctions.FindArmorMod(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
                    if (objMod != null)
                        blnIsMod = true;

                    if (blnIsMod)
                    {
                        // Remove the Cyberweapon created by the Mod if applicable.
                        if (objMod.WeaponID != Guid.Empty.ToString())
                        {
                            // Remove the Weapon from the TreeView.
                            TreeNode objRemoveNode = new TreeNode();
                            foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes)
                            {
                                if (objWeaponNode.Tag.ToString() == objMod.WeaponID)
                                    objRemoveNode = objWeaponNode;
                            }
                            treWeapons.Nodes.Remove(objRemoveNode);

                            // Remove the Weapon from the Character.
                            Weapon objRemoveWeapon = new Weapon(_objCharacter);
                            foreach (Weapon objWeapon in _objCharacter.Weapons)
                            {
                                if (objWeapon.InternalId == objMod.WeaponID)
                                    objRemoveWeapon = objWeapon;
                            }
                            _objCharacter.Weapons.Remove(objRemoveWeapon);
                        }

                        // Remove any Improvements created by the ArmorMod.
                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);
                        objMod.Parent.ArmorMods.Remove(objMod);
                    }
                    else
                    {
                        Armor objSelectedArmor = new Armor(_objCharacter);
                        Gear objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objSelectedArmor);
                        _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);
                        objSelectedArmor.Gear.Remove(objGear);
                    }
                    treArmor.SelectedNode.Remove();
                }
                else if (treArmor.SelectedNode.Level > 2)
                {
                    Armor objSelectedArmor = new Armor(_objCharacter);
                    Gear objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objSelectedArmor);
                    objGear.Parent.Children.Remove(objGear);
                    _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);
                    objSelectedArmor.Gear.Remove(objGear);
                    treArmor.SelectedNode.Remove();
                }
                UpdateCharacterInfo();
                RefreshSelectedArmor();

                _blnIsDirty = true;
                UpdateWindowTitle();
            }
            catch
            {
            }
        }
Пример #18
0
        /// <summary>
        /// Select a piece of Gear and add it to a piece of Armor.
        /// </summary>
        /// <param name="blnShowArmorCapacityOnly">Whether or not only items that consume capacity should be shown.</param>
        private bool PickArmorGear(bool blnShowArmorCapacityOnly = false)
        {
            bool blnNullParent = true;
            Gear objSelectedGear = new Gear(_objCharacter);
            Armor objSelectedArmor = new Armor(_objCharacter);

            foreach (Armor objArmor in _objCharacter.Armor)
            {
                if (objArmor.InternalId == treArmor.SelectedNode.Tag.ToString())
                    objSelectedArmor = objArmor;
            }

            if (treArmor.SelectedNode.Level > 1)
            {
                objSelectedGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objSelectedArmor);
                if (objSelectedGear != null)
                    blnNullParent = false;
            }

            // Open the Gear XML file and locate the selected Gear.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");

            XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objSelectedGear.Name + "\" and category = \"" + objSelectedGear.Category + "\"]");

            bool blnFakeCareerMode = false;
            if (_objCharacter.Metatype == "A.I." || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients")
                blnFakeCareerMode = true;
            frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, blnFakeCareerMode);
            frmPickGear.ShowArmorCapacityOnly = blnShowArmorCapacityOnly;
            frmPickGear.CapacityDisplayStyle = objSelectedArmor.CapacityDisplayStyle;
            try
            {
                if (treArmor.SelectedNode.Level > 1)
                {
                    if (objXmlGear.InnerXml.Contains("<addoncategory>"))
                    {
                        string strCategories = "";
                        foreach (XmlNode objXmlCategory in objXmlGear.SelectNodes("addoncategory"))
                            strCategories += objXmlCategory.InnerText + ",";
                        // Remove the trailing comma.
                        strCategories = strCategories.Substring(0, strCategories.Length - 1);
                        frmPickGear.AllowedCategories = strCategories;
                    }

                    // If the Gear has a Capacity with no brackets (meaning it grants Capacity), show only Subsystems (those that conume Capacity).
                    if (!objSelectedGear.Capacity.Contains('['))
                        frmPickGear.MaximumCapacity = objSelectedGear.CapacityRemaining;

                    if (objSelectedGear.Category == "Commlinks" || objSelectedGear.Category == "Cyberdecks")
                    {
                        Commlink objCommlink = (Commlink)objSelectedGear;
                        frmPickGear.CommlinkResponse = objCommlink.DeviceRating;
                    }
                }
                else if (treArmor.SelectedNode.Level == 1)
                {
                    // Open the Armor XML file and locate the selected Gear.
                    objXmlDocument = XmlManager.Instance.Load("armor.xml");
                    objXmlGear = objXmlDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + objSelectedArmor.Name + "\"]");

                    if (objXmlGear.InnerXml.Contains("<addoncategory>"))
                    {
                        string strCategories = "";
                        foreach (XmlNode objXmlCategory in objXmlGear.SelectNodes("addoncategory"))
                            strCategories += objXmlCategory.InnerText + ",";
                        // Remove the trailing comma.
                        strCategories = strCategories.Substring(0, strCategories.Length - 1);
                        frmPickGear.AllowedCategories = strCategories;
                    }
                }
            }
            catch
            {
            }

            frmPickGear.ShowDialog(this);

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

            TreeNode objNode = new TreeNode();

            // Open the Cyberware XML file and locate the selected piece.
            objXmlDocument = XmlManager.Instance.Load("gear.xml");
            objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");

            // Create the new piece of Gear.
            List<Weapon> objWeapons = new List<Weapon>();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            Gear objNewGear = new Gear(_objCharacter);

            objNewGear.DiscountCost = frmPickGear.BlackMarketDiscount;

            switch (frmPickGear.SelectedCategory)
            {
                case "Commlinks":
                case "Cyberdecks":
                case "Rigger Command Consoles":
                    Commlink objCommlink = new Commlink(_objCharacter);
                    objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating);
                    objCommlink.Quantity = frmPickGear.SelectedQty;
                    try
                    {
                        nudGearQty.Increment = objCommlink.CostFor;
                        //nudGearQty.Minimum = nudGearQty.Increment;
                    }
                    catch
                    {
                    }

                    objNewGear = objCommlink;
                    break;
                default:
                    Gear objGear = new Gear(_objCharacter);
                    objGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", false, false, true, true, frmPickGear.Aerodynamic);
                    objGear.Quantity = frmPickGear.SelectedQty;
                    try
                    {
                        nudGearQty.Increment = objGear.CostFor;
                        //nudGearQty.Minimum = nudGearQty.Increment;
                    }
                    catch
                    {
                    }

                    objNewGear = objGear;
                    break;
            }

            if (objNewGear.InternalId == Guid.Empty.ToString())
                return false;

            if (!blnNullParent)
                objNewGear.Parent = objSelectedGear;

            // Reduce the cost for Do It Yourself components.
            if (frmPickGear.DoItYourself)
                objNewGear.Cost = (Convert.ToDouble(objNewGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
            // If the item was marked as free, change its cost.
            if (frmPickGear.FreeCost)
            {
                objNewGear.Cost = "0";
                objNewGear.Cost3 = "0";
                objNewGear.Cost6 = "0";
                objNewGear.Cost10 = "0";
            }

            // Create any Weapons that came with this Gear.
            foreach (Weapon objWeapon in objWeapons)
                _objCharacter.Weapons.Add(objWeapon);

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

            bool blnMatchFound = false;
            // If this is Ammunition, see if the character already has it on them.
            if (objNewGear.Category == "Ammunition")
            {
                foreach (Gear objCharacterGear in _objCharacter.Gear)
                {
                    if (objCharacterGear.Name == objNewGear.Name && objCharacterGear.Category == objNewGear.Category && objCharacterGear.Rating == objNewGear.Rating && objCharacterGear.Extra == objNewGear.Extra)
                    {
                        // A match was found, so increase the quantity instead.
                        objCharacterGear.Quantity += objNewGear.Quantity;
                        blnMatchFound = true;

                        foreach (TreeNode objGearNode in treGear.Nodes[0].Nodes)
                        {
                            if (objCharacterGear.InternalId == objGearNode.Tag.ToString())
                            {
                                objGearNode.Text = objCharacterGear.DisplayName;
                                treGear.SelectedNode = objGearNode;
                                break;
                            }
                        }

                        break;
                    }
                }
            }

            // Add the Gear.
            if (!blnMatchFound)
            {
                if (objSelectedGear.Name == string.Empty)
                {
                    objNode.ContextMenuStrip = cmsArmorGear;
                    treArmor.SelectedNode.Nodes.Add(objNode);
                    treArmor.SelectedNode.Expand();
                    objSelectedArmor.Gear.Add(objNewGear);
                }
                else
                {
                    objNode.ContextMenuStrip = cmsArmorGear;
                    treArmor.SelectedNode.Nodes.Add(objNode);
                    treArmor.SelectedNode.Expand();
                    objSelectedGear.Children.Add(objNewGear);
                }

                // Select the node that was just added.
                treGear.SelectedNode = objNode;
            }

            UpdateCharacterInfo();
            RefreshSelectedArmor();

            _blnIsDirty = true;
            UpdateWindowTitle();

            return frmPickGear.AddAgain;
        }
Пример #19
0
        private void lstArmor_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstArmor.Text == "")
                return;

            // Get the information for the selected piece of Armor.
            XmlNode objXmlArmor = _objXmlDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + lstArmor.SelectedValue + "\"]");
            // Create the Armor so we can show its Total Avail (some Armor includes Chemical Seal which adds +6 which wouldn't be factored in properly otherwise).
            Armor objArmor = new Armor(_objCharacter);
            TreeNode objNode = new TreeNode();
            objArmor.Create(objXmlArmor, objNode, null, 0, true);

            lblArmor.Text = objXmlArmor["name"].InnerText;
            lblArmorValue.Text = objXmlArmor["armor"].InnerText;
            lblAvail.Text = objArmor.TotalAvail;

            if (objXmlArmor["rating"] != null)
            {
                lblRatingLabel.Visible = true;
                nudRating.Visible = true;
                nudRating.Enabled = true;
                nudRating.Maximum = Convert.ToInt32(objXmlArmor["rating"].InnerText);
                nudRating.Minimum = 1;
                nudRating.Value = 1;
            }
            else
            {
                lblRatingLabel.Visible = false;
                nudRating.Visible = false;
                nudRating.Enabled = false;
                nudRating.Minimum = 0;
                nudRating.Value = 0;
            }
            UpdateArmorInfo();
        }
Пример #20
0
        /// <summary>
        /// Refresh the information for the currently displayed Armor.
        /// </summary>
        public void RefreshSelectedArmor()
        {
            lblArmorDeviceRating.Text = "";
            lblArmorAttack.Text = "";
            lblArmorSleaze.Text = "";
            lblArmorDataProcessing.Text = "";
            lblArmorFirewall.Text = "";

            if (treArmor.SelectedNode.Level == 0)
            {
                lblArmorEquipped.Text = "";
                foreach (Armor objArmor in _objCharacter.Armor)
                {
                    if (objArmor.Equipped && (objArmor.Location == treArmor.SelectedNode.Text || objArmor.Location == string.Empty && treArmor.SelectedNode == treArmor.Nodes[0]))
                        lblArmorEquipped.Text += objArmor.DisplayName + " (" + objArmor.TotalArmor.ToString() + ")\n";
                }
                if (lblArmorEquipped.Text == string.Empty)
                    lblArmorEquipped.Text = LanguageManager.Instance.GetString("String_None");

                lblArmorEquipped.Visible = true;

                _blnSkipRefresh = true;
                chkIncludedInArmor.Enabled = false;
                chkIncludedInArmor.Checked = false;
                chkIncludedInArmor.Enabled = false;
                chkIncludedInArmor.Checked = false;
                _blnSkipRefresh = false;
            }
            else
                lblArmorEquipped.Visible = false;

            if (treArmor.SelectedNode.Level == 1)
            {
                _blnSkipRefresh = true;

                // Loclate the selected Armor
                Armor objArmor = _objFunctions.FindArmor(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
                if (objArmor == null)
                    return;

                lblArmorValue.Text = objArmor.TotalArmor.ToString();
                lblArmorAvail.Text = objArmor.TotalAvail;
                lblArmorCapacity.Text = objArmor.CalculatedCapacity + " (" + objArmor.CapacityRemaining.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining") + ")";
                lblArmorCost.Text = String.Format("{0:###,###,##0¥}", objArmor.TotalCost);
                string strBook = _objOptions.LanguageBookShort(objArmor.Source);
                string strPage = objArmor.Page;
                lblArmorSource.Text = strBook + " " + strPage;
                tipTooltip.SetToolTip(lblArmorSource, _objOptions.LanguageBookLong(objArmor.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objArmor.Page);
                chkArmorEquipped.Enabled = true;
                chkArmorEquipped.Checked = objArmor.Equipped;
                if (objArmor.MaxRating == 0)
                {
                nudArmorRating.Enabled = false;
                }
                else
                {
                    nudArmorRating.Maximum = objArmor.MaxRating;
                    nudArmorRating.Value = objArmor.Rating;
                    nudArmorRating.Enabled = true;
                }

                _blnSkipRefresh = false;
            }
            else if (treArmor.SelectedNode.Level == 2)
            {
                bool blnIsMod = false;
                Armor objSelectedArmor = new Armor(_objCharacter);
                ArmorMod objSelectedMod = _objFunctions.FindArmorMod(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
                if (objSelectedMod != null)
                {
                    blnIsMod = true;
                    objSelectedArmor = objSelectedMod.Parent;
                }

                if (blnIsMod)
                {
                    lblArmorValue.Text = objSelectedMod.Armor.ToString();
                    lblArmorAvail.Text = objSelectedMod.TotalAvail;
                    if (objSelectedArmor.CapacityDisplayStyle == CapacityStyle.Standard)
                        lblArmorCapacity.Text = objSelectedMod.CalculatedCapacity;
                    else if (objSelectedArmor.CapacityDisplayStyle == CapacityStyle.Zero)
                        lblArmorCapacity.Text = "[0]";
                    else if (objSelectedArmor.CapacityDisplayStyle == CapacityStyle.PerRating)
                    {
                        if (objSelectedMod.Rating > 0)
                            lblArmorCapacity.Text = "[" + objSelectedMod.Rating.ToString() + "]";
                        else
                            lblArmorCapacity.Text = "[1]";
                    }
                    lblArmorCost.Text = String.Format("{0:###,###,##0¥}", objSelectedMod.TotalCost);

                    string strBook = _objOptions.LanguageBookShort(objSelectedMod.Source);
                    string strPage = objSelectedMod.Page;
                    lblArmorSource.Text = strBook + " " + strPage;
                    tipTooltip.SetToolTip(lblArmorSource, _objOptions.LanguageBookLong(objSelectedMod.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objSelectedMod.Page);
                    chkArmorEquipped.Enabled = true;
                    chkArmorEquipped.Checked = objSelectedMod.Equipped;
                    if (objSelectedMod.MaximumRating > 1)
                    {
                        _blnSkipRefresh = true;
                        nudArmorRating.Maximum = objSelectedMod.MaximumRating;
                        nudArmorRating.Enabled = true;
                        nudArmorRating.Value = objSelectedMod.Rating;
                        _blnSkipRefresh = false;
                    }
                    else
                    {
                        _blnSkipRefresh = true;
                        nudArmorRating.Maximum = 1;
                        nudArmorRating.Enabled = false;
                        nudArmorRating.Value = 1;
                        _blnSkipRefresh = false;
                    }

                    _blnSkipRefresh = true;
                    chkIncludedInArmor.Enabled = true;
                    chkIncludedInArmor.Checked = objSelectedMod.IncludedInArmor;
                    _blnSkipRefresh = false;
                }
                else
                {
                    Gear objSelectedGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objSelectedArmor);

                    lblArmorValue.Text = "";
                    lblArmorAvail.Text = objSelectedGear.TotalAvail(true);
                    if (objSelectedArmor.CapacityDisplayStyle == CapacityStyle.Standard)
                        lblArmorCapacity.Text = objSelectedGear.CalculatedCapacity;
                    else if (objSelectedArmor.CapacityDisplayStyle == CapacityStyle.Zero)
                        lblArmorCapacity.Text = "[0]";
                    else if (objSelectedArmor.CapacityDisplayStyle == CapacityStyle.PerRating)
                    {
                        if (objSelectedGear.Rating > 0)
                            lblArmorCapacity.Text = "[" + objSelectedGear.Rating.ToString() + "]";
                        else
                            lblArmorCapacity.Text = "[1]";
                    }
                    try
                    {
                        lblArmorCost.Text = String.Format("{0:###,###,##0¥}", objSelectedGear.TotalCost);
                    }
                    catch
                    {
                        lblArmorCost.Text = String.Format("{0:###,###,##0¥}", objSelectedGear.Cost);
                    }
                    string strBook = _objOptions.LanguageBookShort(objSelectedGear.Source);
                    string strPage = objSelectedGear.Page;
                    lblArmorSource.Text = strBook + " " + strPage;
                    tipTooltip.SetToolTip(lblArmorSource, _objOptions.LanguageBookLong(objSelectedGear.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objSelectedGear.Page);
                    chkArmorEquipped.Enabled = true;
                    chkArmorEquipped.Checked = objSelectedGear.Equipped;
                    if (objSelectedGear.MaxRating > 1)
                    {
                        _blnSkipRefresh = true;
                        nudArmorRating.Maximum = objSelectedGear.MaxRating;
                        nudArmorRating.Enabled = true;
                        nudArmorRating.Value = objSelectedGear.Rating;
                        _blnSkipRefresh = false;
                    }
                    else
                    {
                        _blnSkipRefresh = true;
                        nudArmorRating.Maximum = 1;
                        nudArmorRating.Enabled = false;
                        nudArmorRating.Value = 1;
                        _blnSkipRefresh = false;
                    }

                    if (objSelectedGear.GetType() == typeof(Commlink))
                    {
                        Commlink objCommlink = (Commlink)objSelectedGear;
                        lblArmorDeviceRating.Text = objCommlink.DeviceRating.ToString();
                        lblArmorAttack.Text = objCommlink.Attack.ToString();
                        lblArmorSleaze.Text = objCommlink.Sleaze.ToString();
                        lblArmorDataProcessing.Text = objCommlink.DataProcessing.ToString();
                        lblArmorFirewall.Text = objCommlink.Firewall.ToString();
                    }

                    _blnSkipRefresh = true;
                    chkIncludedInArmor.Enabled = false;
                    chkIncludedInArmor.Checked = false;
                    _blnSkipRefresh = false;
                }
            }
            else if (treArmor.SelectedNode.Level > 2)
            {
                Armor objSelectedArmor = new Armor(_objCharacter);
                Gear objSelectedGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objSelectedArmor);

                lblArmorValue.Text = "";
                lblArmorAvail.Text = objSelectedGear.TotalAvail(true);
                lblArmorCapacity.Text = objSelectedGear.CalculatedArmorCapacity;
                try
                {
                    lblArmorCost.Text = String.Format("{0:###,###,##0¥}", objSelectedGear.TotalCost);
                }
                catch
                {
                    lblArmorCost.Text = String.Format("{0:###,###,##0¥}", objSelectedGear.Cost);
                }
                string strBook = _objOptions.LanguageBookShort(objSelectedGear.Source);
                string strPage = objSelectedGear.Page;
                lblArmorSource.Text = strBook + " " + strPage;
                tipTooltip.SetToolTip(lblArmorSource, _objOptions.LanguageBookLong(objSelectedGear.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objSelectedGear.Page);
                chkArmorEquipped.Enabled = true;
                chkArmorEquipped.Checked = objSelectedGear.Equipped;
                if (objSelectedGear.MaxRating > 1)
                {
                    _blnSkipRefresh = true;
                    nudArmorRating.Maximum = objSelectedGear.MaxRating;
                    nudArmorRating.Enabled = true;
                    nudArmorRating.Value = objSelectedGear.Rating;
                    _blnSkipRefresh = false;
                }
                else
                {
                    _blnSkipRefresh = true;
                    nudArmorRating.Maximum = 1;
                    nudArmorRating.Enabled = false;
                    nudArmorRating.Value = 1;
                    _blnSkipRefresh = false;
                }

                if (objSelectedGear.GetType() == typeof(Commlink))
                {
                    Commlink objCommlink = (Commlink)objSelectedGear;
                    lblArmorDeviceRating.Text = objCommlink.DeviceRating.ToString();
                    lblArmorAttack.Text = objCommlink.Attack.ToString();
                    lblArmorSleaze.Text = objCommlink.Sleaze.ToString();
                    lblArmorDataProcessing.Text = objCommlink.DataProcessing.ToString();
                    lblArmorFirewall.Text = objCommlink.Firewall.ToString();
                }
            }
            else
            {
                lblArmorValue.Text = "";
                lblArmorAvail.Text = "";
                lblArmorCost.Text = "";
                lblArmorSource.Text = "";
                tipTooltip.SetToolTip(lblArmorSource, null);
                chkArmorEquipped.Enabled = false;
                nudArmorRating.Enabled = false;
            }
        }
Пример #21
0
        private void UpdateArmorInfo()
        {
            // Get the information for the selected piece of Armor.
            XmlNode objXmlArmor = _objXmlDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + lstArmor.SelectedValue + "\"]");
            // Create the Armor so we can show its Total Avail (some Armor includes Chemical Seal which adds +6 which wouldn't be factored in properly otherwise).
            Armor objArmor = new Armor(_objCharacter);
            TreeNode objNode = new TreeNode();
            objArmor.Create(objXmlArmor, objNode, null, 0, true);

            // Check for a Variable Cost.
            int intItemCost = 0;
            if (objXmlArmor["cost"].InnerText.StartsWith("Variable"))
            {
                int intMin = 0;
                int intMax = 0;
                string strCost = objXmlArmor["cost"].InnerText.Replace("Variable(", string.Empty).Replace(")", string.Empty);
                if (strCost.Contains("-"))
                {
                    string[] strValues = strCost.Split('-');
                    intMin = Convert.ToInt32(strValues[0]);
                    intMax = Convert.ToInt32(strValues[1]);
                }
                else
                    intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));

                if (intMax == 0)
                {
                    intMax = 1000000;
                    lblCost.Text = String.Format("{0:###,###,##0¥+}", intMin);
                }
                else
                    lblCost.Text = String.Format("{0:###,###,##0}", intMin) + "-" + String.Format("{0:###,###,##0¥}", intMax);

                intItemCost = intMin;
            }
            else if (objXmlArmor["cost"].InnerText.Contains("Rating"))
            {
                XPathNavigator nav = _objXmlDocument.CreateNavigator();
                XPathExpression xprCost = nav.Compile(objXmlArmor["cost"].InnerText.Replace("Rating", nudRating.Value.ToString()));
                double dblCost = (Convert.ToDouble(nav.Evaluate(xprCost), GlobalOptions.Instance.CultureInfo));
                if (chkBlackMarketDiscount.Checked)
                {
                    dblCost = dblCost - (dblCost*0.90);
                }
                intItemCost = Convert.ToInt32(dblCost);
                lblCost.Text = String.Format("{0:###,###,##0¥}", intItemCost);
            }
            else
            {
                double dblCost = Convert.ToDouble(objXmlArmor["cost"].InnerText, GlobalOptions.Instance.CultureInfo);
                dblCost *= 1 + (Convert.ToDouble(nudMarkup.Value, GlobalOptions.Instance.CultureInfo) / 100.0);
                if (chkBlackMarketDiscount.Checked)
                {
                    dblCost = dblCost * 0.90;
                }
                lblCost.Text = String.Format("{0:###,###,##0¥}", dblCost);
                intItemCost = Convert.ToInt32(dblCost);
            }

            lblCapacity.Text = objXmlArmor["armorcapacity"].InnerText;

            if (chkFreeItem.Checked)
            {
                lblCost.Text = String.Format("{0:###,###,##0¥}", 0);
                intItemCost = 0;
            }

            lblTest.Text = _objCharacter.AvailTest(intItemCost, lblAvail.Text);

            string strBook = _objCharacter.Options.LanguageBookShort(objXmlArmor["source"].InnerText);
            string strPage = objXmlArmor["page"].InnerText;
            if (objXmlArmor["altpage"] != null)
                strPage = objXmlArmor["altpage"].InnerText;
            lblSource.Text = strBook + " " + strPage;

            tipTooltip.SetToolTip(lblSource, _objCharacter.Options.LanguageBookLong(objXmlArmor["source"].InnerText) + " " + LanguageManager.Instance.GetString("String_Page") + " " + strPage);
        }
Пример #22
0
        /// <summary>
        /// Add a piece of Armor to the Armor TreeView.
        /// </summary>
        /// <param name="objArmor">Armor to add.</param>
        /// <param name="treArmor">Armor TreeView.</param>
        /// <param name="cmsArmor">ContextMenuStrip for the Armor Node.</param>
        /// <param name="cmsArmorMod">ContextMenuStrip for Armor Mod Nodes.</param>
        /// <param name="cmsArmorGear">ContextMenuStrip for Armor Gear Nodes.</param>
        public void CreateArmorTreeNode(Armor objArmor, TreeView treArmor, ContextMenuStrip cmsArmor, ContextMenuStrip cmsArmorMod, ContextMenuStrip cmsArmorGear)
        {
            TreeNode objNode = new TreeNode();
            objNode.Text = objArmor.DisplayName;
            objNode.Tag = objArmor.InternalId;
            if (objArmor.Notes != string.Empty)
                objNode.ForeColor = Color.SaddleBrown;
            objNode.ToolTipText = objArmor.Notes;

            foreach (ArmorMod objMod in objArmor.ArmorMods)
            {
                TreeNode objChild = new TreeNode();
                objChild.Text = objMod.DisplayName;
                objChild.Tag = objMod.InternalId;
                objChild.ContextMenuStrip = cmsArmorMod;
                if (objMod.Notes != string.Empty)
                    objChild.ForeColor = Color.SaddleBrown;
                objChild.ToolTipText = objMod.Notes;
                objNode.Nodes.Add(objChild);
                objNode.Expand();
            }

            foreach (Gear objGear in objArmor.Gear)
            {
                TreeNode objChild = new TreeNode();
                objChild.Text = objGear.DisplayName;
                objChild.Tag = objGear.InternalId;
                if (objGear.Notes != string.Empty)
                    objChild.ForeColor = Color.SaddleBrown;
                objChild.ToolTipText = objGear.Notes;

                BuildGearTree(objGear, objChild, cmsArmorGear);

                objChild.ContextMenuStrip = cmsArmorGear;
                objNode.Nodes.Add(objChild);
                objNode.Expand();
            }

            TreeNode objParent = new TreeNode();
            if (objArmor.Location == "")
                objParent = treArmor.Nodes[0];
            else
            {
                foreach (TreeNode objFind in treArmor.Nodes)
                {
                    if (objFind.Text == objArmor.Location)
                    {
                        objParent = objFind;
                        break;
                    }
                }
            }

            objNode.ContextMenuStrip = cmsArmor;
            objParent.Nodes.Add(objNode);
            objParent.Expand();
        }