Example #1
0
        private void EquipmentImg_Click(object sender, EventArgs e)
        {
            if (!(sender is PictureBox))
            {
                return;
            }

            PictureBox box      = sender as PictureBox;
            string     itemType = box.Name.Substring(3);
            SItem      item     = mStats.GetItemFromName(itemType).Clone() as SItem;

            if (box == imgWaffe)
            {
                frmItemBonusWeapon frm = new frmItemBonusWeapon(item, itemType);
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                item.Name       = frm.txtName.Text;
                item.Sockel     = (int)frm.numSockel.Value;
                item.Bonus      = frm.GetBonusList();
                item.WeaponType = (EWeaponType)frm.cbWeaponType.SelectedIndex;
            }
            else
            {
                frmItemBonus frm = new frmItemBonus(item, itemType);
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                item.Name       = frm.txtName.Text;
                item.Sockel     = (int)frm.numSockel.Value;
                item.Bonus      = frm.GetBonusList();
                item.WeaponType = EWeaponType.None;
            }
            if (item.Name == string.Empty && item.Bonus.Count > 0)
            {
                item.Name = itemType;
            }
            else if (item.Name == string.Empty && item.Bonus.Count == 0)
            {
                item = SItem.Empty.Clone() as SItem;
            }

            if (item.Equals(SItem.Empty))
            {
                box.Image = null;
            }
            else
            {
                box.Image = Bitmap.FromStream(mAssembly.GetManifestResourceStream("Ssc.Resources.EQ_" + itemType + ".png"));
            }

            mStats.SaveItemByName(itemType, item);
            if (mStats.GetItemFromName(itemType) == SItem.Empty)
            {
                box.Image = null;
            }

            box.Invalidate();
            UpdateAll();
        }