예제 #1
0
 private void AddButtonClick(object sender, EventArgs e)
 {
     using (var dataForm = new FormWeaponData())
     {
         dataForm.ShowDialog();
         if (dataForm.Weapon != null)
             AddWeapon(dataForm.Weapon);
     }
 }
예제 #2
0
        private void EditButtonClick(object sender, EventArgs e)
        {
            if (DetailList.SelectedItem == null)
                return;

            string name = DetailList.SelectedItem.ToString().Split(':')[0];
            WeaponData data = ItemManager.WeaponData[name];
            WeaponData newData;
            using (var dataForm = new FormWeaponData())
            {
                dataForm.Weapon = data;
                dataForm.ShowDialog();

                if (dataForm.Weapon == null)
                    return;

                if (dataForm.Weapon.Name == name)
                {
                    ItemManager.WeaponData[name] = dataForm.Weapon;
                    LoadWeapons();
                    return;
                }

                newData = dataForm.Weapon;
            }

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

            if (ItemManager.WeaponData.ContainsKey(newData.Name))
            {
                MessageBox.Show("Entry already exists. Use Edit to modify the entry.", "Entry Exists",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DetailList.Items.Add(newData);
            ItemManager.WeaponData.Add(newData.Name, newData);
        }