Beispiel #1
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            using (FormWeaponDetails formWeaponDetails = new FormWeaponDetails())
            {
                formWeaponDetails.ShowDialog();

                if (formWeaponDetails.Weapon != null)
                    AddWeapon(formWeaponDetails.Weapon);
            }
        }
Beispiel #2
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            using (FormWeaponDetails frmWeaponDetails = new FormWeaponDetails())
            {
                frmWeaponDetails.ShowDialog();

                if (frmWeaponDetails.Weapon != null)
                {
                    AddWeapon(frmWeaponDetails.Weapon);
                }
            }
        }
Beispiel #3
0
        void btnEdit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string   detail = lbDetails.SelectedItem.ToString();
                string[] parts  = detail.Split(',');
                string   entity = parts[0].Trim();

                WeaponData data    = itemManager.WeaponData[entity];
                WeaponData newData = null;

                using (FormWeaponDetails frmWeaponData = new FormWeaponDetails())
                {
                    frmWeaponData.Weapon = data;
                    frmWeaponData.ShowDialog();

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

                    if (frmWeaponData.Weapon.Name == entity)
                    {
                        itemManager.WeaponData[entity] = frmWeaponData.Weapon;
                        FillListBox();
                        return;
                    }

                    newData = frmWeaponData.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 (itemManager.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);
            }
        }
Beispiel #4
0
        void btnEdit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string detail = lbDetails.SelectedItem.ToString();
                string[] parts = detail.Split(',');
                string entity = parts[0].Trim();

                WeaponData data = itemManager.WeaponData[entity];
                WeaponData newData = null;

                using (FormWeaponDetails frmWeaponData = new FormWeaponDetails())
                {
                    frmWeaponData.Weapon = data;
                    frmWeaponData.ShowDialog();

                    if (frmWeaponData.Weapon == null)
                        return;

                    if (frmWeaponData.Weapon.Name == entity)
                    {
                        itemManager.WeaponData[entity] = frmWeaponData.Weapon;
                        FillListBox();
                        return;
                    }

                    newData = frmWeaponData.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 (itemManager.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);
            }
        }