Exemplo n.º 1
0
 private void AddButtonClick(object sender, EventArgs e)
 {
     using (var dataForm = new FormArmorData())
     {
         dataForm.ShowDialog();
         if (dataForm.Armor != null)
             AddArmor(dataForm.Armor);
     }
 }
Exemplo n.º 2
0
        private void EditButtonClick(object sender, EventArgs e)
        {
            string name = DetailList.SelectedItem.ToString().Split(':')[0];
            ArmorData data = ItemManager.ArmorData[name];
            ArmorData newData;
            using (var dataForm = new FormArmorData())
            {
                dataForm.Armor = data;
                dataForm.ShowDialog();

                if (dataForm.Armor == null)
                    return;

                if (dataForm.Armor.Name == name)
                {
                    ItemManager.ArmorData[name] = dataForm.Armor;
                    LoadArmor();
                    return;
                }

                newData = dataForm.Armor;
            }

            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.ArmorData.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.ArmorData.Add(newData.Name, newData);
        }