Пример #1
0
        public void btnAdd_Click(object sender, EventArgs e)
        {
            using (WeaponDetails frmWeaponDetails = new WeaponDetails())
            {
                frmWeaponDetails.ShowDialog();

                if (frmWeaponDetails.Weapon != null)
                {
                    AddWeapon(frmWeaponDetails.Weapon);
                }
            }
        }
Пример #2
0
        public void btnEdit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string detail = Convert.ToString(lbDetails.SelectedItem);
                string[] parts = detail.Split(',');
                string entity = (string)parts[0].Trim();

                WeaponData weapon = itemDataManager.WeaponData[entity];
                WeaponData newData = null;

                using (WeaponDetails frmWeaponDetails = new WeaponDetails())
                {
                    frmWeaponDetails.Weapon = weapon;
                    frmWeaponDetails.ShowDialog();

                    if (frmWeaponDetails.Weapon == null)
                    {
                        return;
                    }

                    if (frmWeaponDetails.Weapon.name == entity)
                    {
                        itemDataManager.WeaponData[entity] = frmWeaponDetails.Weapon;
                        FillListBox();
                        return;
                    }

                    newData = frmWeaponDetails.Weapon;
                }

                DialogResult result = MessageBox.Show("Name has changed. Do you want to add a new entry?",
                                                        "New Entry", MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                {
                    return;
                }

                if (itemDataManager.WeaponData.ContainsKey(newData.name))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry");
                    return;
                }

                lbDetails.Items.Add(newData);
                ItemManager.WeaponData.Add(newData.name, newData);
            }
        }