예제 #1
0
        public void btnAdd_Click(object sender, EventArgs e)
        {
            using (ArmorDetails frmArmorDetails = new ArmorDetails())
            {
                frmArmorDetails.ShowDialog();

                if (frmArmorDetails.Armor != null)
                {
                    AddArmor(frmArmorDetails.Armor);
                }
            }
        }
예제 #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();

                ArmorData armor = itemDataManager.ArmorData[entity];
                ArmorData newData = null;

                using (ArmorDetails frmArmorDetails = new ArmorDetails())
                {
                    frmArmorDetails.Armor = armor;
                    frmArmorDetails.ShowDialog();

                    if (frmArmorDetails.Armor == null)
                    {
                        return;
                    }

                    if (frmArmorDetails.Armor.name == entity)
                    {
                        itemDataManager.ArmorData[entity] = frmArmorDetails.Armor;
                        FillListBox();
                        return;
                    }

                    newData = frmArmorDetails.Armor;
                }

                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.ArmorData.ContainsKey(newData.name))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry");
                    return;
                }

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